From ee1aa8f200b72643ffdea8777dce4e3daacd7815 Mon Sep 17 00:00:00 2001 From: Yingtong Li Date: Tue, 5 Mar 2019 20:16:14 +1100 Subject: [PATCH] Add link to full bulletin --- sspromotions/views.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sspromotions/views.py b/sspromotions/views.py index 1f34a32..82d08a9 100644 --- a/sspromotions/views.py +++ b/sspromotions/views.py @@ -60,11 +60,16 @@ def bulletin_list(request): @login_required def bulletin_preview(request): - if request.method == 'POST': - group_ids = [int(k[6:]) for k, v in request.POST.items() if k.startswith('group_') and v] - groups = [group for group in models.Group.objects.all() if group.id in group_ids] + if request.method == 'POST' or request.GET.get('full', False) is not False: + if request.method == 'POST': + group_ids = [int(k[6:]) for k, v in request.POST.items() if k.startswith('group_') and v] + groups = [group for group in models.Group.objects.all() if group.id in group_ids] + dt = datetime.datetime.strptime(request.POST['date'], '%Y-%m-%d') + else: + groups = models.Group.objects.all() + dt = timezone.now() - datetime.timedelta(days=6) - calbegin, calend, bulbegin, bulend = utils.bulletin_dates(datetime.datetime.strptime(request.POST['date'], '%Y-%m-%d')) + calbegin, calend, bulbegin, bulend = utils.bulletin_dates(dt) return render(request, 'sspromotions/email/bulletin.html', utils.bulletin_args(None, groups, utils.get_calendar_events(calbegin, calend), bulbegin, bulend)) else: date = timezone.now().date()