From acd26e7160d858de14f9b0f3fb7209f6eb4f8332 Mon Sep 17 00:00:00 2001 From: Yingtong Li Date: Sun, 11 Aug 2019 22:48:50 +1000 Subject: [PATCH] Do not send bulletin email if no items --- sspromotions/management/commands/sendbulletin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sspromotions/management/commands/sendbulletin.py b/sspromotions/management/commands/sendbulletin.py index 22607a4..9330bfc 100644 --- a/sspromotions/management/commands/sendbulletin.py +++ b/sspromotions/management/commands/sendbulletin.py @@ -100,6 +100,10 @@ class Command(BaseCommand): if sspromotions.models.BulletinSubscription.is_member_subscribed(member): template_args = sspromotions.utils.bulletin_args(member, sspromotions.models.Group.get_member_groups(member), events, bulbegin, bulend) + if len(template_args['groups']) == 0 and len(template_args['more']) == 0: + self.stdout.write('Skipping {} at {}'.format(member.id, member.email)) + continue + content_html = premailer.Premailer(template_html.render(template_args), cssutils_logging_level=logging.ERROR, strip_important=False).transform() content_txt = template_txt.render(template_args)