Notification emails #80
@ -30,10 +30,12 @@ class Notification(models.Model):
|
||||
]
|
||||
unique_together = ['recipient', 'action']
|
||||
|
||||
def format_email_txt(self):
|
||||
def format_email(self):
|
||||
action = self.action
|
||||
subject = f'New Activity: {action.actor.full_name} {action.verb} {action.target}'
|
||||
url = self.get_absolute_url()
|
||||
# TODO construct a proper phrase, depending on the verb, maybe use a template
|
||||
return f'{self.action.actor.full_name} {self.action.verb} {self.action.target}: {url}'
|
||||
mesage = f'{action.actor.full_name} {action.verb} {action.target}: {url}'
|
||||
return (subject, mesage)
|
||||
|
||||
def get_absolute_url(self):
|
||||
if self.action.verb == Verb.RATED_EXTENSION:
|
||||
@ -50,5 +52,5 @@ class Notification(models.Model):
|
||||
else:
|
||||
url = self.action.target.get_absolute_url()
|
||||
|
||||
# TODO? url cloacking to auto-delete visited notifications
|
||||
# TODO? url cloacking to mark visited notifications as read automatically
|
||||
return absolutify(url)
|
||||
|
@ -41,8 +41,9 @@ class Command(BaseCommand):
|
||||
|
||||
|
||||
def send_notification_email(notification):
|
||||
subject = 'New activity'
|
||||
message = notification.format_email_txt()
|
||||
# TODO construct a proper phrase, depending on the verb,
|
||||
# possibly share a template with NotificationsView
|
||||
subject, message = notification.format_email()
|
||||
send_mail(
|
||||
subject,
|
||||
message,
|
||||
|
Loading…
Reference in New Issue
Block a user