fix tags filtering in public/staff programs
This commit is contained in:
parent
3d33955031
commit
8d10c2c041
|
@ -22,13 +22,14 @@ Event = namedtuple('Event', ['talk', 'row', 'rowcount'])
|
||||||
|
|
||||||
|
|
||||||
class Program:
|
class Program:
|
||||||
def __init__(self, site, pending=False, cache=None):
|
def __init__(self, site, pending=False, cache=None, staff=False):
|
||||||
self.site = site
|
self.site = site
|
||||||
self.pending = pending
|
self.pending = pending
|
||||||
if cache is None:
|
if cache is None:
|
||||||
self.cache = not settings.DEBUG
|
self.cache = not settings.DEBUG
|
||||||
else:
|
else:
|
||||||
self.cache = cache
|
self.cache = cache
|
||||||
|
self.staff = staff
|
||||||
self.initialized = False
|
self.initialized = False
|
||||||
|
|
||||||
def _lazy_init(self):
|
def _lazy_init(self):
|
||||||
|
@ -40,6 +41,7 @@ class Program:
|
||||||
filter(Q(duration__gt=0) | Q(category__duration__gt=0)).\
|
filter(Q(duration__gt=0) | Q(category__duration__gt=0)).\
|
||||||
prefetch_related(
|
prefetch_related(
|
||||||
Prefetch('tags', queryset=Tag.objects.filter(staff=True), to_attr='staff_tags'),
|
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',
|
'category', 'speakers', 'track', 'tags', 'room',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -150,7 +152,11 @@ class Program:
|
||||||
continue
|
continue
|
||||||
options = ' rowspan="%d" bgcolor="%s"' % (event.rowcount, event.talk.category.color)
|
options = ' rowspan="%d" bgcolor="%s"' % (event.rowcount, event.talk.category.color)
|
||||||
cellcontent = escape(str(event.talk)) + '<br><em>' + escape(event.talk.get_speakers_str()) + '</em>'
|
cellcontent = escape(str(event.talk)) + '<br><em>' + escape(event.talk.get_speakers_str()) + '</em>'
|
||||||
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 += '<br>' + tag.label
|
cellcontent += '<br>' + tag.label
|
||||||
elif (i+1 > len(events) or not events[i+1]) and i+1 < self.cols[room]:
|
elif (i+1 > len(events) or not events[i+1]) and i+1 < self.cols[room]:
|
||||||
colspan += 1
|
colspan += 1
|
||||||
|
|
|
@ -1283,8 +1283,8 @@ def create_user(request):
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def schedule(request, program_format, pending, template, cache=None):
|
def schedule(request, program_format, pending, template, staff, cache=None):
|
||||||
program = Program(site=request.conference.site, pending=pending, cache=cache)
|
program = Program(site=request.conference.site, pending=pending, staff=staff, cache=cache)
|
||||||
if program_format is None:
|
if program_format is None:
|
||||||
return render(request, template, {'program': program.render('html')})
|
return render(request, template, {'program': program.render('html')})
|
||||||
elif program_format == '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:
|
if request.conference.schedule_redirection_url and program_format is None:
|
||||||
return redirect(request.conference.schedule_redirection_url)
|
return redirect(request.conference.schedule_redirection_url)
|
||||||
else:
|
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
|
@staff_required
|
||||||
def staff_schedule(request, program_format):
|
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
|
@staff_required
|
||||||
|
|
Loading…
Reference in New Issue