From 8d10c2c041a39f4285b43f23ff31ae7d341df6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Sun, 6 Oct 2019 22:08:12 +0200 Subject: [PATCH] fix tags filtering in public/staff programs --- cfp/planning.py | 10 ++++++++-- cfp/views.py | 8 ++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cfp/planning.py b/cfp/planning.py index 24c55bb..2d9fe6e 100644 --- a/cfp/planning.py +++ b/cfp/planning.py @@ -22,13 +22,14 @@ Event = namedtuple('Event', ['talk', 'row', 'rowcount']) class Program: - def __init__(self, site, pending=False, cache=None): + def __init__(self, site, pending=False, cache=None, staff=False): self.site = site self.pending = pending if cache is None: self.cache = not settings.DEBUG else: self.cache = cache + self.staff = staff self.initialized = False def _lazy_init(self): @@ -40,6 +41,7 @@ class Program: filter(Q(duration__gt=0) | Q(category__duration__gt=0)).\ prefetch_related( Prefetch('tags', queryset=Tag.objects.filter(staff=True), to_attr='staff_tags'), + Prefetch('tags', queryset=Tag.objects.filter(public=True), to_attr='public_tags'), 'category', 'speakers', 'track', 'tags', 'room', ) @@ -150,7 +152,11 @@ class Program: continue options = ' rowspan="%d" bgcolor="%s"' % (event.rowcount, event.talk.category.color) cellcontent = escape(str(event.talk)) + '
' + escape(event.talk.get_speakers_str()) + '' - for tag in event.talk.staff_tags: + if self.staff: + tags = event.talk.staff_tags + else: + tags = event.talk.public_tags + for tag in tags: cellcontent += '
' + tag.label elif (i+1 > len(events) or not events[i+1]) and i+1 < self.cols[room]: colspan += 1 diff --git a/cfp/views.py b/cfp/views.py index b329875..f40feab 100644 --- a/cfp/views.py +++ b/cfp/views.py @@ -1283,8 +1283,8 @@ def create_user(request): }) -def schedule(request, program_format, pending, template, cache=None): - program = Program(site=request.conference.site, pending=pending, cache=cache) +def schedule(request, program_format, pending, template, staff, cache=None): + program = Program(site=request.conference.site, pending=pending, staff=staff, cache=cache) if program_format is None: return render(request, template, {'program': program.render('html')}) elif program_format == 'html': @@ -1305,12 +1305,12 @@ def public_schedule(request, program_format): if request.conference.schedule_redirection_url and program_format is None: return redirect(request.conference.schedule_redirection_url) else: - return schedule(request, program_format=program_format, pending=False, template='cfp/schedule.html') + return schedule(request, program_format=program_format, pending=False, template='cfp/schedule.html', staff=False) @staff_required def staff_schedule(request, program_format): - return schedule(request, program_format=program_format, pending=True, template='cfp/staff/schedule.html', cache=False) + return schedule(request, program_format=program_format, pending=True, template='cfp/staff/schedule.html', staff=True, cache=False) @staff_required