21 lines
696 B
Python
21 lines
696 B
Python
# Copyright (C) 2021 by BDE ENS Paris-Saclay
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
from django.views.generic import DetailView
|
|
from taggit.models import Tag
|
|
from photologue.models import Gallery
|
|
|
|
|
|
class TagDetail(LoginRequiredMixin, DetailView):
|
|
model = Tag
|
|
|
|
def get_context_data(self, **kwargs):
|
|
"""
|
|
Insert the single object into the context dict.
|
|
"""
|
|
current_tag = self.get_object().slug
|
|
context = super().get_context_data(**kwargs)
|
|
context['galleries'] = Gallery.objects.on_site().is_public() \
|
|
.filter(extended__tags__name=current_tag)
|
|
return context
|