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