2025-01-04 20:04:20 +02:00
|
|
|
from django.shortcuts import get_object_or_404, redirect, render
|
|
|
|
from django.views.generic import DetailView, ListView, TemplateView
|
|
|
|
|
|
|
|
from .models import Album
|
2024-12-28 12:21:29 +02:00
|
|
|
|
|
|
|
# Create your views here.
|
|
|
|
|
|
|
|
|
2025-01-04 20:04:20 +02:00
|
|
|
|
2024-12-28 14:14:21 +02:00
|
|
|
class Main(TemplateView):
|
2025-01-04 20:04:20 +02:00
|
|
|
template_name = "gallery/main.html"
|
|
|
|
|
|
|
|
|
|
|
|
class AlbumsList(ListView):
|
|
|
|
model = Album
|
|
|
|
template_name = 'gallery/album_list.html'
|
|
|
|
queryset = Album.objects.filter(is_public=True)
|
|
|
|
ordering = ['-album_date']
|
|
|
|
|
|
|
|
|
|
|
|
class AlbumDetail(DetailView):
|
|
|
|
model = Album
|
|
|
|
template_name = 'gallery/album_detail.html'
|
|
|
|
|
|
|
|
def get_object(self, queryset=None):
|
|
|
|
return get_object_or_404(Album, slug=self.kwargs.get('album_slug'))
|