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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
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 PrivateGallery(DetailView):
model = LuxGallery
slug_field = "slug"
template_name = "details/photo_gallery.html"
class PrivateGalleryList(PaginatedListView):
template_name = 'archives/gallery_list.html'
def get_queryset(self):
return LuxGallery.objects.filter(is_public=False)
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super(PrivateGalleryList, self).get_context_data(**kwargs)
context['is_private'] = True
return context
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 OldGalleryList(PaginatedListView):
template_name = 'archives/gallery_list.html'
model = PhotoGallery
def get_queryset(self):
return PhotoGallery.objects.filter(is_public=True)
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super(OldGalleryList, self).get_context_data(**kwargs)
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 gallery_list(request, page):
request.page_url = '/photos/%d/'
request.page = int(page)
context = {
'object_list': PhotoGallery.objects.all(),
'page': page,
}
return render(request, "archives/photos.html", context)
def gallery(request, slug):
context = {
'object': PhotoGallery.objects.get(set_slug=slug)
}
return render_to_response('details/photo_galleries.html', context, context_instance=RequestContext(request))
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)
def gallery_list_by_area(request, slug, page):
"""Grabs entries by region or country"""
request.page_url = '/photos/' + slug + '/%d/'
request.page = int(page)
try:
region = Region.objects.get(slug__exact=slug)
qs = PhotoGallery.objects.filter(region=region).order_by('-id')
except:
region = Country.objects.get(slug__exact=slug)
qs = PhotoGallery.objects.filter(location__state__country=region).order_by('-id')
if not region:
raise Http404
context = {
'object_list': qs,
'country_list': Country.objects.filter(visited=True),
'region_list': Region.objects.all(),
'region': region,
'page': page
}
return render_to_response("archives/photos.html", context, context_instance=RequestContext(request))
|