Initialise bulletin date to next Sunday

This commit is contained in:
Yingtong Li 2019-01-12 15:38:02 +11:00
parent 04093baf47
commit 07c141d509
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -93,7 +93,8 @@ def bulletin_new(request):
return redirect(reverse('bulletin_edit', kwargs={'id': item.id}))
else:
item = models.BulletinItem()
item.date = timezone.now()
item.date = timezone.now().date()
item.date += datetime.timedelta(days=(6 - item.date.weekday() + 7) % 7) # Next Sunday (6 = Sunday)
return render(request, 'sspromotions/bulletin_edit.html', {
'item': item,
'groups': [group for group in models.Group.objects.all() if group.can_user_access(request.user)],