Bundle trimed down alternative to photologue
This commit is contained in:
parent
2da3419b8d
commit
5368a51a76
40 changed files with 2652 additions and 70 deletions
|
|
@ -2,7 +2,7 @@ from django.contrib import admin
|
|||
from django.utils.translation import gettext_lazy as _
|
||||
from photologue.admin import GalleryAdmin as GalleryAdminDefault
|
||||
from photologue.admin import PhotoAdmin as PhotoAdminDefault
|
||||
from photologue.models import Gallery, Photo, PhotoEffect, PhotoSize, Watermark
|
||||
from photologue.models import Gallery, Photo
|
||||
|
||||
from .models import GalleryExtended, PhotoExtended
|
||||
|
||||
|
|
@ -18,8 +18,6 @@ class GalleryAdmin(GalleryAdminDefault):
|
|||
model.
|
||||
"""
|
||||
inlines = [GalleryExtendedInline, ]
|
||||
autocomplete_fields = ['photos', ]
|
||||
search_fields = ['title', ]
|
||||
|
||||
|
||||
class PhotoExtendedInline(admin.StackedInline):
|
||||
|
|
@ -45,10 +43,5 @@ class PhotoAdmin(PhotoAdminDefault):
|
|||
get_owner.short_description = _('owner')
|
||||
|
||||
|
||||
admin.site.unregister(Gallery)
|
||||
admin.site.unregister(Photo)
|
||||
admin.site.unregister(PhotoEffect)
|
||||
admin.site.unregister(PhotoSize)
|
||||
admin.site.unregister(Watermark)
|
||||
admin.site.register(Gallery, GalleryAdmin)
|
||||
admin.site.register(Photo, PhotoAdmin)
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@ from django.apps import AppConfig
|
|||
|
||||
|
||||
class PhotologueCustomConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.AutoField'
|
||||
name = 'photologue_custom'
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "photologue/root.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% comment %}
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "photologue/root.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% comment %}
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "photologue/root.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% comment %}
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "photologue/root.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% comment %}
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endcomment %}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
from django.urls import path, re_path
|
||||
from photologue.views import GalleryArchiveIndexView, GalleryYearArchiveView, PhotoDetailView
|
||||
|
||||
from .views import (CustomGalleryArchiveIndexView, CustomGalleryDetailView,
|
||||
CustomGalleryYearArchiveView, CustomPhotoDetailView,
|
||||
GalleryDownload, GalleryUpload, TagDetail)
|
||||
from .views import CustomGalleryDetailView, GalleryDownload, GalleryUpload, TagDetail
|
||||
|
||||
# Rather than using photologue default router, we redefine our own router
|
||||
# with login and permission checks.
|
||||
app_name = 'photologue'
|
||||
urlpatterns = [
|
||||
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/', GalleryArchiveIndexView.as_view(), name='pl-gallery-archive'),
|
||||
re_path(r'^gallery/(?P<year>\d{4})/$', GalleryYearArchiveView.as_view(), name='pl-gallery-archive-year'),
|
||||
path('gallery/<slug:slug>/', CustomGalleryDetailView.as_view(), name='pl-gallery'),
|
||||
path('gallery/<slug:slug>/<int:owner>/', CustomGalleryDetailView.as_view(), name='pl-gallery-owner'),
|
||||
path('gallery/<slug:slug>/download/', GalleryDownload.as_view(), name='pl-gallery-download'),
|
||||
path('photo/<slug:slug>/', CustomPhotoDetailView.as_view(), name='pl-photo'),
|
||||
path('photo/<slug:slug>/', PhotoDetailView.as_view(), name='pl-photo'),
|
||||
path('upload/', GalleryUpload.as_view(), name='pl-gallery-upload'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ from django.utils.text import slugify
|
|||
from django.views.generic.detail import DetailView
|
||||
from django.views.generic.edit import FormView
|
||||
from photologue.models import Gallery, Photo
|
||||
from photologue.views import (GalleryArchiveIndexView, GalleryYearArchiveView,
|
||||
PhotoDetailView)
|
||||
from PIL import Image
|
||||
from taggit.models import Tag
|
||||
|
||||
|
|
@ -35,33 +33,17 @@ class TagDetail(LoginRequiredMixin, DetailView):
|
|||
"""
|
||||
current_tag = self.get_object().slug
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['galleries'] = Gallery.objects.on_site().is_public() \
|
||||
context['galleries'] = Gallery.objects.filter(is_public=True) \
|
||||
.filter(extended__tags__slug=current_tag) \
|
||||
.order_by('-extended__date_start')
|
||||
return context
|
||||
|
||||
|
||||
class CustomGalleryArchiveIndexView(LoginRequiredMixin, GalleryArchiveIndexView):
|
||||
"""
|
||||
Override to use event date
|
||||
"""
|
||||
date_field = 'extended__date_start'
|
||||
uses_datetime_field = False # Fix related object access
|
||||
|
||||
|
||||
class CustomGalleryYearArchiveView(LoginRequiredMixin, GalleryYearArchiveView):
|
||||
"""
|
||||
Override to use event date
|
||||
"""
|
||||
date_field = 'extended__date_start'
|
||||
uses_datetime_field = False # Fix related object access
|
||||
|
||||
|
||||
class CustomGalleryDetailView(LoginRequiredMixin, DetailView):
|
||||
"""
|
||||
Custom gallery detail view to filter on photo owner
|
||||
"""
|
||||
queryset = Gallery.objects.on_site().is_public()
|
||||
queryset = Gallery.objects.filter(is_public=True)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
|
@ -104,10 +86,6 @@ class GalleryDownload(LoginRequiredMixin, DetailView):
|
|||
return response
|
||||
|
||||
|
||||
class CustomPhotoDetailView(LoginRequiredMixin, PhotoDetailView):
|
||||
pass
|
||||
|
||||
|
||||
class GalleryUpload(PermissionRequiredMixin, FormView):
|
||||
"""
|
||||
Form to upload new photos in a gallery
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue