diff --git a/setup/website_event_private/odoo/addons/website_event_private b/setup/website_event_private/odoo/addons/website_event_private new file mode 120000 index 000000000..89df32fb9 --- /dev/null +++ b/setup/website_event_private/odoo/addons/website_event_private @@ -0,0 +1 @@ +../../../../website_event_private \ No newline at end of file diff --git a/setup/website_event_private/setup.py b/setup/website_event_private/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/website_event_private/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/website_event_private/README.rst b/website_event_private/README.rst new file mode 100644 index 000000000..eb0b8337a --- /dev/null +++ b/website_event_private/README.rst @@ -0,0 +1,101 @@ +===================== +Website Event Private +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:e2fa0df647bdf86e9ad2ca5b9877819b436963e805bc2b4de1237d0e104d109d + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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_private + :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_private + :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 allows you to configure the privacy of website events : + +* *Public*: anyone can view the event and register +* *Private displayed*: the event appears in the event list (but not clickable) and one needs access token to see content / register +* *Private hidden*: the event does not appear in the list of events and one needs access token to see content / register + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + + +To configure this module, you need to: + +#. Go to an event and set the privacy option +#. If you select private displayed or hidden, access token link will appear just after the privacy field + +Usage +===== + +On private event record, you need to share the access link which is generated +and accessible on backend event form to give access to the event. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Le Filament + +Contributors +~~~~~~~~~~~~ + +* Juliana +* Benjamin + +Other credits +~~~~~~~~~~~~~ + +* Le Filament + +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 `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/website_event_private/__init__.py b/website_event_private/__init__.py new file mode 100644 index 000000000..f7209b171 --- /dev/null +++ b/website_event_private/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import controllers diff --git a/website_event_private/__manifest__.py b/website_event_private/__manifest__.py new file mode 100644 index 000000000..e044452f8 --- /dev/null +++ b/website_event_private/__manifest__.py @@ -0,0 +1,23 @@ +{ + "name": "Website Event Private", + "summary": "Website Event Private", + "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": [ + "templates/event_templates_list.xml", + "views/event_views.xml", + "views/event_type_views.xml", + ], + "assets": { + "web.assets_frontend": [ + "website_event_private/static/src/scss/website_event_private.scss", + ], + }, + "installable": True, + "auto_install": False, +} diff --git a/website_event_private/controllers/__init__.py b/website_event_private/controllers/__init__.py new file mode 100644 index 000000000..12a7e529b --- /dev/null +++ b/website_event_private/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/website_event_private/controllers/main.py b/website_event_private/controllers/main.py new file mode 100644 index 000000000..b6cac666c --- /dev/null +++ b/website_event_private/controllers/main.py @@ -0,0 +1,66 @@ +# Copyright 2023- Le Filament (https://le-filament.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import http +from odoo.http import request + +from odoo.addons.website_event.controllers.main import WebsiteEventController + + +class WebsiteEvent(WebsiteEventController): + # ------------------------------------------------------ + # Inherit parent routes + # ------------------------------------------------------ + @http.route() + def event_page(self, event, page, **post): + if not self._check_privacy(event, **post): + return request.redirect("/event") + + return super(WebsiteEvent, self).event_page(event, page, **post) + + @http.route() + def event(self, event, **post): + if not self._check_privacy(event, **post): + return request.redirect("/event") + + return super(WebsiteEvent, self).event(event, **post) + + @http.route() + def event_register(self, event, **post): + if not self._check_privacy(event, **post): + return request.redirect("/event") + + return super(WebsiteEvent, self).event_register(event, **post) + + # ------------------------------------------------------ + # Business method + # ------------------------------------------------------ + def _check_privacy(self, event, **post): + # for private events, check authorization + if event.event_privacy != "public" and not request.env.user.has_group( + "website.group_website_restricted_editor" + ): + # get cookie from http request + cookie = request.httprequest.cookies.get("odoo-event-%d" % event.id) + # check if cookie match access token + if cookie and cookie == event.access_token: + return True + # if cookie does not match, get the cookie from url + if post and post.get("access_token"): + access_token = post.get("access_token") + # if the cookie is correct, set the cookie accordingly and succeed + if access_token == event.access_token: + request.future_response.set_cookie( + key="odoo-event-%d" % event.id, + value=access_token, + max_age=10 * 86400, + secure=True, + httponly=True, + samesite="Strict", + ) + return True + # if cookie is incorrect, do not set the cookie and fail + else: + return False + # for public event or if user is authorized, allow access + return True diff --git a/website_event_private/i18n/fr.po b/website_event_private/i18n/fr.po new file mode 100644 index 000000000..f00efe1a4 --- /dev/null +++ b/website_event_private/i18n/fr.po @@ -0,0 +1,65 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_event_private +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-08-14 13:05+0000\n" +"PO-Revision-Date: 2024-08-14 13:05+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: website_event_private +#: model_terms:ir.ui.view,arch_db:website_event_private.events_private_list +msgid "Private" +msgstr "Privé" + +#. module: website_event_private +#: model:ir.model,name:website_event_private.model_event_event +msgid "Event" +msgstr "Évènement" + +#. module: website_event_private +#: model:ir.model,name:website_event_private.model_event_type +msgid "Event Template" +msgstr "Modèle d'événement" + +#. module: website_event_private +#: model:ir.model.fields,field_description:website_event_private.field_event_event__event_share_link +msgid "Event link" +msgstr "Lien d'accès à l'évènement" + +#. module: website_event_private +#: model:ir.model.fields,field_description:website_event_private.field_event_event__event_privacy +#: model:ir.model.fields,field_description:website_event_private.field_event_type__event_privacy +msgid "Event privacy" +msgstr "Confidentialité de l'évènement" + +#. module: website_event_private +#: model:ir.model.fields.selection,name:website_event_private.selection__event_event__event_privacy__private_displayed +#: model:ir.model.fields.selection,name:website_event_private.selection__event_type__event_privacy__private_displayed +msgid "Private displayed" +msgstr "Privé mais listé" + +#. module: website_event_private +#: model:ir.model.fields.selection,name:website_event_private.selection__event_event__event_privacy__private_hidden +#: model:ir.model.fields.selection,name:website_event_private.selection__event_type__event_privacy__private_hidden +msgid "Private hidden" +msgstr "Privé et non listé" + +#. module: website_event_private +#: model:ir.model.fields.selection,name:website_event_private.selection__event_event__event_privacy__public +#: model:ir.model.fields.selection,name:website_event_private.selection__event_type__event_privacy__public +msgid "Public" +msgstr "" + +#. module: website_event_private +#: model:ir.model.fields,field_description:website_event_private.field_event_event__access_token +msgid "Security Token" +msgstr "Jeton de sécurité" diff --git a/website_event_private/i18n/website_event_private.pot b/website_event_private/i18n/website_event_private.pot new file mode 100644 index 000000000..1188e8292 --- /dev/null +++ b/website_event_private/i18n/website_event_private.pot @@ -0,0 +1,65 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * website_event_private +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-08-14 13:05+0000\n" +"PO-Revision-Date: 2024-08-14 13:05+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: website_event_private +#: model_terms:ir.ui.view,arch_db:website_event_private.events_private_list +msgid "Private" +msgstr "" + +#. module: website_event_private +#: model:ir.model,name:website_event_private.model_event_event +msgid "Event" +msgstr "" + +#. module: website_event_private +#: model:ir.model,name:website_event_private.model_event_type +msgid "Event Template" +msgstr "" + +#. module: website_event_private +#: model:ir.model.fields,field_description:website_event_private.field_event_event__event_share_link +msgid "Event link" +msgstr "" + +#. module: website_event_private +#: model:ir.model.fields,field_description:website_event_private.field_event_event__event_privacy +#: model:ir.model.fields,field_description:website_event_private.field_event_type__event_privacy +msgid "Event privacy" +msgstr "" + +#. module: website_event_private +#: model:ir.model.fields.selection,name:website_event_private.selection__event_event__event_privacy__private_displayed +#: model:ir.model.fields.selection,name:website_event_private.selection__event_type__event_privacy__private_displayed +msgid "Private displayed" +msgstr "" + +#. module: website_event_private +#: model:ir.model.fields.selection,name:website_event_private.selection__event_event__event_privacy__private_hidden +#: model:ir.model.fields.selection,name:website_event_private.selection__event_type__event_privacy__private_hidden +msgid "Private hidden" +msgstr "" + +#. module: website_event_private +#: model:ir.model.fields.selection,name:website_event_private.selection__event_event__event_privacy__public +#: model:ir.model.fields.selection,name:website_event_private.selection__event_type__event_privacy__public +msgid "Public" +msgstr "" + +#. module: website_event_private +#: model:ir.model.fields,field_description:website_event_private.field_event_event__access_token +msgid "Security Token" +msgstr "" diff --git a/website_event_private/models/__init__.py b/website_event_private/models/__init__.py new file mode 100644 index 000000000..999bca560 --- /dev/null +++ b/website_event_private/models/__init__.py @@ -0,0 +1,2 @@ +from . import event_type +from . import event_event diff --git a/website_event_private/models/event_event.py b/website_event_private/models/event_event.py new file mode 100644 index 000000000..296539f29 --- /dev/null +++ b/website_event_private/models/event_event.py @@ -0,0 +1,69 @@ +# Copyright 2023- Le Filament (https://le-filament.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +import uuid + +from odoo import api, fields, models + + +class Event(models.Model): + _inherit = "event.event" + + access_token = fields.Char( + string="Security Token", compute="_compute_access_token", store=True, copy=False + ) + event_share_link = fields.Char( + string="Event link", + compute="_compute_event_share_link", + ) + event_privacy = fields.Selection( + [ + ("public", "Public"), + ("private_displayed", "Private displayed"), + ("private_hidden", "Private hidden"), + ], + string="Event privacy", + default="public", + required=True, + readonly=False, + store=True, + compute="_compute_event_privacy", + ) + + # ------------------------------------------------------ + # Computed fields / Search Fields + # ------------------------------------------------------ + @api.depends("event_type_id") + def _compute_event_privacy(self): + for event in self: + event.event_privacy = event.event_type_id.event_privacy + + @api.depends("event_privacy") + def _compute_access_token(self): + for event in self: + if event.event_privacy != "public" and not event.access_token: + event.access_token = str(uuid.uuid4()) + + def _compute_event_share_link(self): + for event in self: + if event.id and event.access_token and event.event_privacy != "public": + event.event_share_link = ( + event.get_base_url() + + "/event/" + + str(event.id) + + "?access_token=" + + event.access_token + ) + else: + event.event_share_link = "" + + # ------------------------------------------------------ + # Inherit parent + # ------------------------------------------------------ + @api.model + def _search_get_detail(self, website, order, options): + result = super(Event, self)._search_get_detail(website, order, options) + if not self.env.user.has_group("website.group_website_restricted_editor"): + result["base_domain"].append([("event_privacy", "!=", "private_hidden")]) + + return result diff --git a/website_event_private/models/event_type.py b/website_event_private/models/event_type.py new file mode 100644 index 000000000..a38ab0d9f --- /dev/null +++ b/website_event_private/models/event_type.py @@ -0,0 +1,19 @@ +# Copyright 2023- Le Filament (https://le-filament.com) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class EventType(models.Model): + _inherit = "event.type" + + event_privacy = fields.Selection( + [ + ("public", "Public"), + ("private_displayed", "Private displayed"), + ("private_hidden", "Private hidden"), + ], + string="Event privacy", + default="public", + required=True, + ) diff --git a/website_event_private/readme/CONFIGURE.rst b/website_event_private/readme/CONFIGURE.rst new file mode 100644 index 000000000..65bc194b9 --- /dev/null +++ b/website_event_private/readme/CONFIGURE.rst @@ -0,0 +1,5 @@ + +To configure this module, you need to: + +#. Go to an event and set the privacy option +#. If you select private displayed or hidden, access token link will appear just after the privacy field diff --git a/website_event_private/readme/CONTRIBUTORS.rst b/website_event_private/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..81ad984c7 --- /dev/null +++ b/website_event_private/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Juliana +* Benjamin diff --git a/website_event_private/readme/CREDITS.rst b/website_event_private/readme/CREDITS.rst new file mode 100644 index 000000000..286b299c8 --- /dev/null +++ b/website_event_private/readme/CREDITS.rst @@ -0,0 +1 @@ +* Le Filament diff --git a/website_event_private/readme/DESCRIPTION.rst b/website_event_private/readme/DESCRIPTION.rst new file mode 100644 index 000000000..6a628506d --- /dev/null +++ b/website_event_private/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module allows you to configure the privacy of website events : + +* *Public*: anyone can view the event and register +* *Private displayed*: the event appears in the event list (but not clickable) and one needs access token to see content / register +* *Private hidden*: the event does not appear in the list of events and one needs access token to see content / register diff --git a/website_event_private/readme/USAGE.rst b/website_event_private/readme/USAGE.rst new file mode 100644 index 000000000..efe9d228b --- /dev/null +++ b/website_event_private/readme/USAGE.rst @@ -0,0 +1,2 @@ +On private event record, you need to share the access link which is generated +and accessible on backend event form to give access to the event. diff --git a/website_event_private/static/description/icon.png b/website_event_private/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/website_event_private/static/description/icon.png differ diff --git a/website_event_private/static/description/index.html b/website_event_private/static/description/index.html new file mode 100644 index 000000000..1e300181b --- /dev/null +++ b/website_event_private/static/description/index.html @@ -0,0 +1,451 @@ + + + + + +Website Event Private + + + +
+

Website Event Private

+ + +

Beta License: AGPL-3 OCA/event Translate me on Weblate Try me on Runboat

+

This module allows you to configure the privacy of website events :

+
    +
  • Public: anyone can view the event and register
  • +
  • Private displayed: the event appears in the event list (but not clickable) and one needs access token to see content / register
  • +
  • Private hidden: the event does not appear in the list of events and one needs access token to see content / register
  • +
+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Go to an event and set the privacy option
  2. +
  3. If you select private displayed or hidden, access token link will appear just after the privacy field
  4. +
+
+
+

Usage

+

On private event record, you need to share the access link which is generated +and accessible on backend event form to give access to the event.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Le Filament
  • +
+
+
+

Contributors

+
    +
  • Juliana <JulianaPoudou>
  • +
  • Benjamin <benj-filament>
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/website_event_private/static/src/scss/website_event_private.scss b/website_event_private/static/src/scss/website_event_private.scss new file mode 100644 index 000000000..0af5c9963 --- /dev/null +++ b/website_event_private/static/src/scss/website_event_private.scss @@ -0,0 +1,14 @@ +// Index +.o_wevent_index { + // Events List + .o_wevent_events_list { + .o_wevent_private { + position: absolute; + top: 0; + width: 100%; + padding: 0px $card-spacer-x; + text-align: left; + opacity: 0.8; + } + } +} diff --git a/website_event_private/templates/event_templates_list.xml b/website_event_private/templates/event_templates_list.xml new file mode 100644 index 000000000..ad7cd7bf2 --- /dev/null +++ b/website_event_private/templates/event_templates_list.xml @@ -0,0 +1,21 @@ + + + + + + diff --git a/website_event_private/views/event_type_views.xml b/website_event_private/views/event_type_views.xml new file mode 100644 index 000000000..fe96ad2f6 --- /dev/null +++ b/website_event_private/views/event_type_views.xml @@ -0,0 +1,16 @@ + + + + + event.type.form.inherit + event.type + + + + + + + + + diff --git a/website_event_private/views/event_views.xml b/website_event_private/views/event_views.xml new file mode 100644 index 000000000..2596013eb --- /dev/null +++ b/website_event_private/views/event_views.xml @@ -0,0 +1,22 @@ + + + + + event.event.view.form.inherit.website.private + event.event + + + + + + + + + +