[IMP] 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-20140312140232-nhdkhjc38xnviu1d
This commit is contained in:
commit
44523f4679
|
@ -15,8 +15,18 @@ class contactus(http.Controller):
|
|||
)
|
||||
return url
|
||||
|
||||
@http.route(['/page/website.contactus'], type='http', auth="public", website=True, multilang=True)
|
||||
def contact(self, **kwargs):
|
||||
values = {}
|
||||
for field in ['description', 'partner_name', 'phone', 'contact_name', 'email_from', 'name']:
|
||||
if kwargs.get(field):
|
||||
values[field] = kwargs.pop(field)
|
||||
values.update(kwargs=kwargs.items())
|
||||
print values
|
||||
return request.website.render("website.contactus", values)
|
||||
|
||||
@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 +45,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 +59,19 @@ class contactus(http.Controller):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
environ = request.httprequest.headers.environ
|
||||
post['description'] = "%s\n-----------------------------\nIP: %s\nUSER_AGENT: %s\nACCEPT_LANGUAGE: %s\nREFERER: %s" % (
|
||||
post['description'],
|
||||
environ.get("REMOTE_ADDR"),
|
||||
environ.get("HTTP_USER_AGENT"),
|
||||
environ.get("HTTP_ACCEPT_LANGUAGE"),
|
||||
environ.get("HTTP_REFERER"))
|
||||
for field in kwargs.items():
|
||||
post['description'] = "%s\n%s: %s" % (post['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">
|
||||
|
|
Loading…
Reference in New Issue