Browse Source

generalized user notifications

php2python
Holger Frey 7 years ago
parent
commit
437872da91
  1. 20
      ordr2/events.py

20
ordr2/events.py

@ -9,13 +9,21 @@ class UserLogIn(object): @@ -9,13 +9,21 @@ class UserLogIn(object):
class UserNotification(object):
def __init__(self, request, user):
template = None
def __init__(self, request, user, data=None):
self.request = request
self.user = user
self.data = data
class AccountActivation(UserNotification):
pass
template = 'ordr2:templates/emails/activation.jinja2'
class PasswordReset(UserNotification):
template = 'ordr2:templates/emails/password_reset.jinja2'
@subscriber(UserLogIn)
@ -32,11 +40,11 @@ def set_display_defaults(event): @@ -32,11 +40,11 @@ def set_display_defaults(event):
event.request.session['display'] = defaults
@subscriber(AccountActivation)
def account_activation_notification(event):
@subscriber(UserNotification)
def notify_user(event):
body = render(
'ordr2:templates/emails/activation.jinja2',
{'user': event.user},
event.template,
{'user': event.user, 'data': event.data},
event.request
)
message = Message(