From: Michael Tremer Date: Fri, 14 Oct 2022 14:23:22 +0000 (+0000) Subject: users: Send a welcome email on registration X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18132fad8439144daf892d9336be1a7667fa182c;p=pbs.git users: Send a welcome email on registration Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index a036ed11..6d0e3213 100644 --- a/Makefile.am +++ b/Makefile.am @@ -331,6 +331,11 @@ dist_templates_users_DATA = \ templates_usersdir = $(templatesdir)/users +dist_templates_users_messages_DATA = \ + src/templates/users/messages/welcome.txt + +templates_users_messagesdir = $(templates_usersdir)/messages + dist_templates_users_modules_DATA = \ src/templates/users/modules/list.html @@ -480,6 +485,7 @@ dist_check_SCRIPTS = \ tests/build.py \ tests/builder.py \ tests/distro.py \ + tests/message.py \ tests/package.py \ tests/repo.py \ tests/upload.py diff --git a/src/buildservice/users.py b/src/buildservice/users.py index 84c8f042..bc0a0cd5 100644 --- a/src/buildservice/users.py +++ b/src/buildservice/users.py @@ -56,7 +56,7 @@ class Users(base.Object): return res.count - def create(self, name, realname=None): + def create(self, name, realname=None, notify=True): # XXX check if username has the correct name # Check if name is already taken @@ -70,6 +70,10 @@ class Users(base.Object): log.debug("Created user %s" % user.name) + # Send a welcome email + if notify: + user._send_welcome_email() + return user def create_from_ldap(self, name): @@ -296,6 +300,12 @@ class User(base.DataObject): **kwargs, ) + def _send_welcome_email(self): + """ + Sends a welcome email to the user + """ + self.send_email("users/messages/welcome.txt") + def is_admin(self): return self.data.admin is True diff --git a/src/templates/users/messages/welcome.txt b/src/templates/users/messages/welcome.txt new file mode 100644 index 00000000..ac625c8b --- /dev/null +++ b/src/templates/users/messages/welcome.txt @@ -0,0 +1,8 @@ +To: {{ recipient.email_to }} +Subject: {{ _("Welcome!") }} + +{{ _("Hello, %s!") % recipient }} + +{{ _("You have successfully created an account on the Pakfire Build Service.") }} + +{# XXX We should add some useful information here with links to documentation, and so on... #}