self.ctx['fragment_tags'] = [t for t in self.ctx['tags'] if t.category in ('theme', 'object')]
self.ctx['work_tags'] = [t for t in self.ctx['tags'] if t not in self.ctx['fragment_tags']]
self.is_themed = self.ctx['has_theme'] = bool(self.ctx['fragment_tags'])
- self.ctx['main_tag'] = self.ctx['fragment_tags'][0] if self.is_themed else self.ctx['tags'][0]
+ if self.is_themed:
+ self.ctx['main_tag'] = self.ctx['fragment_tags'][0]
+ elif self.ctx['tags']:
+ self.ctx['main_tag'] = self.ctx['tags'][0]
+ else:
+ self.ctx['main_tag'] = None
self.ctx['filtering_tags'] = [
t for t in self.ctx['tags']
if t is not self.ctx['main_tag']
qs = Book.tagged.with_all(self.ctx['work_tags']).filter(findable=True)
qs = qs.exclude(ancestor__in=qs)
if self.is_themed:
- qs = Fragment.tagged.with_all(self.ctx['fragment_tags']).filter(
- Q(book__in=qs) | Q(book__ancestor__in=qs)
- )
+ fqs = Fragment.tagged.with_all(self.ctx['fragment_tags'])
+ if self.ctx['work_tags']:
+ fqs = fqs.filter(
+ Q(book__in=qs) | Q(book__ancestor__in=qs)
+ )
+ qs = fqs
return qs
def get_suggested_tags(self, queryset):
raise ResponseInstead(HttpResponsePermanentRedirect(
reverse('tagged_object_list', args=['/'.join(tag.url_chunk for tag in e.tags)])))
+ if not tags:
+ raise Http404
try:
if len(tags) > settings.MAX_TAG_LIST:
raise Http404
'club_form': ScheduleForm() if book.preview else None,
'club': Club.objects.first() if book.preview else None,
'donation_form': DonationStep1Form(),
-
- 'EXPERIMENTS_SWITCHABLE_layout': True,
})