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()