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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
from django.shortcuts import render
from django.template import RequestContext
from django.views.generic import ListView
from django.views.generic.detail import DetailView
from django.conf import settings
from django.db.models import Q
from posts.models import Post
#from projects.shortcuts import render_to_geojson
from sightings.models import Sighting
from utils.views import PaginatedListView
from .models import Country, Region, Route, Location, Track
def map_list(request):
context = {
'object_list': Post.objects.filter(status__exact=1),
'country_list': Country.objects.filter(visited=True).exclude(name='default'),
'route_list': Route.objects.all(),
'region_list': Region.objects.all()
}
return render(
request,
'archives/map.html',
context,
)
class MapList(ListView):
"""
Return list of Entries on map
"""
context_object_name = 'object_list'
queryset = Post.objects.filter(status__exact=1)
template_name = 'archives/map.html'
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super(MapList, self).get_context_data(**kwargs)
context['country_list'] = Country.objects.filter(visited=True).exclude(name='default'),
context['route_list'] = Route.objects.all(),
context['region_list'] = Region.objects.all()
context['IMAGES_URL'] = settings.IMAGES_URL
return context
class TravelsList(ListView):
"""
Return list of Entries by trip
"""
context_object_name = 'object_list'
queryset = Post.objects.filter(status__exact=1)
template_name = 'travels.html'
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super(TravelsList, self).get_context_data(**kwargs)
return context
class MapDataList(ListView):
"""
Build data file for Entries on map
"""
context_object_name = 'object_list'
queryset = Post.objects.filter(status__exact=1)
template_name = 'archives/map_data.html'
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super(MapDataList, self).get_context_data(**kwargs)
context['country_list'] = Country.objects.filter(visited=True).exclude(name='default'),
context['route_list'] = Route.objects.all(),
context['region_list'] = Region.objects.all()
context['IMAGES_URL'] = settings.IMAGES_URL
return context
def map_data(request):
context = {
'object_list': Post.objects.filter(status__exact=1),
'route_list': Route.objects.all(),
'country_list': Country.objects.filter(visited=True).exclude(name='default'),
'region_list': Region.objects.all()
}
return render(
request,
'archives/map_data.html',
context,
)
#def data_json(request, id):
# qs = Route.objects.filter(pk=id)
# return render_to_geojson(
# qs,
# included_fields=['id', ],
# geom_attribute='geometry',
# mimetype='application/json',
# pretty_print=True
# )
class LocationDetail(DetailView):
model = Location
def get_context_data(self, **kwargs):
context = super(LocationDetail, self).get_context_data(**kwargs)
context['entry_list'] = Post.objects.filter(
Q(location=self.get_object()) |
Q(location__in=Location.objects.filter(parent=self.get_object()))
)
context['sighting_list'] = Sighting.objects.filter(
Q(location=self.get_object()) |
Q(location__in=Location.objects.filter(parent=self.get_object()))
).order_by('ap_id', 'ap__apclass__kind').distinct("ap")
return context
class TrackDetailView(DetailView):
model = Track
def get_context_data(self, **kwargs):
context = super(TrackDetailView, self).get_context_data(**kwargs)
context['entry_list'] = Post.objects.filter(
Q(location=self.get_object().location) |
Q(location__in=Location.objects.filter(parent=self.get_object().location))
)
context['wildlife'] = Sighting.objects.filter(
Q(location=self.get_object().location) |
Q(location__in=Location.objects.filter(parent=self.get_object().location))
).order_by('ap_id', 'ap__apclass__kind').distinct("ap")
context['breadcrumbs'] = ("walks",self.object.date_walked.year,self.object.title)
return context
class TrackListView(PaginatedListView):
"""
Return list of Walks
"""
model = Track
def get_context_data(self, **kwargs):
'''
Add breadcrumb path
'''
context = super(TrackListView, self).get_context_data(**kwargs)
context['breadcrumbs'] = ("walks",)
return context
|