Browse Source

[PEP8] fix pep8

pull/1/head
houssine 6 years ago
parent
commit
c28bddb6b8
  1. 26
      easy_my_coop/controllers/main.py

26
easy_my_coop/controllers/main.py

@ -240,7 +240,6 @@ class WebsiteSubscription(http.Controller):
return request.website.render(redirect, values) return request.website.render(redirect, values)
# Check that required field from model subscription_request exists
company = request.website.company_id company = request.website.company_id
if company.allow_id_card_upload: if company.allow_id_card_upload:
if not post_file: if not post_file:
@ -250,12 +249,16 @@ class WebsiteSubscription(http.Controller):
" scan of your id card") " scan of your id card")
return request.website.render(redirect, values) return request.website.render(redirect, values)
required_fields = request.env['subscription.request'].sudo().get_required_field()
error = set(field for field in required_fields if not values.get(field))
sub_req_obj = request.env['subscription.request']
# Check that required field from model subscription_request exists
required_fields = sub_req_obj.sudo().get_required_field()
error = set(field for field in required_fields if not values.get(field)) #noqa
if error: if error:
values = self.fill_values(values, is_company) values = self.fill_values(values, is_company)
values["error_msg"] = _("Some mandatory fields have not been filled")
values["error_msg"] = _("Some mandatory fields have not "
"been filled")
values = dict(values, error=error, kwargs=kwargs.items()) values = dict(values, error=error, kwargs=kwargs.items())
return request.website.render(kwargs.get("view_from", redirect), values) return request.website.render(kwargs.get("view_from", redirect), values)
@ -268,7 +271,8 @@ class WebsiteSubscription(http.Controller):
values["name"] = firstname + " " + lastname values["name"] = firstname + " " + lastname
values["lastname"] = lastname values["lastname"] = lastname
values["firstname"] = firstname values["firstname"] = firstname
values["birthdate"] = datetime.strptime(kwargs.get("birthdate"), "%d/%m/%Y").date()
values["birthdate"] = datetime.strptime(kwargs.get("birthdate"),
"%d/%m/%Y").date()
values["source"] = "website" values["source"] = "website"
if kwargs.get("share_product_id"): if kwargs.get("share_product_id"):
@ -287,12 +291,16 @@ class WebsiteSubscription(http.Controller):
if is_company: if is_company:
if kwargs.get("company_register_number", is_company): if kwargs.get("company_register_number", is_company):
values["company_register_number"] = re.sub('[^0-9a-zA-Z]+', '', kwargs.get("company_register_number"))
subscription_id = request.env['subscription.request'].sudo().create_comp_sub_req(values)
values["company_register_number"] = re.sub('[^0-9a-zA-Z]+',
'',
kwargs.get("company_register_number"))
subscription_id = sub_req_obj.sudo().create_comp_sub_req(values)
else: else:
if kwargs.get("no_registre"): if kwargs.get("no_registre"):
values["no_registre"] = re.sub('[^0-9a-zA-Z]+', '', kwargs.get("no_registre"))
subscription_id = request.env['subscription.request'].sudo().create(values)
values["no_registre"] = re.sub('[^0-9a-zA-Z]+',
'',
kwargs.get("no_registre"))
subscription_id = sub_req_obj.sudo().create(values)
values.update(subscription_id=subscription_id) values.update(subscription_id=subscription_id)

Loading…
Cancel
Save