Browse Source

[FIX] emc: One route to rule them all

It's a problem to use one route for the form and one route for the
submission of the form. When user is not logged and he tries to submit
with an existing email, a error tell him to sign in before submitting.
To login in there is a button that let him sign in. But after loggin in,
he comes back to the post url of the form and this url doesn't perform
checks that are performed when arriving on the form for the first time.
9.0-medor-hide_bank_and_birthdate
Rémy Taymans 5 years ago
parent
commit
e053dff6d2
  1. 7
      easy_my_coop/controllers/main.py
  2. 6
      easy_my_coop/view/subscription_template.xml

7
easy_my_coop/controllers/main.py

@ -32,6 +32,8 @@ class WebsiteSubscription(http.Controller):
'/become_cooperator'],
type='http', auth="public", website=True)
def display_become_cooperator_page(self, **kwargs):
if request.httprequest.method == "POST":
return self.share_subscription(**kwargs)
values = {}
logged = False
if request.env.user.login != 'public':
@ -52,6 +54,8 @@ class WebsiteSubscription(http.Controller):
'/become_company_cooperator'],
type='http', auth="public", website=True)
def display_become_company_cooperator_page(self, **kwargs):
if request.httprequest.method == "POST":
return self.share_subscription(**kwargs)
values = {}
logged = False
@ -327,9 +331,6 @@ class WebsiteSubscription(http.Controller):
}
}
@http.route(['/subscription/subscribe_share'],
type='http',
auth="public", website=True)
def share_subscription(self, **kwargs):
sub_req_obj = request.env['subscription.request']
attach_obj = request.env['ir.attachment']

6
easy_my_coop/view/subscription_template.xml

@ -54,7 +54,7 @@
<h2 class="energie">Become Cooperator</h2><br/>
<div class="row">
<div class="col-md-8">
<form action="/subscription/subscribe_share" method="post" class="form-horizontal mt32" enctype="multipart/form-data">
<form method="post" class="form-horizontal mt32" enctype="multipart/form-data">
<p style="color:red;"><t t-esc="error_msg"/></p>
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
@ -90,7 +90,7 @@
<label class="col-md-3 col-sm-4 control-label" for="confirm_email">Confirm Email</label>
<div class="col-md-7 col-sm-8 bottom-line" style="padding-bottom:20px">
<input type="confirm_email" class="form-control mandatory-field" name="confirm_email"
t-att-required="not logged" t-att-readonly="logged"
required="required" t-att-readonly="logged"
t-attf-value="#{confirm_email or ''}" placeholder="didier.bourdon@bees-coop.be"/>
</div>
</div>
@ -341,7 +341,7 @@
<h2 class="energie">Become Cooperator</h2><br/>
<div class="row">
<div class="col-md-8">
<form action="/subscription/subscribe_share" method="post" class="form-horizontal mt32" enctype="multipart/form-data">
<form method="post" class="form-horizontal mt32" enctype="multipart/form-data">
<p style="color:red;"><t t-esc="error_msg"/></p>
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>

Loading…
Cancel
Save