Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] kicker: signup flow #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kicker/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
16 changes: 14 additions & 2 deletions kicker/controllers/kicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -183,4 +185,14 @@ def web_login(self, redirect=None, *args, **kw):
else:
redirect = '/app'
return http.redirect_with_hash(redirect)
return response
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 <trigram>@odoo.com"))

return super().do_signup(qcontext)
11 changes: 11 additions & 0 deletions kicker/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from odoo import models, fields, api, _
from odoo.exceptions import UserError

import datetime
from dateutil import relativedelta
Expand Down Expand Up @@ -155,3 +156,13 @@ def _get_rankings(self, period='month', metric='all'):
'matches': wins + losses,
})
return res

def write(self, vals):
if 'kicker_player' in vals:
if not self.user_has_groups('kicker.group_kicker_manager'):
raise UserError(_("Only kicker managers can modify a player status"))
if vals['kicker_player']:
# erase email address upon validation
vals['email'] = False

return super().write(vals)
10 changes: 10 additions & 0 deletions kicker/views/kicker_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ Login Restyling
</xpath>
</template>

<template id="signup_kicker" name="Signup" inherit_id="auth_signup.fields">
<xpath expr="//label[@for='login']" position="replace">
<label for="login">Your @odoo.com Email</label>
</xpath>

<xpath expr="//label[@for='name']" position="replace">
<label for="name">Your Player Name (login)</label>
</xpath>
</template>

<!-- Reveal password field (button to see the password). The only param is name (the nname attribute of the field)-->
<template id="password_field_reveal" name="Password Field Reveal (can show and hide the password)">
<div class="odoo-password-reveal input-group">
Expand Down
50 changes: 50 additions & 0 deletions kicker/views/kicker_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,34 @@
</field>
</record>

<record id="view_kicker_players_validate_tree" model="ir.ui.view">
<field name="name">res.partner.validate.tree</field>
<field name="model">res.partner</field>
<field name="priority">100</field>
<field name="arch" type="xml">
<tree string="Players">
<field name="name"/>
<field name="email"/>
<field name="create_date"/>
<field name="kicker_player" widget="boolean_toggle" />
</tree>
</field>
</record>

<record model="ir.ui.view" id="view_partners_search_inherit_kicker">
<field name="name">res.partner.search.inherit.kicker</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_res_partner_filter"/>
<field name="arch" type="xml">
<search position="inside">
<filter string="Players To Validate"
name="players_to_activate"
domain="[('kicker_player', '=', False)]"/>
</search>
</field>
</record>


<!--
Actions
-->
Expand Down Expand Up @@ -197,6 +225,19 @@
<field name="context">{'default_kicker_player': True}</field>
</record>

<record id="kicker_player_action_to_validate_list" model="ir.actions.act_window">
<field name="name">Players to Validate</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.partner</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('view_kicker_players_validate_tree')}),
]"/>
<field name="domain">['|', ('email', '=like', '%@odoo.com'), ('kicker_player', '=', True)]</field>
<field name="context">{'search_default_players_to_activate': 1}</field>
</record>

<!--
Menus
-->
Expand Down Expand Up @@ -242,4 +283,13 @@
parent="kicker_menu_root"
action="kicker_player_action_list"
sequence="25"/>

<menuitem
id="kicker_menu_partner_list_validate"
name="Players to Validate"
parent="kicker_menu_root"
action="kicker_player_action_to_validate_list"
groups="kicker.group_kicker_manager"
sequence="30"/>

</odoo>