diff --git a/__init__.py b/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e046e49fbe22a4768c49bca1ed4cc0b0487c66c3 100644 --- a/__init__.py +++ b/__init__.py @@ -0,0 +1 @@ +from . import controllers diff --git a/__manifest__.py b/__manifest__.py index 43f9804b9165079087c9941e4652439f55d9db47..03b8cb514e9038450ba5c769ce2d954fbd326202 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -13,9 +13,7 @@ "assets": { "web._assets_primary_variables": [], "web._assets_frontend_helpers": [], - 'web.assets_frontend': [ - 'solagro_auth_signup/static/**/*', - ], + "web.assets_frontend": [], "web.assets_tests": [], "web.assets_qweb": [], }, diff --git a/controllers/__init__.py b/controllers/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..12a7e529b674164f0ad189b131c5d5c8fb9ae0bc --- /dev/null +++ b/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/controllers/main.py b/controllers/main.py new file mode 100644 index 0000000000000000000000000000000000000000..9a8c5aba79f44e189c74ecf7f1f9a4700cae4ba1 --- /dev/null +++ b/controllers/main.py @@ -0,0 +1,22 @@ +from odoo import http, tools, _ +from odoo.addons.auth_signup.controllers.main import AuthSignupHome + + +class SolagroAuthSignupHome(AuthSignupHome): + @http.route('/web/signup', type='http', auth='public', website=True, sitemap=False) + def web_auth_signup(self, **post): + # email validation + if post and http.request.httprequest.method == 'POST': + email = post.get('email') + if email and not tools.single_email_re.match(email): + post.update({'error': _('Invalid Email! Please enter a valid email address.'), 'error_email': True}) + else: + post["login"] = email + # name from firstname / lastname + if post and http.request.httprequest.method == 'POST': + firstname = post.get('firstname') + lastname = post.get('lastname') + post["name"] = firstname + " " + lastname + # update request params + http.request.params.update(post) + return super().web_auth_signup() diff --git a/static/src/js/signup.js b/static/src/js/signup.js deleted file mode 100644 index 1928ef9308719f0c3d3ccc8a906a18a70d81ef27..0000000000000000000000000000000000000000 --- a/static/src/js/signup.js +++ /dev/null @@ -1,30 +0,0 @@ -/** @odoo-module */ - -import "web.dom_ready"; - -console.log("ready") - -// il semble que web.signup n'a pas été porté en OWL, donc j'utilise l'ancienne forme - -const signupForm = document.querySelector('.oe_signup_form'); -if (signupForm) { - const name = document.querySelector("input[name='name']"); - const firstname = document.querySelector("input[name='firstname']"); - const lastname = document.querySelector("input[name='lastname']"); - - let firstname_val = "" - let lastname_val = "" - - firstname.addEventListener("input", (e) => { - firstname_val = e.target.value - update_name() - }); - lastname.addEventListener("input", (e) => { - lastname_val = e.target.value - update_name() - }); - - function update_name() { - name.value = firstname_val + " " + lastname_val - } -} diff --git a/views/auth_signup_login_templates.xml b/views/auth_signup_login_templates.xml index 92ce8451797d53f55f3e41ade7fa97d21fdb7b31..c29b9868005e1fe96e8af6f2d6234c834cffb6ed 100644 --- a/views/auth_signup_login_templates.xml +++ b/views/auth_signup_login_templates.xml @@ -3,21 +3,29 @@ License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> <odoo> - <template id="auth_signup_fields_inherit" inherit_id="auth_signup.fields"> - <!-- replaces name by firstname / lastname --> - <xpath expr="//div[@class='mb-3 field-name']/input" position="attributes"> - <attribute name="required">False</attribute> - <attribute name="t-att-readonly">True</attribute> + <!-- email field --> + <!-- div with correct error class --> + <xpath expr="//input[@id='login']/.." position="attributes"> + <attribute name="t-attf-class">mb-3 {{'o_has_error' if error_email else ''}}</attribute> </xpath> + <!-- input with correct type and error class--> + <xpath expr="//input[@id='login']" position="attributes"> + <attribute name="type">email</attribute> + <attribute name="name">email</attribute> + <attribute name="t-attf-class">form-control {{'is-invalid' if error_email else ''}}</attribute> + </xpath> + - <xpath expr="//div[@class='mb-3 field-name']" position="after"> + <!-- replaces name by firstname / lastname --> + <xpath expr="//input[@name='name']/.." position="replace"> <div class="mb-3 field-firstname"> <label for="name">Prénom</label> <input type="text" name="firstname" t-att-value="firstname" id="firstname" class="form-control form-control-sm" placeholder="par ex. Julie" - required="required" t-att-readonly="'readonly' if only_passwords else None"/> + required="required" t-att-readonly="'readonly' if only_passwords else None" + /> </div> <div class="mb-3 field-lastname"> <label for="name">Nom</label> @@ -28,5 +36,4 @@ </xpath> </template> - </odoo>