1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
import json
from django.shortcuts import render_to_response, render
from django.template import RequestContext
from django.http import Http404, HttpResponse
from django.core import serializers
from .models import Photo, PhotoGallery, LuxGallery, LuxImage
from locations.models import Country, Region
from utils.views import PaginatedListView
from django.views.generic import ListView
from django.views.generic.detail import DetailView
class Gallery(DetailView):
model = LuxGallery
slug_field = "slug"
template_name = "details/photo_gallery.html"
class GalleryList(PaginatedListView):
template_name = 'archives/gallery_list.html'
def get_queryset(self):
return LuxGallery.objects.filter(is_public=True)
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super(GalleryList, self).get_context_data(**kwargs)
context['is_private'] = False
return context
class DailyPhotoList(PaginatedListView):
template_name = 'archives/photo_daily_list.html'
def get_queryset(self):
return LuxImage.objects.filter(is_public=True, title__startswith="daily_")
def photo_json(request, slug):
p = PhotoGallery.objects.filter(set_slug=slug)
return HttpResponse(serializers.serialize('json', p), mimetype='application/json')
def photo_preview_json(request, pk):
p = LuxImage.objects.get(pk=pk)
data = {}
data['url'] = p.get_admin_image()
data = json.dumps(data)
return HttpResponse(data)
def thumb_preview_json(request, pk):
p = LuxImage.objects.get(pk=pk)
data = {}
data['url'] = p.get_admin_insert()
data = json.dumps(data)
return HttpResponse(data)
|