diff --git a/ordr2/events.py b/ordr2/events.py index 936ecc1..2d85584 100644 --- a/ordr2/events.py +++ b/ordr2/events.py @@ -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): 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(