Skip to content

Commit 72550e5

Browse files
benj-filamentremi-filament
authored andcommitted
[ADD] website_event_mail_unique: new module
1 parent 7b13259 commit 72550e5

File tree

16 files changed

+664
-0
lines changed

16 files changed

+664
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../website_event_email_unique
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

website_event_email_unique/README.rst

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
==========================
2+
Website Event Email Unique
3+
==========================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:5598a26ff3b78af7f4eda6c1a0342d23cc143c3fe79157c3045470109ef86ce8
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github
20+
:target: https://github.com/OCA/event/tree/16.0/website_event_email_unique
21+
:alt: OCA/event
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/event-16-0/event-16-0-website_event_email_unique
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/event&target_branch=16.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
This module will check whether an attendee already registered with the same e-mail address.
32+
If this is the case, then depending on configuration, the new registration will either:
33+
#. Replace the previous one
34+
#. Be ignored
35+
36+
This module is quite similar in implemented function to event_registration_partner_unique,
37+
except that you do not have to get a partner for each attendee, you only make check on e-mail.
38+
Also there is no dependency to partner_event module since it is not needed here.
39+
40+
**Table of contents**
41+
42+
.. contents::
43+
:local:
44+
45+
Configuration
46+
=============
47+
48+
On event record (on the backend), select "Unique registration email" field if you
49+
want to enforce unique emails among registrations.
50+
51+
Once selected, new field "Duplicated email registration behaviour" will appear where
52+
you have to select the expected behavior if an attendee registers with an e-mail
53+
already registered:
54+
#. Delete and recreate registration: will remove previous registration and create a new one
55+
#. Ignore new registration: will silently discard new registration (and keep the previous one)
56+
57+
Bug Tracker
58+
===========
59+
60+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/event/issues>`_.
61+
In case of trouble, please check there if your issue has already been reported.
62+
If you spotted it first, help us to smash it by providing a detailed and welcomed
63+
`feedback <https://github.com/OCA/event/issues/new?body=module:%20website_event_email_unique%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
64+
65+
Do not contact contributors directly about support or help with technical issues.
66+
67+
Credits
68+
=======
69+
70+
Authors
71+
~~~~~~~
72+
73+
* Le Filament
74+
75+
Contributors
76+
~~~~~~~~~~~~
77+
78+
* Juliana Poudou <JulianaPoudou>
79+
* Benjamin Rivier <benj-filament>
80+
81+
Other credits
82+
~~~~~~~~~~~~~
83+
84+
* Le Filament <https://www.le-filament.com>
85+
86+
Maintainers
87+
~~~~~~~~~~~
88+
89+
This module is maintained by the OCA.
90+
91+
.. image:: https://odoo-community.org/logo.png
92+
:alt: Odoo Community Association
93+
:target: https://odoo-community.org
94+
95+
OCA, or the Odoo Community Association, is a nonprofit organization whose
96+
mission is to support the collaborative development of Odoo features and
97+
promote its widespread use.
98+
99+
This module is part of the `OCA/event <https://github.com/OCA/event/tree/16.0/website_event_email_unique>`_ project on GitHub.
100+
101+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import models
2+
from . import controllers
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "Website Event Email Unique",
3+
"version": "16.0.1.0.0",
4+
"author": "Le Filament,Odoo Community Association (OCA)",
5+
"license": "AGPL-3",
6+
"website": "https://github.com/OCA/event",
7+
"application": False,
8+
"category": "Marketing",
9+
"depends": ["website_event"],
10+
"data": [
11+
"views/event_views.xml",
12+
],
13+
"installable": True,
14+
"auto_install": False,
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import main
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2023 Le Filament (https://le-filament.com)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
3+
4+
from odoo.addons.website_event.controllers.main import WebsiteEventController
5+
6+
7+
class WebsiteEvent(WebsiteEventController):
8+
def _create_attendees_from_registration_post(self, event, registration_data):
9+
""" """
10+
if event.unique_attendee_email:
11+
existing_registration_ids = event.sudo().registration_ids.filtered(
12+
lambda r: r.email in [data.get("email") for data in registration_data]
13+
)
14+
if event.email_duplication_behaviour == "update":
15+
existing_registration_ids.unlink()
16+
return super()._create_attendees_from_registration_post(
17+
event, registration_data
18+
)
19+
else:
20+
attendee_emails = event.sudo().registration_ids.mapped("email")
21+
for data in registration_data:
22+
if data.get("email") in attendee_emails:
23+
registration_data.remove(data)
24+
created_attendee_ids = super()._create_attendees_from_registration_post(
25+
event, registration_data
26+
)
27+
return created_attendee_ids + existing_registration_ids
28+
else:
29+
return super()._create_attendees_from_registration_post(
30+
event, registration_data
31+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import event_event
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2023 Le Filament (https://le-filament.com)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
3+
4+
from odoo import fields, models
5+
6+
7+
class Event(models.Model):
8+
_inherit = "event.event"
9+
10+
unique_attendee_email = fields.Boolean(
11+
string="Unique registration email", default=False
12+
)
13+
email_duplication_behaviour = fields.Selection(
14+
selection=[
15+
("update", "Delete and recreate registration"),
16+
("ignore", "Ignore new registration"),
17+
],
18+
string="Duplicated email registration behaviour",
19+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
On event record (on the backend), select "Unique registration email" field if you
2+
want to enforce unique emails among registrations.
3+
4+
Once selected, new field "Duplicated email registration behaviour" will appear where
5+
you have to select the expected behavior if an attendee registers with an e-mail
6+
already registered:
7+
#. Delete and recreate registration: will remove previous registration and create a new one
8+
#. Ignore new registration: will silently discard new registration (and keep the previous one)

0 commit comments

Comments
 (0)