You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.2 KiB
43 lines
1.2 KiB
import warnings
|
|
import json
|
|
from django.conf import settings
|
|
from django.views.generic import DetailView, ListView
|
|
from photologue.models import Gallery, Photo
|
|
from django.shortcuts import get_object_or_404, HttpResponse
|
|
|
|
|
|
# Number of galleries to display per page.
|
|
GALLERY_PAGINATE_BY = getattr(settings, 'PHOTOLOGUE_GALLERY_PAGINATE_BY', 20)
|
|
|
|
if GALLERY_PAGINATE_BY != 20:
|
|
warnings.warn(
|
|
DeprecationWarning('PHOTOLOGUE_GALLERY_PAGINATE_BY setting will be removed in Photologue 3.1'))
|
|
|
|
# Number of photos to display per page.
|
|
PHOTO_PAGINATE_BY = getattr(settings, 'PHOTOLOGUE_PHOTO_PAGINATE_BY', 20)
|
|
|
|
if PHOTO_PAGINATE_BY != 20:
|
|
warnings.warn(
|
|
DeprecationWarning('PHOTOLOGUE_PHOTO_PAGINATE_BY setting will be removed in Photologue 3.1'))
|
|
|
|
class GalleryView(DetailView):
|
|
model = Gallery
|
|
slug_field = 'slug'
|
|
template_name = 'client/photoreport/gallery.html'
|
|
|
|
|
|
class PhotoView(DetailView):
|
|
model = Photo
|
|
slug_field = 'slug'
|
|
template_name = 'client/photoreport/photo.html'
|
|
|
|
|
|
def ajax_photo(request, id):
|
|
|
|
photo = get_object_or_404(Photo, pk=id)
|
|
|
|
response = {'title': photo.caption, 'text': photo.title, 'url':photo.get_display_url()}
|
|
|
|
return HttpResponse(json.dumps(response), content_type='application/json')
|
|
|
|
|
|
|