Filter on event date in galleries list

This commit is contained in:
Alexandre Iooss 2021-10-13 11:23:58 +02:00
parent 3130913191
commit dd5409d93e
2 changed files with 22 additions and 2 deletions

View file

@ -1,8 +1,11 @@
from django.urls import path from django.urls import path, re_path
from .views import TagDetail, GalleryDownload from .views import (CustomGalleryArchiveIndexView,
CustomGalleryYearArchiveView, GalleryDownload, TagDetail)
urlpatterns = [ urlpatterns = [
path('tag/<slug:slug>/', TagDetail.as_view(), name='tag-detail'), path('tag/<slug:slug>/', TagDetail.as_view(), name='tag-detail'),
path('gallery/', CustomGalleryArchiveIndexView.as_view(), name='pl-gallery-archive'),
re_path(r'^gallery/(?P<year>\d{4})/$', CustomGalleryYearArchiveView.as_view(), name='pl-gallery-archive-year'),
path('gallery/<slug:slug>/download/', GalleryDownload.as_view(), name='gallery-download'), path('gallery/<slug:slug>/download/', GalleryDownload.as_view(), name='gallery-download'),
] ]

View file

@ -9,6 +9,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponse from django.http import HttpResponse
from django.views.generic import DetailView from django.views.generic import DetailView
from photologue.models import Gallery from photologue.models import Gallery
from photologue.views import GalleryArchiveIndexView, GalleryYearArchiveView
from taggit.models import Tag from taggit.models import Tag
@ -26,6 +27,22 @@ class TagDetail(LoginRequiredMixin, DetailView):
return context return context
class CustomGalleryArchiveIndexView(GalleryArchiveIndexView):
"""
Override to use event date
"""
date_field = 'extended__date_start'
uses_datetime_field = False # Fix related object access
class CustomGalleryYearArchiveView(GalleryYearArchiveView):
"""
Override to use event date
"""
date_field = 'extended__date_start'
uses_datetime_field = False # Fix related object access
class GalleryDownload(LoginRequiredMixin, DetailView): class GalleryDownload(LoginRequiredMixin, DetailView):
model = Gallery model = Gallery