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