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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
from django.urls import reverse
from django.apps import apps
from builder.base import BuildNew
from itertools import chain
from django.conf import settings
from .models import PostType
class BuildSrc(BuildNew):
def get_model_queryset(self):
return self.model.objects.filter(post_type=PostType.SRC).filter(status__exact=1).order_by('-pub_date')
def build(self):
self.build_list_view(
base_path=reverse("src:list"),
paginate_by=50
)
self.build_detail_view()
self.build_feed("src:feed")
class BuildGuide(BuildNew):
def get_model_queryset(self):
return self.model.objects.filter(post_type__in=[PostType.FIELD_TEST, PostType.REVIEW]).filter(status__exact=1).order_by('-pub_date')
def build(self):
self.build_list_view(
base_path=reverse("guides:guide-base"),
paginate_by=50
)
self.build_detail_view()
class BuildFieldNotes(BuildNew):
def get_model_queryset(self):
return self.model.objects.filter(post_type=PostType.FIELD_NOTE).filter(status__exact=1).order_by('-pub_date')
def build(self):
self.build_detail_view()
self.build_list_view(
base_path=reverse("fieldnotes:list"),
paginate_by=24
)
self.build_year_view("fieldnotes:list_year")
self.build_month_view("fieldnotes:list_month")
class BuildJrnl(BuildNew):
'''
Write jrnl to disk
'''
def get_model_queryset(self):
return self.model.objects.filter(post_type=PostType.JRNL).filter(status__exact=1).order_by('-pub_date')
def build(self):
self.build_list_view(
base_path=reverse("jrnl:list"),
paginate_by=24
)
self.build_year_view("jrnl:list_year")
self.build_month_view("jrnl:list_month")
self.build_detail_view()
self.build_location_view()
self.build_latest()
def build_arc(self):
self.build_list_view(
base_path=reverse("jrnl:list"),
paginate_by=24
)
self.build_year_view("jrnl:list_year")
self.build_month_view("jrnl:list_month")
self.build_location_view()
def build_location_view(self):
c = apps.get_model('locations', 'Country')
r = apps.get_model('locations', 'Region')
countries = c.objects.filter(visited=True)
regions = r.objects.all()
locations = list(chain(countries, regions))
for c in locations:
try:
qs = self.model.objects.filter(
status__exact=1,
post_type=PostType.JRNL,
location__state__country=c
)
except:
qs = self.model.objects.filter(
status__exact=1,
post_type=PostType.JRNL,
location__state__country__lux_region=c.id
)
print(c)
pages = self.get_pages(qs, 24)
for page in range(pages):
base_path = reverse("jrnl:list_country", kwargs={'slug': c.slug, 'page': page + 1})
response = self.client.get(base_path)
print(response.content)
if page == 0:
self.write_file(base_path, response.content)
else:
self.write_file(base_path, response.content)
def build_latest(self):
response = self.client.get('/jrnl/latest/')
self.write_file(reverse("jrnl:latest"), response.content)
class BuildEssays(BuildNew):
def get_model_queryset(self):
return self.model.objects.filter(post_type=PostType.ESSAY).filter(status__exact=1).order_by('-pub_date')
def build(self):
self.build_list_view(
base_path=reverse("essay-list:list"),
paginate_by=50
)
self.build_detail_view()
class BuildRange(BuildNew):
def get_model_queryset(self):
return self.model.objects.filter(post_type=PostType.RANGE).filter(status__exact=1).order_by('-pub_date')
def build(self):
self.build_list_view(
base_path=reverse("range:range-list"),
paginate_by=30
)
self.build_detail_view()
self.build_feed("range:feed")
class BuildFriends(BuildNew):
def get_model_queryset(self):
return self.model.objects.filter(post_type=PostType.FRIENDS).filter(status__exact=1).order_by('-pub_date')
def build(self):
self.build_list_view(
base_path=reverse("friends:friends-list"),
paginate_by=30
)
self.build_detail_view()
self.build_feed("friends:feed")
class BuildFilms(BuildNew):
def get_model_queryset(self):
return self.model.objects.filter(post_type=PostType.FILM).filter(status__exact=1).order_by('-pub_date')
def build(self):
self.build_list_view(
base_path=reverse("films:list"),
paginate_by=30
)
self.build_detail_view()
class BuildTrips(BuildNew):
def get_model_queryset(self):
return self.model.objects.all()
def build(self):
self.build_list_view(
base_path=reverse("trips:list"),
paginate_by=30
)
self.build_detail_view()
|