website_crm: contact form improvement
get argument are processed and set into input fields + hidden fields save some datas from http headers controller should save all the submitted vars bzr revid: chm@openerp.com-20140310162626-libizyxlycvuwo7h
This commit is contained in:
@@ -15,8 +15,14 @@ class contactus(http.Controller):
|
||||
)
|
||||
return url
|
||||
|
||||
@http.route(['/page/website.contactus'], type='http', auth="public", website=True, multilang=True)
|
||||
def contact(self, **kwargs):
|
||||
return request.website.render("website.contactus", {
|
||||
'kwargs': kwargs.items()
|
||||
})
|
||||
|
||||
@http.route(['/crm/contactus'], type='http', auth="public", website=True, multilang=True)
|
||||
def contactus(self, description=None, partner_name=None, phone=None, contact_name=None, email_from=None, name=None):
|
||||
def contactus(self, description=None, partner_name=None, phone=None, contact_name=None, email_from=None, name=None, **kwargs):
|
||||
post = {}
|
||||
post['description'] = description
|
||||
post['partner_name'] = partner_name
|
||||
@@ -35,6 +41,7 @@ class contactus(http.Controller):
|
||||
if not post.get(field):
|
||||
error.add(field)
|
||||
if error:
|
||||
values.update(kwargs=kwargs.items())
|
||||
return request.website.render("website.contactus", values)
|
||||
|
||||
# if not given: subject is contact name
|
||||
@@ -48,9 +55,18 @@ class contactus(http.Controller):
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
environ = request.httprequest.headers.environ
|
||||
values['description'] = "%s\n-----------------------------\nIP: %s\nUSER_AGENT: %s\nACCEPT_LANGUAGE: %s" % (
|
||||
values['description'],
|
||||
environ.get("REMOTE_ADDR"),
|
||||
environ.get("HTTP_USER_AGENT"),
|
||||
environ.get("HTTP_ACCEPT_LANGUAGE"))
|
||||
for field in kwargs.items():
|
||||
values['description'] = "%s\n%s: %s" % (values['description'], field[0], field[1])
|
||||
|
||||
request.registry['crm.lead'].create(request.cr, SUPERUSER_ID, post, request.context)
|
||||
company = request.website.company_id
|
||||
values = {
|
||||
'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 '')
|
||||
'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.contactus_thanks", values)
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
<template id="contactus_form" name="Contact Form" inherit_id="website.contactus" inherit_option_id="website.contactus">
|
||||
<xpath expr="//div[@name='mail_button']" position="replace">
|
||||
<form action="/crm/contactus" method="post" class="form-horizontal mt32" >
|
||||
<t t-foreach="kwargs" t-as="kwarg">
|
||||
<input type="hidden" t-att-name="kwarg[0]" t-att-value="kwarg[1]"/>
|
||||
</t>
|
||||
<div t-attf-class="form-group #{error and 'contact_name' in error and 'has-error' or ''}">
|
||||
<label class="col-md-3 col-sm-4 control-label" for="contact_name">Your Name</label>
|
||||
<div class="col-md-7 col-sm-8">
|
||||
|
||||
Reference in New Issue
Block a user