diff --git a/addons/website/views/views.xml b/addons/website/views/views.xml index 0d4e55126cc..3e861e1c4e4 100644 --- a/addons/website/views/views.xml +++ b/addons/website/views/views.xml @@ -271,6 +271,20 @@ + + + Name + + + + + ✆ + + + + + + @@ -292,18 +306,7 @@ - - Name - - - - - ✆ - - - - - + diff --git a/addons/website_crm/controllers/main.py b/addons/website_crm/controllers/main.py index 082eb3634cd..dcdd5590c78 100644 --- a/addons/website_crm/controllers/main.py +++ b/addons/website_crm/controllers/main.py @@ -6,17 +6,38 @@ from openerp.addons.website.models import website from urllib import quote_plus + class contactus(http.Controller): + def generate_google_map_url(self, street, city, city_zip, country_name): + url = "http://maps.googleapis.com/maps/api/staticmap?center=%s&sensor=false&zoom=8&size=298x298" % quote_plus( + '%s, %s %s, %s' % (street, city, city_zip, country_name) + ) + return url + @website.route(['/crm/contactus'], type='http', auth="admin", multilang=True) def contactus(self, *arg, **post): + required_fields = ['contact_name', 'email_from', 'description'] post['user_id'] = False + error = set() + values = dict((key, post.get(key)) for key in post) + values['error'] = error + + # fields validation + for field in required_fields: + if not post.get(field): + error.add(field) + if error: + return request.website.render("website.contactus", values) + + # if not given: subject is contact name + if not post.get('name'): + post['name'] = post.get('contact_name') + request.registry['crm.lead'].create(request.cr, request.uid, post, request.context) company = request.website.company_id values = { - 'google_map_url': "http://maps.googleapis.com/maps/api/staticmap?center=%s&sensor=false&zoom=8&size=298x298" % quote_plus('%s, %s %s, %s' % (company.street, company.city, company.zip, company.country_id and company.country_id.name_get()[0][1] or '')) + 'google_map_url': self.generate_google_map_url(company.street, company.city, company.zip, company.country_id and company.country_id.name_get()[0][1] or '') } - return request.website.render("website_crm.thanks", values) - -# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4: + return request.website.render("website_crm.contactus_thanks", values) diff --git a/addons/website_crm/views/website_crm.xml b/addons/website_crm/views/website_crm.xml index 44d14f1bdf3..e10fd094795 100644 --- a/addons/website_crm/views/website_crm.xml +++ b/addons/website_crm/views/website_crm.xml @@ -5,34 +5,34 @@ - + Your Name - + - + Phone Number - + - + Email - + - + Subject - + - + Your Question - + @@ -44,27 +44,49 @@ - - - Message Sent - - - - Your message has been sent successfully. - × - - Thanks! - - We will get back to you shortly. - - If you have an emergency, do not hesitate to contact us by phone: - - - : - : - - + + + + Your Company + + + + + + + + + Contact us - + + + + + + + + + Your message has been sent successfully. + × + + Thanks! + + We will get back to you shortly. + + If you have an emergency, do not hesitate to contact us by phone: + + + : + : + + + + + + + + +
- We will get back to you shortly. -
- If you have an emergency, do not hesitate to contact us by phone: -
+ We will get back to you shortly. +
+ If you have an emergency, do not hesitate to contact us by phone: +