Add link to full bulletin

This commit is contained in:
Yingtong Li 2019-03-05 20:16:14 +11:00
parent a681b05473
commit ee1aa8f200
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 9 additions and 4 deletions

View File

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