Add hidden bulletin groups

This commit is contained in:
Yingtong Li 2019-03-31 22:52:08 +11:00
parent 1daffa2a08
commit fc110e4060
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 4 additions and 3 deletions

View File

@ -26,6 +26,7 @@ class Group(models.Model):
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
subscribable = models.BooleanField() subscribable = models.BooleanField()
order = models.IntegerField(null=True, blank=True) order = models.IntegerField(null=True, blank=True)
hidden = models.BooleanField()
managers = JSONField(default=[], blank=True) managers = JSONField(default=[], blank=True)

View File

@ -74,7 +74,7 @@ def bulletin_preview(request):
else: else:
date = timezone.now().date() date = timezone.now().date()
date += datetime.timedelta(days=(6 - date.weekday() + 7) % 7) # Next Sunday (6 = Sunday) date += datetime.timedelta(days=(6 - date.weekday() + 7) % 7) # Next Sunday (6 = Sunday)
return render(request, 'sspromotions/bulletin_preview.html', {'date': date, 'groups': models.Group.objects.all()}) return render(request, 'sspromotions/bulletin_preview.html', {'date': date, 'groups': models.Group.objects.filter(hidden=False).all()})
@login_required @login_required
def bulletin_new(request): def bulletin_new(request):
@ -102,7 +102,7 @@ def bulletin_new(request):
item.date += datetime.timedelta(days=(6 - item.date.weekday() + 7) % 7) # Next Sunday (6 = Sunday) item.date += datetime.timedelta(days=(6 - item.date.weekday() + 7) % 7) # Next Sunday (6 = Sunday)
return render(request, 'sspromotions/bulletin_edit.html', { return render(request, 'sspromotions/bulletin_edit.html', {
'item': item, 'item': item,
'groups': models.Group.objects.all() 'groups': models.Group.objects.filter(hidden=False).all()
}) })
@login_required @login_required
@ -131,7 +131,7 @@ def bulletin_edit(request, id):
return HttpResponse('Unauthorized', status=401) return HttpResponse('Unauthorized', status=401)
return render(request, 'sspromotions/bulletin_edit.html', { return render(request, 'sspromotions/bulletin_edit.html', {
'item': item, 'item': item,
'groups': models.Group.objects.all() 'groups': models.Group.objects.filter(hidden=False).all()
}) })
@login_required @login_required