From 476ba60318b2ff552fd7228a03b3fc3d2f20691b Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Thu, 22 Feb 2024 11:08:05 +0500 Subject: [PATCH 1/9] =?UTF-8?q?[ADD]=20tc=5Fevent=5Fguest:=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D1=83=D0=BB=D1=8C=20=D0=B4=D0=BB=D1=8F=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B8=D0=B5=D0=BD=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tg_event_guest/README.rst | 22 +++++ tg_event_guest/__init__.py | 3 + tg_event_guest/__manifest__.py | 19 ++++ tg_event_guest/controllers/__init__.py | 2 + tg_event_guest/controllers/main.py | 48 ++++++++++ tg_event_guest/controllers/portal.py | 48 ++++++++++ tg_event_guest/data/mail_template_data.xml | 27 ++++++ tg_event_guest/models/__init__.py | 2 + tg_event_guest/models/event_guest.py | 55 +++++++++++ tg_event_guest/models/res_users.py | 17 ++++ tg_event_guest/security/ir.model.access.csv | 3 + tg_event_guest/views/event_guest_views.xml | 95 +++++++++++++++++++ tg_event_guest/views/portal_templates.xml | 24 +++++ tg_event_guest/wizard/__init__.py | 1 + tg_event_guest/wizard/mail_compose_message.py | 20 ++++ 15 files changed, 386 insertions(+) create mode 100644 tg_event_guest/README.rst create mode 100644 tg_event_guest/__init__.py create mode 100644 tg_event_guest/__manifest__.py create mode 100644 tg_event_guest/controllers/__init__.py create mode 100644 tg_event_guest/controllers/main.py create mode 100644 tg_event_guest/controllers/portal.py create mode 100644 tg_event_guest/data/mail_template_data.xml create mode 100644 tg_event_guest/models/__init__.py create mode 100644 tg_event_guest/models/event_guest.py create mode 100644 tg_event_guest/models/res_users.py create mode 100644 tg_event_guest/security/ir.model.access.csv create mode 100644 tg_event_guest/views/event_guest_views.xml create mode 100644 tg_event_guest/views/portal_templates.xml create mode 100644 tg_event_guest/wizard/__init__.py create mode 100644 tg_event_guest/wizard/mail_compose_message.py diff --git a/tg_event_guest/README.rst b/tg_event_guest/README.rst new file mode 100644 index 0000000..474a356 --- /dev/null +++ b/tg_event_guest/README.rst @@ -0,0 +1,22 @@ +============== + Event guests +============== + + +Credits +======= + +Contributors +------------ + +* `Eugene Molotov `__ + +Sponsors +-------- + +* `Tribal Gathering `__ + +Maintainers +----------- + +* `IT-Projects LLC `__ diff --git a/tg_event_guest/__init__.py b/tg_event_guest/__init__.py new file mode 100644 index 0000000..48d9904 --- /dev/null +++ b/tg_event_guest/__init__.py @@ -0,0 +1,3 @@ +from . import models +from . import controllers +from . import wizard diff --git a/tg_event_guest/__manifest__.py b/tg_event_guest/__manifest__.py new file mode 100644 index 0000000..e91e670 --- /dev/null +++ b/tg_event_guest/__manifest__.py @@ -0,0 +1,19 @@ +{ + "name": """Event guests""", + "version": "14.0.0.1.0", + "author": "IT-Projects LLC, Eugene Molotov", + "support": "it@it-projects.info", + "website": "https://github.com/it-projects-llc/tg-addons", + "license": "LGPL-3", + "depends": [ + "auth_signup", + "event_sale", + "portal", + ], + "data": [ + "security/ir.model.access.csv", + "data/mail_template_data.xml", + "views/event_guest_views.xml", + "views/portal_templates.xml", + ], +} diff --git a/tg_event_guest/controllers/__init__.py b/tg_event_guest/controllers/__init__.py new file mode 100644 index 0000000..5e73599 --- /dev/null +++ b/tg_event_guest/controllers/__init__.py @@ -0,0 +1,2 @@ +from . import portal +from . import main diff --git a/tg_event_guest/controllers/main.py b/tg_event_guest/controllers/main.py new file mode 100644 index 0000000..db20609 --- /dev/null +++ b/tg_event_guest/controllers/main.py @@ -0,0 +1,48 @@ +from odoo.http import request + +from odoo.addons.auth_signup.controllers.main import ( + AuthSignupHome as BaseAuthSignupHome, +) + + +class AuthSignupHome(BaseAuthSignupHome): + def get_auth_signup_qcontext(self): + qcontext = super(AuthSignupHome, self).get_auth_signup_qcontext() + if not qcontext.get("guest_register_code") and request.params.get( + "guest_register_code" + ): + qcontext["guest_register_code"] = request.params.get("guest_register_code") + + guest_register_code = qcontext.get("guest_register_code") + if guest_register_code: + guest = request.env["event.guest"]._get_by_code(guest_register_code) + if guest: + if not qcontext.get("name"): + qcontext["name"] = guest.name or "" + if not qcontext.get("login"): + qcontext["login"] = guest.email or "" + + return qcontext + + def _signup_with_values(self, token, values): + qcontext = self.get_auth_signup_qcontext() + guest = None + if ( + bool(request) + and not (request.session.uid) + and qcontext.get("guest_register_code") + ): + guest = request.env["event.guest"]._get_by_code( + qcontext["guest_register_code"] + ) + if not guest or guest.result_partner: + guest = None + + res = super(AuthSignupHome, self)._signup_with_values(token, values) + + if guest: + guest.result_partner = ( + request.env["res.users"].browse(request.session.uid).partner_id + ) + + return res diff --git a/tg_event_guest/controllers/portal.py b/tg_event_guest/controllers/portal.py new file mode 100644 index 0000000..2da7be6 --- /dev/null +++ b/tg_event_guest/controllers/portal.py @@ -0,0 +1,48 @@ +from odoo.http import request, route + +from odoo.addons.portal.controllers.portal import CustomerPortal as BaseCustomerPortal + + +class CustomerPortal(BaseCustomerPortal): + @route() + def account(self, redirect=None, **post): + res = super(CustomerPortal, self).account(redirect, **post) + + if not request.httprequest.method == "POST": + # we are handling only POST requests here + return res + + if res.status_code == 200: + # some fields are not correct + return res + + partner = request.env.user.partner_id + guest = request.env.user.event_guest + + if not guest: + return res + + if not guest.result_attendee: + Attendee = request.env["event.registration"].sudo() + vals = { + "name": partner.name, + "event_id": guest.event.id, + "event_ticket_id": guest.event_ticket.id, + "partner_id": partner.id, + } + + # additional field from partner_event + if "attendee_partner_id" in Attendee._fields: + vals["attendee_partner_id"] = partner.id + + attendee = Attendee.create(vals) + attendee.action_confirm() + + ctx = attendee.action_send_badge_email()["context"] + compose = ( + attendee.env["mail.compose.message"].with_context(**ctx).create({}) + ) + compose.send_mail() + guest.result_attendee = attendee + + return res diff --git a/tg_event_guest/data/mail_template_data.xml b/tg_event_guest/data/mail_template_data.xml new file mode 100644 index 0000000..8807890 --- /dev/null +++ b/tg_event_guest/data/mail_template_data.xml @@ -0,0 +1,27 @@ + + + + Guest Mass Mail + + ${object.email|safe} + Invitation to ${object.event.name} + + ${object.lang} + +

Hello, ${object.name}!

+
+

+ Please complete your registration to ${object.event.display_name} using the + link +

+

Thank you!

+
+

You are receiving this email because ${object.invited_by.name} has invited you to ${object.event.display_name}. Please, let us know if you believe this email has been sent to you by mistake.

+
+

Tribal Gathering Crew

+
+
+
diff --git a/tg_event_guest/models/__init__.py b/tg_event_guest/models/__init__.py new file mode 100644 index 0000000..e1d822b --- /dev/null +++ b/tg_event_guest/models/__init__.py @@ -0,0 +1,2 @@ +from . import event_guest +from . import res_users diff --git a/tg_event_guest/models/event_guest.py b/tg_event_guest/models/event_guest.py new file mode 100644 index 0000000..a40f6c9 --- /dev/null +++ b/tg_event_guest/models/event_guest.py @@ -0,0 +1,55 @@ +from random import choice as random_choice +from string import ascii_lowercase, digits + +from odoo import api, fields, models + + +class EventGuest(models.Model): + _name = "event.guest" + _description = "Event Guest" + _order = "id DESC" + + @api.model + def _default_code(self): + return "".join([random_choice(ascii_lowercase + digits) for i in range(8)]) + + name = fields.Char(required=True) + email = fields.Char(required=True) + event = fields.Many2one( + "event.event", required=True, domain="[('stage_id.pipe_end', '=', False)]" + ) + event_ticket = fields.Many2one( + "event.event.ticket", + required=True, + domain="[('event_id', '=', event), ('price', '=', 0)]", + ) + code = fields.Char( + index=True, required=True, default=lambda self: self._default_code() + ) + + invited_by = fields.Many2one("res.partner", readonly=True) + guest_of = fields.Many2one("res.partner") + + result_partner = fields.Many2one( + "res.partner", string="Related partner", readonly=True + ) + result_attendee = fields.Many2one( + "event.registration", string="Related attendee", readonly=True + ) + + _sql_constraints = [ + ( + "code_unique", + "unique(code)", + "Code must be unique", + ), + ] + + @api.model + def _get_by_code(self, code): + return self.sudo().search( + [ + ("code", "=", code), + ], + limit=1, + ) diff --git a/tg_event_guest/models/res_users.py b/tg_event_guest/models/res_users.py new file mode 100644 index 0000000..129865a --- /dev/null +++ b/tg_event_guest/models/res_users.py @@ -0,0 +1,17 @@ +from odoo import fields, models + + +class ResUsers(models.Model): + _inherit = "res.users" + + event_guest = fields.Many2one("event.guest", compute="_compute_event_guest") + + def _compute_event_guest(self): + event_guests = self.env["event.guest"].search( + [ + ("result_partner", "in", self.mapped("partner_id").ids), + ] + ) + d = {x.result_partner.id: x.id for x in event_guests} + for user in self: + user.event_guest = d.get(user.partner_id.id, False) diff --git a/tg_event_guest/security/ir.model.access.csv b/tg_event_guest/security/ir.model.access.csv new file mode 100644 index 0000000..fdedb1b --- /dev/null +++ b/tg_event_guest/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_event_guest_user,access_event_guest_user,model_event_guest,base.group_user,1,1,1,1 +access_event_guest_public,access_event_guest_public,model_event_guest,,1,0,0,0 diff --git a/tg_event_guest/views/event_guest_views.xml b/tg_event_guest/views/event_guest_views.xml new file mode 100644 index 0000000..74322d0 --- /dev/null +++ b/tg_event_guest/views/event_guest_views.xml @@ -0,0 +1,95 @@ + + + + event.guest.form + event.guest + +
+ + + + + + + + + + + + + +
+
+
+ + + event.guest.tree + event.guest + + + + + + + + + + + + + + + + event.guest.search + event.guest + + + + + + + + + + + + Guests + event.guest + tree,form + { + 'search_default_no_result_attendee': 1 + } + + + + + + Send email + mail.compose.message + form + new + + + list,form + + +
diff --git a/tg_event_guest/views/portal_templates.xml b/tg_event_guest/views/portal_templates.xml new file mode 100644 index 0000000..9a61013 --- /dev/null +++ b/tg_event_guest/views/portal_templates.xml @@ -0,0 +1,24 @@ + + + + + + diff --git a/tg_event_guest/wizard/__init__.py b/tg_event_guest/wizard/__init__.py new file mode 100644 index 0000000..b528d99 --- /dev/null +++ b/tg_event_guest/wizard/__init__.py @@ -0,0 +1 @@ +from . import mail_compose_message diff --git a/tg_event_guest/wizard/mail_compose_message.py b/tg_event_guest/wizard/mail_compose_message.py new file mode 100644 index 0000000..00409a2 --- /dev/null +++ b/tg_event_guest/wizard/mail_compose_message.py @@ -0,0 +1,20 @@ +from odoo import api, models + + +class MailComposeMessage(models.TransientModel): + _inherit = "mail.compose.message" + + def send_mail(self, *args, **kw): + for wizard in self.filtered(lambda w: w.model == "event.guest"): + active_ids = self.env.context.get("active_ids") or [wizard.res_id] + self.env[wizard.model].browse( + active_ids + ).invited_by = self.env.user.partner_id + return super(MailComposeMessage, self).send_mail(*args, **kw) + + @api.model + def default_get(self, fields): + res = super(MailComposeMessage, self).default_get(fields) + if res.get("model") == "event.guest" and res.get("email_from"): + res["reply_to"] = res["email_from"] + return res From 29b98d67cb1e761394cec54aef75efeb06290003 Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Tue, 17 Sep 2024 09:30:11 +0500 Subject: [PATCH 2/9] =?UTF-8?q?[IMP]=20tg=5Fevent=5Fguest:=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=D0=B8=20=D0=BE=D1=82=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D0=BE=D0=B5=20=D0=BF=D0=BE=D0=BB=D0=B5=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B8=D0=BD=D0=B2=D0=B0=D0=B9=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tg_event_guest/__manifest__.py | 2 +- tg_event_guest/data/mail_template_data.xml | 4 +--- tg_event_guest/models/event_guest.py | 13 +++++++++++++ tg_event_guest/views/event_guest_views.xml | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tg_event_guest/__manifest__.py b/tg_event_guest/__manifest__.py index e91e670..a82188f 100644 --- a/tg_event_guest/__manifest__.py +++ b/tg_event_guest/__manifest__.py @@ -1,6 +1,6 @@ { "name": """Event guests""", - "version": "14.0.0.1.0", + "version": "14.0.0.2.0", "author": "IT-Projects LLC, Eugene Molotov", "support": "it@it-projects.info", "website": "https://github.com/it-projects-llc/tg-addons", diff --git a/tg_event_guest/data/mail_template_data.xml b/tg_event_guest/data/mail_template_data.xml index 8807890..53f44b3 100644 --- a/tg_event_guest/data/mail_template_data.xml +++ b/tg_event_guest/data/mail_template_data.xml @@ -12,9 +12,7 @@

Please complete your registration to ${object.event.display_name} using the - link + link

Thank you!


diff --git a/tg_event_guest/models/event_guest.py b/tg_event_guest/models/event_guest.py index a40f6c9..c3f902f 100644 --- a/tg_event_guest/models/event_guest.py +++ b/tg_event_guest/models/event_guest.py @@ -1,5 +1,6 @@ from random import choice as random_choice from string import ascii_lowercase, digits +from urllib.parse import urljoin from odoo import api, fields, models @@ -27,6 +28,7 @@ def _default_code(self): index=True, required=True, default=lambda self: self._default_code() ) + invite_url = fields.Char("Invite URL", compute="_compute_invite_url", store=False) invited_by = fields.Many2one("res.partner", readonly=True) guest_of = fields.Many2one("res.partner") @@ -53,3 +55,14 @@ def _get_by_code(self, code): ], limit=1, ) + + @api.depends("code", "event") + def _compute_invite_url(self): + for guest in self: + if guest.event: + guest.invite_url = urljoin( + guest.event.get_base_url(), + f"/web/signup?guest_register_code={guest.code}&redirect=%2Fmy%2Faccount", + ) + else: + guest.invite_url = False diff --git a/tg_event_guest/views/event_guest_views.xml b/tg_event_guest/views/event_guest_views.xml index 74322d0..dc889cf 100644 --- a/tg_event_guest/views/event_guest_views.xml +++ b/tg_event_guest/views/event_guest_views.xml @@ -12,6 +12,7 @@ + From 5a9ec9f9cb68624f8b4bc12802e336352fc8aa60 Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Tue, 1 Oct 2024 11:09:05 +0500 Subject: [PATCH 3/9] =?UTF-8?q?[FIX]=20tg=5Fevent=5Fguest:=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B7=D0=B2=D0=BE=D0=BB=D1=8F=D1=82=D1=8C=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D0=B8=D1=80=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=D1=81=D1=8F=20=D0=BA=D0=B0=D0=BA?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BB=D0=BE=D0=B3=D0=B8=D0=BD=D0=B5=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tg_event_guest/controllers/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tg_event_guest/controllers/main.py b/tg_event_guest/controllers/main.py index db20609..4d1a38c 100644 --- a/tg_event_guest/controllers/main.py +++ b/tg_event_guest/controllers/main.py @@ -1,3 +1,4 @@ +from odoo import _ from odoo.http import request from odoo.addons.auth_signup.controllers.main import ( @@ -21,6 +22,8 @@ def get_auth_signup_qcontext(self): qcontext["name"] = guest.name or "" if not qcontext.get("login"): qcontext["login"] = guest.email or "" + if request.session.uid: + qcontext["error"] = _("You need to logout to register guest") return qcontext From 8e8d82f942826da1ba6813a5325f63e2900e58be Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Thu, 3 Oct 2024 11:32:12 +0500 Subject: [PATCH 4/9] =?UTF-8?q?[IMP]=20tg=5Fevent=5Fguest:=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=D0=B8=20=D0=B2=D0=BE=D0=B7=D0=BC?= =?UTF-8?q?=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D0=B3=D0=BB=D0=B0=D1=88=D0=B0=D1=82=D1=8C=20=D0=B3=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B5=D0=B9=20=D0=B8=D0=B7=20=D1=81=D1=83=D1=89=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D0=B2=D1=83=D1=8E=D1=89=D0=B8=D1=85=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D0=B5?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tg_event_guest/controllers/portal.py | 8 ++++++ tg_event_guest/models/event_guest.py | 33 ++++++++++++++++++---- tg_event_guest/views/event_guest_views.xml | 1 + 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/tg_event_guest/controllers/portal.py b/tg_event_guest/controllers/portal.py index 2da7be6..7d01dbc 100644 --- a/tg_event_guest/controllers/portal.py +++ b/tg_event_guest/controllers/portal.py @@ -6,6 +6,14 @@ class CustomerPortal(BaseCustomerPortal): @route() def account(self, redirect=None, **post): + if not request.httprequest.method == "POST": + if post.get("guest_register_code"): + guest = request.env["event.guest"]._get_by_code( + post["guest_register_code"] + ) + if guest.guest_partner == request.env.user.partner_id: + guest.result_partner = request.env.user.partner_id + res = super(CustomerPortal, self).account(redirect, **post) if not request.httprequest.method == "POST": diff --git a/tg_event_guest/models/event_guest.py b/tg_event_guest/models/event_guest.py index c3f902f..dec0be4 100644 --- a/tg_event_guest/models/event_guest.py +++ b/tg_event_guest/models/event_guest.py @@ -19,6 +19,10 @@ def _default_code(self): event = fields.Many2one( "event.event", required=True, domain="[('stage_id.pipe_end', '=', False)]" ) + guest_partner = fields.Many2one( + "res.partner", compute="_compute_guest_partner", store=True + ) + event_ticket = fields.Many2one( "event.event.ticket", required=True, @@ -56,13 +60,32 @@ def _get_by_code(self, code): limit=1, ) - @api.depends("code", "event") + @api.depends("email") + def _compute_guest_partner(self): + with_email = self.filtered("email") + for record in self: + record.guest_partner = self.env["res.partner"].search( + [ + ("email", "=", record.email), + ], + limit=1, + ) + + (self - with_email).write( + { + "guest_partner": False, + } + ) + + @api.depends("code", "event", "guest_partner") def _compute_invite_url(self): for guest in self: if guest.event: - guest.invite_url = urljoin( - guest.event.get_base_url(), - f"/web/signup?guest_register_code={guest.code}&redirect=%2Fmy%2Faccount", - ) + if guest.guest_partner: + path = f"/my/account?guest_register_code={guest.code}" + else: + path = f"/web/signup?guest_register_code={guest.code}&redirect=%2Fmy%2Faccount" # noqa: B950 + + guest.invite_url = urljoin(guest.event.get_base_url(), path) else: guest.invite_url = False diff --git a/tg_event_guest/views/event_guest_views.xml b/tg_event_guest/views/event_guest_views.xml index dc889cf..b40797d 100644 --- a/tg_event_guest/views/event_guest_views.xml +++ b/tg_event_guest/views/event_guest_views.xml @@ -8,6 +8,7 @@ + From 2ea78eaadf4f3d887f4099471403cdf71cdd2fb4 Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Fri, 25 Oct 2024 13:32:19 +0500 Subject: [PATCH 5/9] =?UTF-8?q?[FIX]=20tg=5Fevent=5Fguest:=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=B8=D0=BC=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20=D1=81=20auth=5Fsignup=5Fverify=5Femail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tg_event_guest/controllers/main.py | 23 --------- tg_event_guest/models/res_users.py | 19 ++++++- tg_event_guest/tests/__init__.py | 1 + tg_event_guest/tests/test_main.py | 79 ++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 24 deletions(-) create mode 100644 tg_event_guest/tests/__init__.py create mode 100644 tg_event_guest/tests/test_main.py diff --git a/tg_event_guest/controllers/main.py b/tg_event_guest/controllers/main.py index 4d1a38c..8a7e025 100644 --- a/tg_event_guest/controllers/main.py +++ b/tg_event_guest/controllers/main.py @@ -26,26 +26,3 @@ def get_auth_signup_qcontext(self): qcontext["error"] = _("You need to logout to register guest") return qcontext - - def _signup_with_values(self, token, values): - qcontext = self.get_auth_signup_qcontext() - guest = None - if ( - bool(request) - and not (request.session.uid) - and qcontext.get("guest_register_code") - ): - guest = request.env["event.guest"]._get_by_code( - qcontext["guest_register_code"] - ) - if not guest or guest.result_partner: - guest = None - - res = super(AuthSignupHome, self)._signup_with_values(token, values) - - if guest: - guest.result_partner = ( - request.env["res.users"].browse(request.session.uid).partner_id - ) - - return res diff --git a/tg_event_guest/models/res_users.py b/tg_event_guest/models/res_users.py index 129865a..3bcd6d9 100644 --- a/tg_event_guest/models/res_users.py +++ b/tg_event_guest/models/res_users.py @@ -1,4 +1,4 @@ -from odoo import fields, models +from odoo import api, fields, models class ResUsers(models.Model): @@ -15,3 +15,20 @@ def _compute_event_guest(self): d = {x.result_partner.id: x.id for x in event_guests} for user in self: user.event_guest = d.get(user.partner_id.id, False) + + @api.model + def signup(self, values, token=None): + guest_register_code = values.pop("guest_register_code", False) + res = super(ResUsers, self).signup(values, token) + if guest_register_code: + guest = self.env["event.guest"]._get_by_code(guest_register_code) + if guest and not guest.result_partner: + user = self.search( + [ + ("login", "=", res[1]), + ], + limit=1, + ) + guest.result_partner = user.partner_id + + return res diff --git a/tg_event_guest/tests/__init__.py b/tg_event_guest/tests/__init__.py new file mode 100644 index 0000000..6c9812d --- /dev/null +++ b/tg_event_guest/tests/__init__.py @@ -0,0 +1 @@ +from . import test_main diff --git a/tg_event_guest/tests/test_main.py b/tg_event_guest/tests/test_main.py new file mode 100644 index 0000000..69ed29b --- /dev/null +++ b/tg_event_guest/tests/test_main.py @@ -0,0 +1,79 @@ +from datetime import datetime, timedelta + +from odoo import fields +from odoo.tests import TransactionCase + + +class TestMain(TransactionCase): + def test_signup_01(self): + self.env["res.config.settings"].create( + { + "auth_signup_uninvited": "b2c", + } + ).execute() + + Users = self.env["res.users"].with_context( + mail_create_nolog=True, + mail_create_nosubscribe=True, + mail_notrack=True, + no_reset_password=True, + ) + + event = self.env["event.event"].create( + { + "name": "Test event", + "date_begin": fields.Datetime.to_string( + datetime.today() + timedelta(days=1) + ), + "date_end": fields.Datetime.to_string( + datetime.today() + timedelta(days=15) + ), + "event_ticket_ids": [ + ( + 0, + 0, + { + "name": "Test ticket", + }, + ) + ], + } + ) + + guest = self.env["event.guest"].create( + { + "name": "Eugene", + "email": "eugene@mailforspam.com", + "event": event.id, + "event_ticket": event.event_ticket_ids[0].id, + } + ) + + guest_user_tuple = Users.signup( + { + "name": "eugene1", + "login": "eugene1", + "password": "eugene1", + "guest_register_code": guest.code, + } + ) + guest_user = Users.search([("login", "=", guest_user_tuple[1])]) + + guest.invalidate_cache(fnames=["result_partner"]) + self.assertEqual(guest.result_partner, guest_user.partner_id) + + # for example, some reason other test user registered with already used guest code + + guest_user_tuple = Users.signup( + { + "name": "eugene2", + "login": "eugene2", + "password": "eugene2", + "guest_register_code": guest.code, + } + ) + accident_guest_user = Users.search([("login", "=", guest_user_tuple[1])]) + + guest.invalidate_cache(fnames=["result_partner"]) + self.assertNotEqual(guest.result_partner, accident_guest_user.partner_id) + self.assertEqual(guest.result_partner, guest_user.partner_id) From 3f673089a55abd89f6dbb471d8a04b528c29f72a Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Fri, 1 Nov 2024 15:49:16 +0500 Subject: [PATCH 6/9] =?UTF-8?q?[FIX]=20tg=5Fevent=5Fguest:=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=BF=D1=83=D1=81=D0=BA=D0=B0=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BA=20/my=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=B1=D0=B8=D0=BB?= =?UTF-8?q?=D0=B5=D1=82=20=D0=B4=D0=BB=D1=8F=20=D0=B3=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8F=20=D0=BD=D0=B5=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tg_event_guest/controllers/portal.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tg_event_guest/controllers/portal.py b/tg_event_guest/controllers/portal.py index 7d01dbc..dfd097f 100644 --- a/tg_event_guest/controllers/portal.py +++ b/tg_event_guest/controllers/portal.py @@ -4,6 +4,13 @@ class CustomerPortal(BaseCustomerPortal): + @route() + def home(self, **kw): + guest = request.env.user.event_guest + if guest and not guest.result_attendee: + return request.redirect("/my/account") + return super(CustomerPortal, self).home(**kw) + @route() def account(self, redirect=None, **post): if not request.httprequest.method == "POST": From 99634bf1017ff0b0361cf6dcdb453a3c354fdab6 Mon Sep 17 00:00:00 2001 From: Eugene Molotov Date: Mon, 11 Nov 2024 14:59:36 +0500 Subject: [PATCH 7/9] =?UTF-8?q?[DOC]=20tg=5Fevent=5Fguest:=20=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=BE,=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=BA=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tg_event_guest/README.rst | 92 +++- tg_event_guest/__manifest__.py | 2 +- tg_event_guest/readme/CONTRIBUTORS.md | 1 + tg_event_guest/readme/DESCRIPTION.md | 1 + tg_event_guest/readme/USAGE.md | 25 + tg_event_guest/static/description/index.html | 457 +++++++++++++++++++ 6 files changed, 567 insertions(+), 11 deletions(-) create mode 100644 tg_event_guest/readme/CONTRIBUTORS.md create mode 100644 tg_event_guest/readme/DESCRIPTION.md create mode 100644 tg_event_guest/readme/USAGE.md create mode 100644 tg_event_guest/static/description/index.html diff --git a/tg_event_guest/README.rst b/tg_event_guest/README.rst index 474a356..3660d92 100644 --- a/tg_event_guest/README.rst +++ b/tg_event_guest/README.rst @@ -1,22 +1,94 @@ -============== - Event guests -============== +============ +Event guests +============ +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:fc7a7eef77a1909fe77e3bb8cd041eedadb7eb2b7ee189bf08b1e902481bc4ea + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-it--projects--llc%2Ftg--addons-lightgray.png?logo=github + :target: https://github.com/it-projects-llc/tg-addons/tree/14.0/tg_event_guest + :alt: it-projects-llc/tg-addons + +|badge1| |badge2| |badge3| + +Module for inviting guests to event + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Preparing guest +--------------- + +- Go to main menu -> Events -> Guests +- Create record with following mandatory fields set: + + - Name + - Email + - Event + - Event ticket + +- Save +- Run Actions -> Send mail +- In "Send mail" wizard leave everything default +- Send +- RESULT: email with invitation link is sent +- RESULT: invitation link is the same as in guest form + +Guest registering +----------------- + +- Copy "Invitation link" from event guest form or from invitiation + email as actual guest +- Open that link in browser as logged out user (probably in + Incognito/Private mode) +- Register and set password +- RESULT: you will be redirected to contact details portal page +- Fill in all required fields and press "Confirm" +- RESULT: new registration created. Event and event ticket are used + guest form, that is filled in "Preparing guest" section + +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 ======= -Contributors ------------- +Authors +------- -* `Eugene Molotov `__ +* IT-Projects LLC -Sponsors --------- +Contributors +------------ -* `Tribal Gathering `__ +- Eugene Molotov (https://github.com/em230418) Maintainers ----------- -* `IT-Projects LLC `__ +This module is part of the `it-projects-llc/tg-addons `_ project on GitHub. + +You are welcome to contribute. diff --git a/tg_event_guest/__manifest__.py b/tg_event_guest/__manifest__.py index a82188f..60b719c 100644 --- a/tg_event_guest/__manifest__.py +++ b/tg_event_guest/__manifest__.py @@ -1,7 +1,7 @@ { "name": """Event guests""", "version": "14.0.0.2.0", - "author": "IT-Projects LLC, Eugene Molotov", + "author": "IT-Projects LLC", "support": "it@it-projects.info", "website": "https://github.com/it-projects-llc/tg-addons", "license": "LGPL-3", diff --git a/tg_event_guest/readme/CONTRIBUTORS.md b/tg_event_guest/readme/CONTRIBUTORS.md new file mode 100644 index 0000000..2f4c137 --- /dev/null +++ b/tg_event_guest/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Eugene Molotov (https://github.com/em230418) diff --git a/tg_event_guest/readme/DESCRIPTION.md b/tg_event_guest/readme/DESCRIPTION.md new file mode 100644 index 0000000..5658503 --- /dev/null +++ b/tg_event_guest/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Module for inviting guests to event diff --git a/tg_event_guest/readme/USAGE.md b/tg_event_guest/readme/USAGE.md new file mode 100644 index 0000000..3582881 --- /dev/null +++ b/tg_event_guest/readme/USAGE.md @@ -0,0 +1,25 @@ +Preparing guest +--------------- + +- Go to main menu -> Events -> Guests +- Create record with following mandatory fields set: + * Name + * Email + * Event + * Event ticket +- Save +- Run Actions -> Send mail +- In "Send mail" wizard leave everything default +- Send +- RESULT: email with invitation link is sent +- RESULT: invitation link is the same as in guest form + +Guest registering +----------------- + +- Copy "Invitation link" from event guest form or from invitiation email as actual guest +- Open that link in browser as logged out user (probably in Incognito/Private mode) +- Register and set password +- RESULT: you will be redirected to contact details portal page +- Fill in all required fields and press "Confirm" +- RESULT: new registration created. Event and event ticket are used guest form, that is filled in "Preparing guest" section diff --git a/tg_event_guest/static/description/index.html b/tg_event_guest/static/description/index.html new file mode 100644 index 0000000..5417c6d --- /dev/null +++ b/tg_event_guest/static/description/index.html @@ -0,0 +1,457 @@ + + + + + +Event guests + + + +
+

Event guests

+ + +

Beta License: LGPL-3 it-projects-llc/tg-addons

+

Module for inviting guests to event

+

Table of contents

+ +
+

Usage

+
+

Preparing guest

+
    +
  • Go to main menu -> Events -> Guests
  • +
  • Create record with following mandatory fields set:
      +
    • Name
    • +
    • Email
    • +
    • Event
    • +
    • Event ticket
    • +
    +
  • +
  • Save
  • +
  • Run Actions -> Send mail
  • +
  • In “Send mail” wizard leave everything default
  • +
  • Send
  • +
  • RESULT: email with invitation link is sent
  • +
  • RESULT: invitation link is the same as in guest form
  • +
+
+
+

Guest registering

+
    +
  • Copy “Invitation link” from event guest form or from invitiation +email as actual guest
  • +
  • Open that link in browser as logged out user (probably in +Incognito/Private mode)
  • +
  • Register and set password
  • +
  • RESULT: you will be redirected to contact details portal page
  • +
  • Fill in all required fields and press “Confirm”
  • +
  • RESULT: new registration created. Event and event ticket are used +guest form, that is filled in “Preparing guest” section
  • +
+
+
+
+

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

+
    +
  • IT-Projects LLC
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is part of the it-projects-llc/tg-addons project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + From 13ab8ae3c4daf7ae945b3f25738b0a79e58a4b4a Mon Sep 17 00:00:00 2001 From: Kuat Azimkhan Date: Mon, 11 Nov 2024 16:11:52 +0500 Subject: [PATCH 8/9] [IMP] tg_event_guest: pre-commit auto fixes --- tg_event_guest/README.rst | 6 +++--- tg_event_guest/__manifest__.py | 2 +- tg_event_guest/controllers/main.py | 2 +- tg_event_guest/controllers/portal.py | 4 ++-- tg_event_guest/models/event_guest.py | 2 +- tg_event_guest/models/res_users.py | 2 +- tg_event_guest/pyproject.toml | 3 +++ tg_event_guest/static/description/index.html | 6 +++--- tg_event_guest/tests/test_main.py | 2 +- tg_event_guest/wizard/mail_compose_message.py | 4 ++-- 10 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 tg_event_guest/pyproject.toml diff --git a/tg_event_guest/README.rst b/tg_event_guest/README.rst index 3660d92..a02ac5b 100644 --- a/tg_event_guest/README.rst +++ b/tg_event_guest/README.rst @@ -17,7 +17,7 @@ Event guests :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-it--projects--llc%2Ftg--addons-lightgray.png?logo=github - :target: https://github.com/it-projects-llc/tg-addons/tree/14.0/tg_event_guest + :target: https://github.com/it-projects-llc/tg-addons/tree/17.0/tg_event_guest :alt: it-projects-llc/tg-addons |badge1| |badge2| |badge3| @@ -69,7 +69,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -89,6 +89,6 @@ Contributors Maintainers ----------- -This module is part of the `it-projects-llc/tg-addons `_ project on GitHub. +This module is part of the `it-projects-llc/tg-addons `_ project on GitHub. You are welcome to contribute. diff --git a/tg_event_guest/__manifest__.py b/tg_event_guest/__manifest__.py index 60b719c..c279b99 100644 --- a/tg_event_guest/__manifest__.py +++ b/tg_event_guest/__manifest__.py @@ -1,6 +1,6 @@ { "name": """Event guests""", - "version": "14.0.0.2.0", + "version": "17.0.0.2.0", "author": "IT-Projects LLC", "support": "it@it-projects.info", "website": "https://github.com/it-projects-llc/tg-addons", diff --git a/tg_event_guest/controllers/main.py b/tg_event_guest/controllers/main.py index 8a7e025..1fc6d77 100644 --- a/tg_event_guest/controllers/main.py +++ b/tg_event_guest/controllers/main.py @@ -8,7 +8,7 @@ class AuthSignupHome(BaseAuthSignupHome): def get_auth_signup_qcontext(self): - qcontext = super(AuthSignupHome, self).get_auth_signup_qcontext() + qcontext = super().get_auth_signup_qcontext() if not qcontext.get("guest_register_code") and request.params.get( "guest_register_code" ): diff --git a/tg_event_guest/controllers/portal.py b/tg_event_guest/controllers/portal.py index dfd097f..2e1ed38 100644 --- a/tg_event_guest/controllers/portal.py +++ b/tg_event_guest/controllers/portal.py @@ -9,7 +9,7 @@ def home(self, **kw): guest = request.env.user.event_guest if guest and not guest.result_attendee: return request.redirect("/my/account") - return super(CustomerPortal, self).home(**kw) + return super().home(**kw) @route() def account(self, redirect=None, **post): @@ -21,7 +21,7 @@ def account(self, redirect=None, **post): if guest.guest_partner == request.env.user.partner_id: guest.result_partner = request.env.user.partner_id - res = super(CustomerPortal, self).account(redirect, **post) + res = super().account(redirect, **post) if not request.httprequest.method == "POST": # we are handling only POST requests here diff --git a/tg_event_guest/models/event_guest.py b/tg_event_guest/models/event_guest.py index dec0be4..6d64540 100644 --- a/tg_event_guest/models/event_guest.py +++ b/tg_event_guest/models/event_guest.py @@ -84,7 +84,7 @@ def _compute_invite_url(self): if guest.guest_partner: path = f"/my/account?guest_register_code={guest.code}" else: - path = f"/web/signup?guest_register_code={guest.code}&redirect=%2Fmy%2Faccount" # noqa: B950 + path = f"/web/signup?guest_register_code={guest.code}&redirect=%2Fmy%2Faccount" # noqa: B950 E501 guest.invite_url = urljoin(guest.event.get_base_url(), path) else: diff --git a/tg_event_guest/models/res_users.py b/tg_event_guest/models/res_users.py index 3bcd6d9..0aefd6a 100644 --- a/tg_event_guest/models/res_users.py +++ b/tg_event_guest/models/res_users.py @@ -19,7 +19,7 @@ def _compute_event_guest(self): @api.model def signup(self, values, token=None): guest_register_code = values.pop("guest_register_code", False) - res = super(ResUsers, self).signup(values, token) + res = super().signup(values, token) if guest_register_code: guest = self.env["event.guest"]._get_by_code(guest_register_code) if guest and not guest.result_partner: diff --git a/tg_event_guest/pyproject.toml b/tg_event_guest/pyproject.toml new file mode 100644 index 0000000..4231d0c --- /dev/null +++ b/tg_event_guest/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/tg_event_guest/static/description/index.html b/tg_event_guest/static/description/index.html index 5417c6d..aa8cf70 100644 --- a/tg_event_guest/static/description/index.html +++ b/tg_event_guest/static/description/index.html @@ -369,7 +369,7 @@

Event guests

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:fc7a7eef77a1909fe77e3bb8cd041eedadb7eb2b7ee189bf08b1e902481bc4ea !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: LGPL-3 it-projects-llc/tg-addons

+

Beta License: LGPL-3 it-projects-llc/tg-addons

Module for inviting guests to event

Table of contents

@@ -429,7 +429,7 @@

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.

+feedback.

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

@@ -448,7 +448,7 @@

Contributors

Maintainers

-

This module is part of the it-projects-llc/tg-addons project on GitHub.

+

This module is part of the it-projects-llc/tg-addons project on GitHub.

You are welcome to contribute.

diff --git a/tg_event_guest/tests/test_main.py b/tg_event_guest/tests/test_main.py index 69ed29b..1969cf0 100644 --- a/tg_event_guest/tests/test_main.py +++ b/tg_event_guest/tests/test_main.py @@ -62,7 +62,7 @@ def test_signup_01(self): guest.invalidate_cache(fnames=["result_partner"]) self.assertEqual(guest.result_partner, guest_user.partner_id) - # for example, some reason other test user registered with already used guest code + # for example, some reason other test user registered with already used guest code # noqa: E501 guest_user_tuple = Users.signup( { diff --git a/tg_event_guest/wizard/mail_compose_message.py b/tg_event_guest/wizard/mail_compose_message.py index 00409a2..88a4c71 100644 --- a/tg_event_guest/wizard/mail_compose_message.py +++ b/tg_event_guest/wizard/mail_compose_message.py @@ -10,11 +10,11 @@ def send_mail(self, *args, **kw): self.env[wizard.model].browse( active_ids ).invited_by = self.env.user.partner_id - return super(MailComposeMessage, self).send_mail(*args, **kw) + return super().send_mail(*args, **kw) @api.model def default_get(self, fields): - res = super(MailComposeMessage, self).default_get(fields) + res = super().default_get(fields) if res.get("model") == "event.guest" and res.get("email_from"): res["reply_to"] = res["email_from"] return res From cd7e76772e69b36eae395d81f0ff1cdcad407da6 Mon Sep 17 00:00:00 2001 From: Kuat Azimkhan Date: Wed, 13 Nov 2024 09:37:57 +0500 Subject: [PATCH 9/9] [MIG] tg_event_guest: Migration to 17.0 --- tg_event_guest/controllers/main.py | 6 ++++ tg_event_guest/controllers/portal.py | 2 +- tg_event_guest/data/mail_template_data.xml | 20 ++++++----- tg_event_guest/models/event_guest.py | 1 + tg_event_guest/models/res_users.py | 2 +- tg_event_guest/tests/test_main.py | 4 +-- tg_event_guest/views/event_guest_views.xml | 36 +++++++++++-------- tg_event_guest/views/portal_templates.xml | 2 +- tg_event_guest/wizard/mail_compose_message.py | 4 +-- 9 files changed, 47 insertions(+), 30 deletions(-) diff --git a/tg_event_guest/controllers/main.py b/tg_event_guest/controllers/main.py index 1fc6d77..5173aa7 100644 --- a/tg_event_guest/controllers/main.py +++ b/tg_event_guest/controllers/main.py @@ -26,3 +26,9 @@ def get_auth_signup_qcontext(self): qcontext["error"] = _("You need to logout to register guest") return qcontext + + def _prepare_signup_values(self, qcontext): + values = super()._prepare_signup_values(qcontext) + if qcontext.get("guest_register_code"): + values["guest_register_code"] = qcontext["guest_register_code"] + return values diff --git a/tg_event_guest/controllers/portal.py b/tg_event_guest/controllers/portal.py index 2e1ed38..6f7b199 100644 --- a/tg_event_guest/controllers/portal.py +++ b/tg_event_guest/controllers/portal.py @@ -57,7 +57,7 @@ def account(self, redirect=None, **post): compose = ( attendee.env["mail.compose.message"].with_context(**ctx).create({}) ) - compose.send_mail() + compose.action_send_mail() guest.result_attendee = attendee return res diff --git a/tg_event_guest/data/mail_template_data.xml b/tg_event_guest/data/mail_template_data.xml index 53f44b3..0c185a7 100644 --- a/tg_event_guest/data/mail_template_data.xml +++ b/tg_event_guest/data/mail_template_data.xml @@ -3,21 +3,25 @@ Guest Mass Mail - ${object.email|safe} - Invitation to ${object.event.name} + {{ object.email }} + Invitation to {{ object.event.name }} - ${object.lang} -

Hello, ${object.name}!

+

Hello, object name!


- Please complete your registration to ${object.event.display_name} using the - link + Please complete your registration to event display_name using the + link

Thank you!


-

You are receiving this email because ${object.invited_by.name} has invited you to ${object.event.display_name}. Please, let us know if you believe this email has been sent to you by mistake.

+

You are receiving this email because invited_by name has invited you to event display_name. Please, let us know if you believe this email has been sent to you by mistake.


Tribal Gathering Crew

diff --git a/tg_event_guest/models/event_guest.py b/tg_event_guest/models/event_guest.py index 6d64540..432c0a1 100644 --- a/tg_event_guest/models/event_guest.py +++ b/tg_event_guest/models/event_guest.py @@ -7,6 +7,7 @@ class EventGuest(models.Model): _name = "event.guest" + _inherit = "mail.thread" _description = "Event Guest" _order = "id DESC" diff --git a/tg_event_guest/models/res_users.py b/tg_event_guest/models/res_users.py index 0aefd6a..c408b95 100644 --- a/tg_event_guest/models/res_users.py +++ b/tg_event_guest/models/res_users.py @@ -25,7 +25,7 @@ def signup(self, values, token=None): if guest and not guest.result_partner: user = self.search( [ - ("login", "=", res[1]), + ("login", "=", res[0]), ], limit=1, ) diff --git a/tg_event_guest/tests/test_main.py b/tg_event_guest/tests/test_main.py index 1969cf0..d1c0637 100644 --- a/tg_event_guest/tests/test_main.py +++ b/tg_event_guest/tests/test_main.py @@ -59,7 +59,7 @@ def test_signup_01(self): ) guest_user = Users.search([("login", "=", guest_user_tuple[1])]) - guest.invalidate_cache(fnames=["result_partner"]) + guest = self.env["event.guest"].browse(guest.id) self.assertEqual(guest.result_partner, guest_user.partner_id) # for example, some reason other test user registered with already used guest code # noqa: E501 @@ -74,6 +74,6 @@ def test_signup_01(self): ) accident_guest_user = Users.search([("login", "=", guest_user_tuple[1])]) - guest.invalidate_cache(fnames=["result_partner"]) + guest = self.env["event.guest"].browse(guest.id) self.assertNotEqual(guest.result_partner, accident_guest_user.partner_id) self.assertEqual(guest.result_partner, guest_user.partner_id) diff --git a/tg_event_guest/views/event_guest_views.xml b/tg_event_guest/views/event_guest_views.xml index b40797d..b9078a3 100644 --- a/tg_event_guest/views/event_guest_views.xml +++ b/tg_event_guest/views/event_guest_views.xml @@ -5,21 +5,27 @@ event.guest
- - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
+ + +
diff --git a/tg_event_guest/views/portal_templates.xml b/tg_event_guest/views/portal_templates.xml index 9a61013..fd2e9e5 100644 --- a/tg_event_guest/views/portal_templates.xml +++ b/tg_event_guest/views/portal_templates.xml @@ -1,7 +1,7 @@