Add detail page for tags

This commit is contained in:
Alexandre Iooss 2021-09-23 11:05:04 +02:00
parent 7d700bea36
commit d59fb154b6
6 changed files with 48 additions and 2 deletions

View file

@ -19,7 +19,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
</p>
Si vous souhaitez qu'une photo soit supprimée, signalez le nous :
<a href="mailto:photos@crans.org?subject=[ABUS] Nouvelle requête" class="btn btn-warning btn-sm">Signaler un abus</a>
<a href="mailto:photos@crans.org?subject=[ABUS] Nouvelle requête" class="btn btn-dark btn-sm">Signaler un abus</a>
<h3>Dernières galeries</h3>
<div class="row mb-2">

View file

@ -23,9 +23,11 @@ from .views import IndexView
urlpatterns = [
path('', IndexView.as_view(), name='index'),
path('photologue/', include('photologue.urls', namespace='photologue')),
path('photologue_custom/', include('photologue_custom.urls')),
path('accounts/', include('django.contrib.auth.urls')),
path('i18n/', include('django.conf.urls.i18n')),
path('admin/', admin.site.urls),
path('admin/doc/', include('django.contrib.admindocs.urls')),
]
if settings.DEBUG:

View file

@ -26,7 +26,7 @@
{% if gallery.extended.tags.all %}
<p class="text-muted">
Tags : {% for tag in gallery.extended.tags.all %}
<span class="badge rounded-pill bg-dark">{{ tag }}</span>
<a class="badge rounded-pill bg-dark text-decoration-none" href="{% url 'tag-detail' tag %}">{{ tag }}</a>
{% endfor %}
</p>
{% endif %}

View file

@ -0,0 +1,16 @@
{% extends "base.html" %}
{% load i18n %}
{% block title %}{{ object.name }}{% endblock %}
{% block content %}
<h1>Tag : {{ object.name }}</h1>
<div class="row mb-2">
{% for gallery in galleries %}
<div class="col-md-3">
{% include "photologue/includes/gallery_sample.html" %}
</div>
{% endfor %}
</div>
{% endblock %}

View file

@ -0,0 +1,7 @@
from django.urls import path
from .views import TagDetail
urlpatterns = [
path('tags/<slug:slug>/', TagDetail.as_view(), name='tag-detail'),
]

View file

@ -0,0 +1,21 @@
# 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