diff --git a/photologue_custom/urls.py b/photologue_custom/urls.py index 1401caf..52fc483 100644 --- a/photologue_custom/urls.py +++ b/photologue_custom/urls.py @@ -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 = [ path('tag//', TagDetail.as_view(), name='tag-detail'), + path('gallery/', CustomGalleryArchiveIndexView.as_view(), name='pl-gallery-archive'), + re_path(r'^gallery/(?P\d{4})/$', CustomGalleryYearArchiveView.as_view(), name='pl-gallery-archive-year'), path('gallery//download/', GalleryDownload.as_view(), name='gallery-download'), ] diff --git a/photologue_custom/views.py b/photologue_custom/views.py index cea94e7..285ae5e 100644 --- a/photologue_custom/views.py +++ b/photologue_custom/views.py @@ -9,6 +9,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin from django.http import HttpResponse from django.views.generic import DetailView from photologue.models import Gallery +from photologue.views import GalleryArchiveIndexView, GalleryYearArchiveView from taggit.models import Tag @@ -26,6 +27,22 @@ class TagDetail(LoginRequiredMixin, DetailView): 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): model = Gallery