-
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] website_event_private: new module
- Loading branch information
1 parent
7b13259
commit 626f47d
Showing
21 changed files
with
825 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../website_event_private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import controllers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
|
||
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): | ||
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) | ||
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( | ||
key="odoo-event-%d" % event.id, | ||
value=access_token, | ||
max_age=10 * 86400, | ||
secure=True, | ||
httponly=True, | ||
samesite="Strict", | ||
) | ||
return True | ||
elif cookie and cookie == event.access_token: | ||
return True | ||
else: | ||
return False | ||
return True | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import event_type | ||
from . import event_event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 (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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* Juliana <JulianaPoudou> | ||
* Benjamin <benj-filament> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Le Filament <https://www.le-filament.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.