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> </table>
</th> </th>
</tr></tbody></table> </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 %} {% if not loop.first %}
{{ gap }} {{ gap }}
{% endif %} {% endif %}
@ -50,7 +50,7 @@
</th> </th>
</tr></tbody></table> </tr></tbody></table>
{{ gap }} {{ 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 --> <table class="row"><tbody><tr> <!-- Main Digest content -->
{% if item.image %} {% if item.image %}
<th class="small-12 large-3 columns first"> <th class="small-12 large-3 columns first">

View File

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