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

[16.0][ADD] website_event_mail_unique: new module #389

Open
wants to merge 1 commit into
base: 16.0
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
6 changes: 6 additions & 0 deletions setup/website_event_email_unique/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
101 changes: 101 additions & 0 deletions website_event_email_unique/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
==========================
Website Event Email Unique
==========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5598a26ff3b78af7f4eda6c1a0342d23cc143c3fe79157c3045470109ef86ce8
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fevent-lightgray.png?logo=github
:target: https://github.com/OCA/event/tree/16.0/website_event_email_unique
:alt: OCA/event
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/event-16-0/event-16-0-website_event_email_unique
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/event&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module will check whether an attendee already registered with the same e-mail address.
If this is the case, then depending on configuration, the new registration will either:
#. Replace the previous one
#. Be ignored

This module is quite similar in implemented function to event_registration_partner_unique,
except that you do not have to get a partner for each attendee, you only make check on e-mail.
Also there is no dependency to partner_event module since it is not needed here.

**Table of contents**

.. contents::
:local:

Configuration
=============

On event record (on the backend), select "Unique registration email" field if you
want to enforce unique emails among registrations.

Once selected, new field "Duplicated email registration behaviour" will appear where
you have to select the expected behavior if an attendee registers with an e-mail
already registered:
#. Delete and recreate registration: will remove previous registration and create a new one
#. Ignore new registration: will silently discard new registration (and keep the previous one)

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/event/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`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**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Le Filament

Contributors
~~~~~~~~~~~~

* Juliana Poudou <JulianaPoudou>
* Benjamin Rivier <benj-filament>

Other credits
~~~~~~~~~~~~~

* Le Filament <https://www.le-filament.com>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/event <https://github.com/OCA/event/tree/16.0/website_event_email_unique>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions website_event_email_unique/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import controllers
15 changes: 15 additions & 0 deletions website_event_email_unique/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Website Event Email Unique",
"version": "16.0.1.0.0",
"author": "Le Filament,Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/event",
"application": False,
"category": "Marketing",
"depends": ["website_event"],
"data": [
"views/event_views.xml",
],
"installable": True,
"auto_install": False,
}
1 change: 1 addition & 0 deletions website_event_email_unique/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
31 changes: 31 additions & 0 deletions website_event_email_unique/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2023 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo.addons.website_event.controllers.main import WebsiteEventController


class WebsiteEvent(WebsiteEventController):
def _create_attendees_from_registration_post(self, event, registration_data):
""" """
if event.unique_attendee_email:
existing_registration_ids = event.sudo().registration_ids.filtered(
lambda r: r.email in [data.get("email") for data in registration_data]
)
if event.email_duplication_behaviour == "update":
existing_registration_ids.unlink()
return super()._create_attendees_from_registration_post(

Check warning on line 16 in website_event_email_unique/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_email_unique/controllers/main.py#L15-L16

Added lines #L15 - L16 were not covered by tests
event, registration_data
)
else:
attendee_emails = event.sudo().registration_ids.mapped("email")

Check warning on line 20 in website_event_email_unique/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_email_unique/controllers/main.py#L20

Added line #L20 was not covered by tests
for data in registration_data:
if data.get("email") in attendee_emails:
registration_data.remove(data)
created_attendee_ids = super()._create_attendees_from_registration_post(

Check warning on line 24 in website_event_email_unique/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_email_unique/controllers/main.py#L23-L24

Added lines #L23 - L24 were not covered by tests
event, registration_data
)
return created_attendee_ids + existing_registration_ids

Check warning on line 27 in website_event_email_unique/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_email_unique/controllers/main.py#L27

Added line #L27 was not covered by tests
else:
return super()._create_attendees_from_registration_post(

Check warning on line 29 in website_event_email_unique/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_email_unique/controllers/main.py#L29

Added line #L29 was not covered by tests
event, registration_data
)
1 change: 1 addition & 0 deletions website_event_email_unique/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import event_event
19 changes: 19 additions & 0 deletions website_event_email_unique/models/event_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2023 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import fields, models


class Event(models.Model):
_inherit = "event.event"

unique_attendee_email = fields.Boolean(
string="Unique registration email", default=False
)
email_duplication_behaviour = fields.Selection(
selection=[
("update", "Delete and recreate registration"),
("ignore", "Ignore new registration"),
],
string="Duplicated email registration behaviour",
)
8 changes: 8 additions & 0 deletions website_event_email_unique/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
On event record (on the backend), select "Unique registration email" field if you
want to enforce unique emails among registrations.

Once selected, new field "Duplicated email registration behaviour" will appear where
you have to select the expected behavior if an attendee registers with an e-mail
already registered:
#. Delete and recreate registration: will remove previous registration and create a new one
#. Ignore new registration: will silently discard new registration (and keep the previous one)
2 changes: 2 additions & 0 deletions website_event_email_unique/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Juliana Poudou <JulianaPoudou>
* Benjamin Rivier <benj-filament>
1 change: 1 addition & 0 deletions website_event_email_unique/readme/CREDITS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Le Filament <https://www.le-filament.com>
8 changes: 8 additions & 0 deletions website_event_email_unique/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This module will check whether an attendee already registered with the same e-mail address.
If this is the case, then depending on configuration, the new registration will either:
#. Replace the previous one
#. Be ignored

This module is quite similar in implemented function to event_registration_partner_unique,
except that you do not have to get a partner for each attendee, you only make check on e-mail.
Also there is no dependency to partner_event module since it is not needed here.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading