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_private: new module #385

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_private/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_private/README.rst
Original file line number Diff line number Diff line change
@@ -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 <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_private%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 <JulianaPoudou>
* Benjamin <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_private>`_ 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_private/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import controllers
23 changes: 23 additions & 0 deletions website_event_private/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
1 change: 1 addition & 0 deletions website_event_private/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
62 changes: 62 additions & 0 deletions website_event_private/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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")

Check warning on line 17 in website_event_private/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_private/controllers/main.py#L17

Added line #L17 was not covered by tests

return super(WebsiteEvent, self).event_page(event, page, **post)

Check warning on line 19 in website_event_private/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_private/controllers/main.py#L19

Added line #L19 was not covered by tests

@http.route()
def event(self, event, **post):
if not self._check_privacy(event, **post):
return request.redirect("/event")

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

View check run for this annotation

Codecov / codecov/patch

website_event_private/controllers/main.py#L24

Added line #L24 was not covered by tests

return super(WebsiteEvent, self).event(event, **post)

Check warning on line 26 in website_event_private/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_private/controllers/main.py#L26

Added line #L26 was not covered by tests

@http.route()
def event_register(self, event, **post):
if not self._check_privacy(event, **post):
return request.redirect("/event")

Check warning on line 31 in website_event_private/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_private/controllers/main.py#L31

Added line #L31 was not covered by tests

return super(WebsiteEvent, self).event_register(event, **post)

Check warning on line 33 in website_event_private/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_private/controllers/main.py#L33

Added line #L33 was not covered by tests

# ------------------------------------------------------
# Business method
# ------------------------------------------------------
def _check_privacy(self, event, **post):
if event.event_privacy != "public" and not request.env.user.has_group(
"website.group_website_restricted_editor"
):
cookie = request.httprequest.cookies.get("odoo-event-%d" % event.id)

Check warning on line 42 in website_event_private/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_private/controllers/main.py#L42

Added line #L42 was not covered by tests
if (
post
and post.get("access_token")
and post.get("access_token") == event.access_token
):
access_token = post.get("access_token")
request.future_response.set_cookie(

Check warning on line 49 in website_event_private/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_private/controllers/main.py#L48-L49

Added lines #L48 - L49 were not covered by tests
key="odoo-event-%d" % event.id,
value=access_token,
max_age=10 * 86400,
secure=True,
httponly=True,
samesite="Strict",
)
return True

Check warning on line 57 in website_event_private/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_private/controllers/main.py#L57

Added line #L57 was not covered by tests
elif cookie and cookie == event.access_token:
return True

Check warning on line 59 in website_event_private/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_private/controllers/main.py#L59

Added line #L59 was not covered by tests
else:
return False
return True

Check warning on line 62 in website_event_private/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

website_event_private/controllers/main.py#L61-L62

Added lines #L61 - L62 were not covered by tests
65 changes: 65 additions & 0 deletions website_event_private/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -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 "<i class=\"fa fa-user-secret me-2\"/>Private"
msgstr "<i class=\"fa fa-user-secret me-2\"/>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é"
65 changes: 65 additions & 0 deletions website_event_private/i18n/website_event_private.pot
Original file line number Diff line number Diff line change
@@ -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 "<i class=\"fa fa-user-secret me-2\"/>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 ""
2 changes: 2 additions & 0 deletions website_event_private/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import event_type
from . import event_event
Loading
Loading