From 0f2ed400b7a104b482162dcb07da329dd8a22f9f Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 15 Mar 2019 20:24:19 +0100 Subject: [PATCH] [ADD] kicker: signup flow Force users to have an @odoo.com email address and a trigram Add a screen with list of players to validate --- kicker/__manifest__.py | 2 +- kicker/controllers/kicker.py | 16 ++++++++-- kicker/views/kicker_templates.xml | 10 +++++++ kicker/views/kicker_views.xml | 50 +++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 3 deletions(-) diff --git a/kicker/__manifest__.py b/kicker/__manifest__.py index 9d473a8..6b85d39 100644 --- a/kicker/__manifest__.py +++ b/kicker/__manifest__.py @@ -6,7 +6,7 @@ 'sequence': 6, 'summary': 'Kicker in the Lunch Room', 'website': 'https://kicker.odoo.com', - 'depends': ['http_routing', 'bus', 'web_editor'], + 'depends': ['http_routing', 'bus', 'web_editor', 'auth_signup'], 'data': [ 'security/kicker_security.xml', 'security/ir.model.access.csv', diff --git a/kicker/controllers/kicker.py b/kicker/controllers/kicker.py index 2d3ff46..8f4541c 100644 --- a/kicker/controllers/kicker.py +++ b/kicker/controllers/kicker.py @@ -3,16 +3,18 @@ import jinja2 import logging import random +import re import datetime from functools import reduce import werkzeug from odoo import SUPERUSER_ID -from odoo import api, http +from odoo import api, http, _ from odoo.exceptions import UserError from odoo.http import request from odoo.modules import get_module_resource from odoo.addons.web.controllers.main import binary_content, Home +from odoo.addons.auth_signup.controllers.main import AuthSignupHome _logger = logging.getLogger(__name__) @@ -183,4 +185,14 @@ def web_login(self, redirect=None, *args, **kw): else: redirect = '/app' return http.redirect_with_hash(redirect) - return response \ No newline at end of file + return response + +class KickerSignupController(AuthSignupHome): + + def do_signup(self, qcontext): + email = qcontext.get('login') + if email: + if not re.match(r"^\w{3}@odoo.com$", email): + raise UserError(_("Please use an email in the format @odoo.com")) + + return super().do_signup(qcontext) diff --git a/kicker/views/kicker_templates.xml b/kicker/views/kicker_templates.xml index 574a705..ec2ff92 100644 --- a/kicker/views/kicker_templates.xml +++ b/kicker/views/kicker_templates.xml @@ -82,6 +82,16 @@ Login Restyling + +