Fix mistake calculating current bulletin items

This commit is contained in:
Yingtong Li 2019-01-12 15:26:22 +11:00
parent 1661738514
commit 336f8cfbe8
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 10 additions and 7 deletions

View File

@ -33,7 +33,7 @@
</table>
</th>
</tr></tbody></table>
{% for group in groups if group.bulletinitem_set.filter(date__gte=dtbegin).filter(date__lt=dtend).count() > 0 %}
{% for group in groups if group.bulletinitem_set.filter(date__gte=bulbegin).filter(date__lt=bulend).count() > 0 %}
{% if not loop.first %}
{{ gap }}
{% endif %}
@ -50,7 +50,7 @@
</th>
</tr></tbody></table>
{{ gap }}
{% for item in group.bulletinitem_set.filter(date__gte=dtbegin).filter(date__lt=dtend).all() %}
{% for item in group.bulletinitem_set.filter(date__gte=bulbegin).filter(date__lt=bulend).all() %}
<table class="row"><tbody><tr> <!-- Main Digest content -->
{% if item.image %}
<th class="small-12 large-3 columns first">

View File

@ -57,15 +57,18 @@ def bulletin_list(request):
@login_required
def bulletin_preview(request):
dtbegin = timezone.now().date() + datetime.timedelta(days=1) # Start tomorrow for calendar
dtend = dtbegin + datetime.timedelta(days=14)
calbegin = timezone.now().date() + datetime.timedelta(days=1) # Start tomorrow for calendar
calend = calbegin + datetime.timedelta(days=14)
bulbegin = timezone.now().date()
bulend = bulbegin + datetime.timedelta(days=7)
return render(request, 'sspromotions/email/bulletin.html', {
'events': models.CalendarItem.objects.filter(date__gte=dtbegin).filter(date__lt=dtend).all(),
'events': models.CalendarItem.objects.filter(date__gte=calbegin).filter(date__lt=calend).all(),
'groups': models.Group.objects.all(),
'more': [],
'dtbegin': dtbegin,
'dtend': dtend
'bulbegin': bulbegin,
'bulend': bulend
})
@login_required