Skip to content

Commit eb885f9

Browse files
committed
[FIX] website_event_require_login: patch EventRegistrationForm onClick
- add data require-login into form registration - remove registration flow modal when detect registration require from Javascript - add contributor TechnoLibre
1 parent e018f40 commit eb885f9

4 files changed

Lines changed: 63 additions & 2 deletions

File tree

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
# Copyright 2019 Tecnativa - David Vidal
2+
# Copyright 2026 TechnoLibre - Mathieu Benoit
23
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
34
{
45
"name": "Website Event Require Login",
56
"version": "18.0.1.0.0",
6-
"author": "Tecnativa, " "Odoo Community Association (OCA)",
7+
"author": "Tecnativa, " "Odoo Community Association (OCA), " "TechnoLibre",
78
"website": "https://github.com/OCA/event",
89
"category": "Event",
910
"depends": ["website_event"],
1011
"data": ["views/event_views.xml", "views/website_event_templates.xml"],
12+
"assets": {
13+
"web.assets_frontend": [
14+
"website_event_require_login/static/src/js/registration_login_required.js",
15+
],
16+
},
1117
"installable": True,
1218
"license": "AGPL-3",
1319
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
- [Tecnativa](https://www.tecnativa.com):
22
- David Vidal
33
- Rafael Blasco
4-
- [Sygel](https://www.https://sygel.es/):
4+
- [Sygel](https://www.sygel.es/):
55
- Manuel Regidor
6+
- [TechnoLibre](https://technolibre.ca):
7+
- Mathieu Benoit
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/** @odoo-module **/
2+
3+
import {patch} from "@web/core/utils/patch";
4+
import {rpc} from "@web/core/network/rpc";
5+
import EventRegistrationForm from "@website_event/js/website_event";
6+
7+
patch(EventRegistrationForm.prototype, {
8+
async _onClick(ev) {
9+
const formEl = ev.currentTarget.closest("form");
10+
11+
if (formEl.dataset.requireLogin !== "1") {
12+
// Standard registration flow
13+
return super._onClick(ev);
14+
}
15+
16+
// Login required: support custom modal
17+
ev.preventDefault();
18+
ev.stopPropagation();
19+
const buttonEl = ev.currentTarget.closest("[type='submit']");
20+
buttonEl.disabled = true;
21+
22+
const post = this._getPost();
23+
const modal = await rpc(formEl.action, post);
24+
const modalEl = new DOMParser().parseFromString(modal, "text/html").body.
25+
firstChild;
26+
27+
const _onClose = () => {
28+
buttonEl.disabled = false;
29+
modalEl.remove();
30+
};
31+
const closeBtn = modalEl.querySelector(".btn-close");
32+
const gotoBtn = modalEl.querySelector(".js_goto_event");
33+
if (closeBtn) closeBtn.addEventListener("click", _onClose);
34+
if (gotoBtn) gotoBtn.addEventListener("click", _onClose);
35+
36+
const formModal = Modal.getOrCreateInstance(modalEl, {
37+
backdrop: "static",
38+
keyboard: false,
39+
});
40+
formModal.show();
41+
},
42+
});

website_event_require_login/views/website_event_templates.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,15 @@
3939
</div>
4040
</div>
4141
</template>
42+
43+
<template
44+
id="registration_form_require_login"
45+
inherit_id="website_event.modal_ticket_registration"
46+
>
47+
<xpath expr="//form[@id='registration_form']" position="attributes">
48+
<attribute
49+
name="t-att-data-require-login"
50+
>1 if event.website_require_login and request.env.user == request.website.user_id else 0</attribute>
51+
</xpath>
52+
</template>
4253
</odoo>

0 commit comments

Comments
 (0)