Add detail page for tags
This commit is contained in:
parent
7d700bea36
commit
d59fb154b6
6 changed files with 48 additions and 2 deletions
|
|
@ -19,7 +19,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Si vous souhaitez qu'une photo soit supprimée, signalez le nous :
|
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>
|
<h3>Dernières galeries</h3>
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,11 @@ from .views import IndexView
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', IndexView.as_view(), name='index'),
|
path('', IndexView.as_view(), name='index'),
|
||||||
path('photologue/', include('photologue.urls', namespace='photologue')),
|
path('photologue/', include('photologue.urls', namespace='photologue')),
|
||||||
|
path('photologue_custom/', include('photologue_custom.urls')),
|
||||||
path('accounts/', include('django.contrib.auth.urls')),
|
path('accounts/', include('django.contrib.auth.urls')),
|
||||||
path('i18n/', include('django.conf.urls.i18n')),
|
path('i18n/', include('django.conf.urls.i18n')),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
path('admin/doc/', include('django.contrib.admindocs.urls')),
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
{% if gallery.extended.tags.all %}
|
{% if gallery.extended.tags.all %}
|
||||||
<p class="text-muted">
|
<p class="text-muted">
|
||||||
Tags : {% for tag in gallery.extended.tags.all %}
|
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 %}
|
{% endfor %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
16
photologue_custom/templates/taggit/tag_detail.html
Normal file
16
photologue_custom/templates/taggit/tag_detail.html
Normal 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 %}
|
||||||
7
photologue_custom/urls.py
Normal file
7
photologue_custom/urls.py
Normal 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'),
|
||||||
|
]
|
||||||
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue