Browse Source

[Fix] add changes for lint errors

pull/35/head
ITISAG-Git 5 years ago
parent
commit
3672394342
  1. 2
      .gitignore
  2. 0
      website_contact_extend/__manifest__.py
  3. 49
      website_contact_extend/controllers/contactby.py
  4. 43
      website_contact_extend/controllers/myfilter.py
  5. 0
      website_contact_extend/models/__init__.py
  6. 2
      website_contact_extend/models/res_partner.py
  7. 2
      website_contact_extend/security/ir.model.access.csv
  8. 29
      website_contact_extend/static/src/js/contactus.js
  9. 2
      website_contact_extend/views/disp_msg_template.xml
  10. 2
      website_contact_extend/views/email_template.xml
  11. 2
      website_contact_extend/views/website_contact.xml

2
.gitignore

@ -57,3 +57,5 @@ docs/_build/
# OSX Files
*.DS_Store
.eslintrc.json

0
website_contact_extend/__manifest__.py

49
website_contact_extend/controllers/contactby.py

@ -3,8 +3,6 @@
from odoo.addons.website_form.controllers import main as parent_controller
from odoo import http
from odoo.http import request
from odoo.exceptions import ValidationError
from psycopg2 import IntegrityError
import base64
import json
@ -13,7 +11,8 @@ link_data = {}
class ContactByController(http.Controller):
@http.route('/check_user_exists/', type='json', auth="public", methods=['POST'], website=True, csrf=False)
@http.route('/check_user_exists/', type='json', auth="public",
methods=['POST'], website=True, csrf=False)
def check_user_exists(self, email_from, company_name, **kwargs):
res_part_rec = request.env['res.partner'].sudo().search([
('email', '=', email_from),
@ -22,7 +21,8 @@ class ContactByController(http.Controller):
res_part_email = request.env['res.partner'].sudo().search([
('email', '=', email_from)])
if len(res_part_rec) > 0 or len(res_part_rec) == 0 and len(res_part_email) > 0:
if len(res_part_rec) > 0 or len(res_part_rec) == 0 \
and len(res_part_email) > 0:
# if partner:
return True
return False
@ -37,8 +37,10 @@ class ContactByController(http.Controller):
# link_data =base64.b64decode(kwargs.get("data")).decode("utf-8") \
# print('FD')
# print(request.session['form_data'])
return http.request.render('website_contact_extend.review_form', {'form_data': request.session['form_data'],
'form_data_dict': request.session['form_data_dict']})
return http.request.render(
'website_contact_extend.review_form',
{'form_data': request.session['form_data'],
'form_data_dict': request.session['form_data_dict']})
@http.route('/contact_by/<string:data>',
type='http',
@ -52,7 +54,8 @@ class ContactByController(http.Controller):
# link_data =base64.b64decode(kwargs.get("data")).decode("utf-8") \
link_data = data
return http.request.render('website_contact_extend.contactby_form')
# return "<center style='color:red'>You are at the right place</center>"
# return "<center style='color:red'>You are at the right \
# place</center>"
@http.route('/contact_by_send/<string:model_name>',
type='http',
@ -130,11 +133,17 @@ class ContactByController(http.Controller):
return json.dumps({'id': partner[0].id})
# return http.request.render('website_contact_extend.disp_msg_template', {'message_success': 'Means of contact changed!'})
# return http.request.render('website_contact_extend.\
# disp_msg_template', {'message_success': \
# 'Means of contact changed!'})
# return "<p style='color: green'>Means of contact changed!</p>"
# else:
# # return http.request.render('website_contact_extend.disp_msg_template', {'message_failure': 'Could not change your means of contact. Please request a new link'})
# return "<p style='color: red'>Could not change your means of contact. Please request a new link</p>"
# return http.request.render('website_contact_extend.\
# disp_msg_template', {'message_failure': \
# 'Could not change your means of contact. \
# Please request a new link'})
# return "<p style='color: red'>Could not change your means\
# of contact. Please request a new link</p>"
class FormReview(parent_controller.WebsiteForm):
@ -177,7 +186,8 @@ class FormReview(parent_controller.WebsiteForm):
''
)
if len(res_part_email) > 0 and len(res_part_rec) == 0 and res_part_email[0].is_verified == True:
if len(res_part_email) > 0 and len(res_part_rec) == 0 and \
res_part_email[0].is_verified is True:
print('Company change detected')
res_cat = request.env['res.partner.category'].search(
@ -220,10 +230,12 @@ class FormReview(parent_controller.WebsiteForm):
if update_parent_partner and len(update_parent_partner) > 0:
update_parent_partner[0].category_id = False
update_parent_partner_comp = request.env['res.partner'].sudo().search([
('id', '=', res_part_email[0].parent_id.id)])
update_parent_partner_comp = \
request.env['res.partner'].sudo().search([
('id', '=', res_part_email[0].parent_id.id)])
if update_parent_partner_comp and len(update_parent_partner_comp) > 0:
if update_parent_partner_comp and \
len(update_parent_partner_comp) > 0:
update_parent_partner_comp[0].category_id = False
res_partner_company_dict = res_partner_dict.copy()
@ -234,7 +246,8 @@ class FormReview(parent_controller.WebsiteForm):
res_partner_company_dict.pop('phone')
res_partner_company_dict['name'] = res_partner_data['partner_name']
res_partner_company_dict['display_name'] = res_partner_data['partner_name']
res_partner_company_dict['display_name'] = \
res_partner_data['partner_name']
res_partner_company_dict['customer'] = False
res_partner_company_dict['is_company'] = True
res_partner_company_dict['company_type'] = 'company'
@ -252,7 +265,8 @@ class FormReview(parent_controller.WebsiteForm):
res_partner_company_dict['child_ids'] = [
[6, 'virtual_1798', [id_record_res]]]
id_record_res_company = self.insert_record(
# id_record_res_company = self.insert_record(
self.insert_record(
request,
request.env['ir.model'].search(
[('model', '=', 'res.partner')]),
@ -305,7 +319,8 @@ class FormReview(parent_controller.WebsiteForm):
'website_contact_extend.verification_email_template'
).sudo().send_mail(id_record)
request.env.ref('website_contact_extend.email_template_onchange_data').sudo(
request.env.ref('website_contact_extend.\
email_template_onchange_data').sudo(
).send_mail(id_record)
request.session['form_builder_model_model'] = model_record.model

43
website_contact_extend/controllers/myfilter.py

@ -16,8 +16,6 @@ class VerifyController(http.Controller):
methods=['GET'],
website=True)
def verify_email(self, **kwargs):
print(kwargs)
if kwargs:
contact_url = '%s/contact_by/%s' % (
@ -80,13 +78,16 @@ class VerifyController(http.Controller):
if request_gdpdr == "True":
# print("Hit")
page_render_html = page_render_html + "<br/>"\
"<div style='text-align: center'>Click <a href='" + contact_url + \
"'>here</a> to choose how you want to be contacted</div>"
"<div style='text-align: center'>"\
"Click <a href='" + contact_url + \
"'>here</a> to choose how you"\
" want to be contacted</div>"
if personal_data == "True":
request.env.ref(
'website_contact_extend.email_template_information_request'
'website_contact_extend.\
email_template_information_request'
).sudo().send_mail(int(crm_id))
request.env.ref(
@ -122,7 +123,6 @@ class MyFilter(parent_controller.WebsiteForm):
# need_send_email = False
try:
data = self.extract_data(model_record, request.params)
print(data)
# contact_type = False
phone_contact = False
letter_contact = False
@ -133,7 +133,7 @@ class MyFilter(parent_controller.WebsiteForm):
index = 0
for field_name, field_value in request.params.items():
# if field_name == "contact_type":
# contact_type = field_value
# contact_type = field_value
if field_name == "send_mail" and field_value == "send_mail":
send_mail = True
if field_name == "phone_contact" \
@ -160,7 +160,7 @@ class MyFilter(parent_controller.WebsiteForm):
res_partner_data = data['record']
try:
contact_name = data.get("record").get("contact_name")
# contact_name = data.get("record").get("contact_name")
email = data.get("record").get("email_from")
company = data.get("record").get("partner_name")
res_part_rec = request.env['res.partner'].sudo().search([
@ -172,7 +172,8 @@ class MyFilter(parent_controller.WebsiteForm):
res_part_email = request.env['res.partner'].sudo().search([
('email', '=', email)])
if len(res_part_rec) > 0 or len(res_part_rec) == 0 and len(res_part_email) > 0:
if len(res_part_rec) > 0 or len(res_part_rec) == 0 \
and len(res_part_email) > 0:
request.session['review_form'] = "/contact-us-form-review"
print('Display review')
@ -248,11 +249,13 @@ class MyFilter(parent_controller.WebsiteForm):
# res_partner_data['phone'] = ""
res_partner_dict['name'] = res_partner_data['contact_name']
res_partner_dict['display_name'] = res_partner_data['contact_name']
res_partner_dict['display_name'] = \
res_partner_data['contact_name']
res_partner_dict['email'] = res_partner_data['email_from']
if 'phone' in res_partner_data:
res_partner_dict['phone'] = res_partner_data['phone']
res_partner_dict['company_name'] = res_partner_data['partner_name']
res_partner_dict['company_name'] = \
res_partner_data['partner_name']
res_partner_dict['category_id'] = [[6, False, [cat_id]]]
res_partner_company_dict = res_partner_dict.copy()
@ -261,8 +264,10 @@ class MyFilter(parent_controller.WebsiteForm):
if 'phone' in res_partner_company_dict:
res_partner_company_dict.pop('phone')
res_partner_company_dict['name'] = res_partner_data['partner_name']
res_partner_company_dict['display_name'] = res_partner_data['partner_name']
res_partner_company_dict['name'] = \
res_partner_data['partner_name']
res_partner_company_dict['display_name'] = \
res_partner_data['partner_name']
res_partner_company_dict['customer'] = False
res_partner_company_dict['is_company'] = True
res_partner_company_dict['company_type'] = 'company'
@ -278,7 +283,7 @@ class MyFilter(parent_controller.WebsiteForm):
res_partner_dict['parent_id'] = id_record_res_company
id_record_res = self.insert_record(
self.insert_record(
request,
request.env['ir.model'].search(
[('model', '=', 'res.partner')]),
@ -312,7 +317,7 @@ class MyFilter(parent_controller.WebsiteForm):
print("RGPDR" + str(request_gdpdr))
# if request_gdpdr == True:
if request_gdpdr == True or send_mail == True:
if request_gdpdr is True or send_mail is True:
if id_record and model_name == "crm.lead":
crm_lead_obj = request.env['crm.lead'].sudo().search([
('id', '=', id_record)]
@ -328,9 +333,8 @@ class MyFilter(parent_controller.WebsiteForm):
str(crm_lead_obj.create_date)
print(email_data)
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'),
@ -339,7 +343,8 @@ 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'
'website_contact_extend.\
verification_email_template'
).sudo().send_mail(id_record)
except IntegrityError:

0
website_contact_extend/models/__init__.py

2
website_contact_extend/models/res_partner.py

@ -25,12 +25,10 @@ class ResContacts(models.Model):
# s
@api.multi
def write(self, vals):
print(vals)
return super(ResContacts, self).write(vals)
@api.model
def create(self, vals):
print(vals)
return super(ResContacts, self).create(vals)

2
website_contact_extend/security/ir.model.access.csv

@ -1,4 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_mail_template,access.mail.template.view,mail.model_mail_template,,1,0,0,0
access_crm_lead_record,access.crm.lead.record,crm.model_crm_lead,,1,0,0,0
access_mail_mail_record,access.mail.mail.record,mail.model_mail_mail,,1,1,1,0
access_mail_mail_record,access.mail.mail.record,mail.model_mail_mail,,1,1,1,0

29
website_contact_extend/static/src/js/contactus.js

@ -1,41 +1,40 @@
odoo.define('website_contact_extend.success_page', function (require) {
odoo.define('website_contact_extend.success_page', function(require) {
"use strict";
var ajax = require("web.ajax");
// function check_user_exists(){
// }
$(document).on('blur', '.input_email_from', function (ev) {
$(document).on('blur', '.input_email_from', function(ev) {
var email_from = $('.input_email_from').val();
var company_name = $('.input_company').val();
return ajax.jsonRpc('/check_user_exists', 'call', {
email_from: email_from,
email_from: email_from,
company_name: company_name,
}).then(function (res) {
}).then(function(res) {
var contactus_page = "/contactus-thank-you";
if(res){
if (res) {
contactus_page = "/contact-us-form-review";
}
$('form[action="/website_form/"]').attr('data-success_page',contactus_page);
var formaction_webform = 'form[action="/website_form/"]';
$(formaction_webform).attr('data-success_page', contactus_page);
});
});
$(document).on('blur', '.input_company', function (ev) {
$(document).on('blur', '.input_company', function(ev) {
var email_from = $('.input_email_from').val();
var company_name = $('.input_company').val();
return ajax.jsonRpc('/check_user_exists', 'call', {
email_from: email_from,
email_from: email_from,
company_name: company_name,
}).then(function (res) {
}).then(function(res) {
var contactus_page = "/contactus-thank-you";
if(res){
if (res) {
contactus_page = "/contact-us-form-review";
}
$('form[action="/website_form/"]').attr('data-success_page',contactus_page);
var formaction_webform = 'form[action="/website_form/"]';
$(formaction_webform).attr('data-success_page', contactus_page);
});
});
});
});

2
website_contact_extend/views/disp_msg_template.xml

@ -14,4 +14,4 @@
</div>
</t>
</template>
</odoo>
</odoo>

2
website_contact_extend/views/email_template.xml

@ -63,4 +63,4 @@
</field>
</record>
</data>
</odoo>
</odoo>

2
website_contact_extend/views/website_contact.xml

@ -143,4 +143,4 @@
<!--</field>-->
<!--</record>-->
</odoo>
</odoo>
Loading…
Cancel
Save