Notification emails #80
@ -397,6 +397,9 @@ class DraftExtensionView(
|
|||||||
add_preview_formset.save()
|
add_preview_formset.save()
|
||||||
form.save()
|
form.save()
|
||||||
if 'submit_draft' in self.request.POST:
|
if 'submit_draft' in self.request.POST:
|
||||||
|
# in the signal context we won't know the real user doing that,
|
||||||
|
# so keeping this in the view code for now
|
||||||
|
# alternatively (TODO?) this could be turned into an ApprovalActivity record
|
||||||
action.send(
|
action.send(
|
||||||
self.request.user,
|
self.request.user,
|
||||||
verb=Verb.SUBMITTED_FOR_REVIEW,
|
verb=Verb.SUBMITTED_FOR_REVIEW,
|
||||||
|
@ -22,6 +22,9 @@ class Notification(models.Model):
|
|||||||
processed_by_mailer_at = models.DateTimeField(default=None, null=True)
|
processed_by_mailer_at = models.DateTimeField(default=None, null=True)
|
||||||
sent = models.BooleanField(default=False, null=False)
|
sent = models.BooleanField(default=False, null=False)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
unique_together = ['recipient', 'action']
|
||||||
|
|
||||||
def format_email_txt(self):
|
def format_email_txt(self):
|
||||||
url = self.get_absolute_url()
|
url = self.get_absolute_url()
|
||||||
# TODO construct a proper phrase, depending on the verb, maybe use a template
|
# TODO construct a proper phrase, depending on the verb, maybe use a template
|
||||||
|
@ -28,7 +28,7 @@ class Command(BaseCommand):
|
|||||||
# TODO check some form of recipient.is_subscribed(n):
|
# TODO check some form of recipient.is_subscribed(n):
|
||||||
n.sent = True
|
n.sent = True
|
||||||
to_send.append(n)
|
to_send.append(n)
|
||||||
# first mark, then send: to avoid spamming in case of a crash-loop
|
# first mark as processed, then send: avoid spamming in case of a crash-loop
|
||||||
Notification.objects.bulk_update(batch, ['processed_by_mailer_at', 'sent'])
|
Notification.objects.bulk_update(batch, ['processed_by_mailer_at', 'sent'])
|
||||||
if len(to_send) > 0:
|
if len(to_send) > 0:
|
||||||
logger.info(f'sending an email to {recipient} about {len(to_send)} notifications')
|
logger.info(f'sending an email to {recipient} about {len(to_send)} notifications')
|
||||||
|
16
users/migrations/0004_delete_notification.py
Normal file
16
users/migrations/0004_delete_notification.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Generated by Django 4.2.11 on 2024-04-12 18:09
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('users', '0003_notification'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='Notification',
|
||||||
|
),
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user