|
|
@ -29,12 +29,13 @@ class VerifyController(http.Controller): |
|
|
|
link = datetime.datetime.strptime(link_date, "%Y%m%d").date() |
|
|
|
diff = today - link |
|
|
|
if diff.days > 5 or diff.days < 0: |
|
|
|
return "<center style='color:red'>Not valid!<br/>" \ |
|
|
|
return "<center style='color:red'>Not valid!<br/>"\ |
|
|
|
"The link you entered is either not valid or expired."\ |
|
|
|
"<br/>Please request a new link.</center>" |
|
|
|
partner = request.env['res.partner'].sudo()\ |
|
|
|
.search([('email', '=', email), |
|
|
|
('name', '=', contact_name)]) |
|
|
|
partner = request.env['res.partner'].sudo().search([ |
|
|
|
('email', '=', email), |
|
|
|
('name', '=', contact_name) |
|
|
|
]) |
|
|
|
if partner: |
|
|
|
for part in partner: |
|
|
|
part.is_verified = True |
|
|
@ -51,14 +52,14 @@ class VerifyController(http.Controller): |
|
|
|
part.letter_contact = True |
|
|
|
else: |
|
|
|
part.letter_contact = False |
|
|
|
request.env.ref('website_contact_extend.' |
|
|
|
'confirmation_email_template')\ |
|
|
|
.sudo().send_mail(part.id) |
|
|
|
return "<center style='color:green'>" \ |
|
|
|
"Thank You! Your email address has been verified!" \ |
|
|
|
request.env.ref( |
|
|
|
'website_contact_extend.confirmation_email_template' |
|
|
|
).sudo().send_mail(part.id) |
|
|
|
return "<center style='color:green'>"\ |
|
|
|
"Thank You! Your email address has been verified!"\ |
|
|
|
"</center>" |
|
|
|
else: |
|
|
|
return "<center style='color:red'>Not valid!<br/>" \ |
|
|
|
return "<center style='color:red'>Not valid!<br/>"\ |
|
|
|
"The link you entered is either not valid or expired."\ |
|
|
|
"<br/>Please request a new link.</center>" |
|
|
|
|
|
|
@ -71,9 +72,10 @@ class MyFilter(parent_controller.WebsiteForm): |
|
|
|
methods=['POST'], |
|
|
|
website=True) |
|
|
|
def website_form(self, model_name, **kwargs): |
|
|
|
model_record = request.env['ir.model'].sudo()\ |
|
|
|
.search([('model', '=', model_name), |
|
|
|
('website_form_access', '=', True)]) |
|
|
|
model_record = request.env['ir.model'].sudo().search([ |
|
|
|
('model', '=', model_name), |
|
|
|
('website_form_access', '=', True) |
|
|
|
]) |
|
|
|
if not model_record: |
|
|
|
return json.dumps(False) |
|
|
|
# need_send_email = False |
|
|
@ -109,26 +111,32 @@ class MyFilter(parent_controller.WebsiteForm): |
|
|
|
return json.dumps({'error_fields': e.args[0]}) |
|
|
|
|
|
|
|
try: |
|
|
|
id_record = self.insert_record(request, |
|
|
|
model_record, |
|
|
|
data['record'], |
|
|
|
data['custom'], |
|
|
|
data.get('meta')) |
|
|
|
id_record = self.insert_record( |
|
|
|
request, |
|
|
|
model_record, |
|
|
|
data['record'], |
|
|
|
data['custom'], |
|
|
|
data.get('meta') |
|
|
|
) |
|
|
|
if id_record: |
|
|
|
self.insert_attachment(model_record, |
|
|
|
id_record, |
|
|
|
data['attachments']) |
|
|
|
self.insert_attachment( |
|
|
|
model_record, |
|
|
|
id_record, |
|
|
|
data['attachments'] |
|
|
|
) |
|
|
|
if id_record and send_mail and model_name == "crm.lead": |
|
|
|
crm_lead_obj = request.env['crm.lead'].sudo()\ |
|
|
|
.search([('id', '=', id_record)]) |
|
|
|
crm_lead_obj = request.env['crm.lead'].sudo().search([ |
|
|
|
('id', '=', id_record)] |
|
|
|
) |
|
|
|
email_data = crm_lead_obj.email_from + "####" +\ |
|
|
|
crm_lead_obj.contact_name + "####" +\ |
|
|
|
str(email_contact) + "####" +\ |
|
|
|
str(phone_contact) + "####" +\ |
|
|
|
str(letter_contact)+"####" +\ |
|
|
|
str(crm_lead_obj.create_date) |
|
|
|
ency_email = base64.b64encode(email_data.encode())\ |
|
|
|
.decode("utf-8") |
|
|
|
ency_email = base64.b64encode(email_data.encode()).decode( |
|
|
|
"utf-8" |
|
|
|
) |
|
|
|
action_url = '%s/verify_email/?data=%s' % ( |
|
|
|
request.env['ir.config_parameter']. |
|
|
|
sudo().get_param('web.base.url'), |
|
|
@ -136,9 +144,9 @@ class MyFilter(parent_controller.WebsiteForm): |
|
|
|
) |
|
|
|
if crm_lead_obj: |
|
|
|
crm_lead_obj.email_link = action_url |
|
|
|
request.env.ref('website_contact_extend.' |
|
|
|
'verification_email_template')\ |
|
|
|
.send_mail(id_record) |
|
|
|
request.env.ref( |
|
|
|
'website_contact_extend.verification_email_template' |
|
|
|
).send_mail(id_record) |
|
|
|
# Some fields have additional SQL constraints |
|
|
|
# that we can't check generically |
|
|
|
# Ex: crm.lead.probability which is a float between 0 and 1 |
|
|
|