summaryrefslogtreecommitdiff
path: root/app/posts
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2020-11-15 10:13:08 -0500
committerluxagraf <sng@luxagraf.net>2020-11-15 10:13:08 -0500
commit7509da286bccd1dda358507cd455f9297db59247 (patch)
tree779aa3660e453d73268d22a72d9a5599cc94aa02 /app/posts
parentb2434dcba142961b4a4b67780cf64e01d0908bf5 (diff)
ported jrnl building to posts
Diffstat (limited to 'app/posts')
-rw-r--r--app/posts/build.py78
-rw-r--r--app/posts/migrations/0001_initial.py2
-rw-r--r--app/posts/templates/posts/jrnl_detail.txt2
-rw-r--r--app/posts/templates/posts/jrnl_latest.html6
-rw-r--r--app/posts/views/jrnl_views.py2
5 files changed, 73 insertions, 17 deletions
diff --git a/app/posts/build.py b/app/posts/build.py
index 73c52e2..8c8fee0 100644
--- a/app/posts/build.py
+++ b/app/posts/build.py
@@ -20,11 +20,6 @@ class BuildSrc(BuildNew):
self.build_detail_view()
-def src_builder():
- j = BuildSrc("posts", "post")
- j.build()
-
-
class BuildGuide(BuildNew):
def get_model_queryset(self):
@@ -38,11 +33,6 @@ class BuildGuide(BuildNew):
self.build_detail_view()
-def guide_builder():
- j = BuildGuide("posts", "post")
- j.build()
-
-
class BuildFieldNotes(BuildNew):
def get_model_queryset(self):
@@ -58,6 +48,68 @@ class BuildFieldNotes(BuildNew):
self.build_month_view("fieldnotes:list_month")
-def fieldnotes_builder():
- j = BuildFieldNotes("posts", "post")
- j.build()
+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,
+ location__state__country=c
+ )
+ except:
+ qs = self.model.objects.filter(
+ status__exact=1,
+ 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 BuildHome(BuildNew):
+
+ def build(self):
+ response = self.client.get('/')
+ self.write_file('', response.content)
diff --git a/app/posts/migrations/0001_initial.py b/app/posts/migrations/0001_initial.py
index e853a06..3c36ee9 100644
--- a/app/posts/migrations/0001_initial.py
+++ b/app/posts/migrations/0001_initial.py
@@ -11,12 +11,10 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
- ('jrnl', '0044_auto_20190917_1703'),
('books', '0009_book_afflink'),
('normalize', '__first__'),
('taxonomy', '0001_initial'),
('locations', '0018_auto_20190414_2124'),
- ('fieldnotes', '0002_auto_20190303_1222'),
('photos', '0019_auto_20190704_0903'),
]
diff --git a/app/posts/templates/posts/jrnl_detail.txt b/app/posts/templates/posts/jrnl_detail.txt
index 547ce79..a608b88 100644
--- a/app/posts/templates/posts/jrnl_detail.txt
+++ b/app/posts/templates/posts/jrnl_detail.txt
@@ -2,7 +2,7 @@
{% for letter in object.title %}={%endfor%}
by Scott Gilbertson
- <{{SITE_URL}}{{object.get_absolute_url}}>
+ <https://luxagraf.net{{object.get_absolute_url}}>
{{object.pub_date|date:"l, d F Y"}}
{{object.body_markdown|safe}}
diff --git a/app/posts/templates/posts/jrnl_latest.html b/app/posts/templates/posts/jrnl_latest.html
new file mode 100644
index 0000000..03e3c56
--- /dev/null
+++ b/app/posts/templates/posts/jrnl_latest.html
@@ -0,0 +1,6 @@
+{% extends "base.html" %}
+{% block js %}
+<script>
+window.location="{{object.get_absolute_url}}";
+</script>
+{% endblock %}
diff --git a/app/posts/views/jrnl_views.py b/app/posts/views/jrnl_views.py
index 1ff7a4c..0dc2dc8 100644
--- a/app/posts/views/jrnl_views.py
+++ b/app/posts/views/jrnl_views.py
@@ -121,7 +121,7 @@ class JrnlDetailViewTXT(JrnlDetailView):
class JrnlLatestView(JrnlDetailView):
- template_name = "details/entry_latest.html"
+ template_name = "posts/jrnl_latest.html"
def get_object(self, queryset=None):
obj = self.model.objects.filter(status=1).latest()