summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/builder/views.py4
-rw-r--r--app/lttr/build.py36
-rw-r--r--design/templates/admin/buttons.html1
3 files changed, 41 insertions, 0 deletions
diff --git a/app/builder/views.py b/app/builder/views.py
index cbb33fb..7d463a7 100644
--- a/app/builder/views.py
+++ b/app/builder/views.py
@@ -11,6 +11,7 @@ from pages.build import builder as page_builder
#from fieldnotes.build import builder as fieldnotes_builder
from photos.build import dailybuilder
from posts.build import src_builder, guide_builder, fieldnotes_builder
+from lttr.build import lttr_builder
options = {
'writing': BuildWriting,
@@ -72,6 +73,9 @@ def do_build(request):
elif section == 'fieldnotes':
context = {'message': 'Writing FieldNotes to Disk'}
fieldnotes_builder()
+ elif section == 'lttr_archive':
+ context = {'message': 'Writing newsletter archives to Disk'}
+ lttr_builder()
else:
options[section]().build()
context = {'message': 'Writing %s to Disk' % section}
diff --git a/app/lttr/build.py b/app/lttr/build.py
new file mode 100644
index 0000000..f1efd80
--- /dev/null
+++ b/app/lttr/build.py
@@ -0,0 +1,36 @@
+import os
+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 NewsletterMailing
+
+
+class BuildNewsletterArchives(BuildNew):
+
+ def get_model_queryset(self):
+ return self.model.objects.exclude(slug='test')
+
+ def build(self):
+ for lttr in self.get_model_queryset():
+ self.build_list_view(
+ base_path=reverse("lttr:list", kwargs={'slug':lttr.slug}),
+ paginate_by=50
+ )
+ self.build_detail_view(lttr)
+
+ def build_detail_view(self, lttr):
+ for obj in lttr.newslettermailing_set.all():
+ url = obj.get_absolute_url()
+ path, slug = os.path.split(url)
+ path = '%s/' % path
+ # write html
+ response = self.client.get(url)
+ print(path, slug)
+ self.write_file(path, response.content, filename=slug)
+
+def lttr_builder():
+ j = BuildNewsletterArchives("lttr", "Newsletter")
+ j.build()
diff --git a/design/templates/admin/buttons.html b/design/templates/admin/buttons.html
index 32e2778..afdc2d9 100644
--- a/design/templates/admin/buttons.html
+++ b/design/templates/admin/buttons.html
@@ -44,6 +44,7 @@
<li class="item"><a href="/admin/build/build?id=homepage">Build Homepage</a></li>
<li class="item"><a href="/admin/build/build?id=sitemap">Build Sitemap</a></li>
<li class="item"><a href="/admin/build/build?id=buildrss">Build RSS</a></li>
+ <li class="item"><a href="/admin/build/build?id=lttr_archive">Build Newsletter</a></li>
<li class="item"><a href="/admin/build/build?id=guide">Build Guide</a></li>
<li class="item"><a href="/admin/build/build?id=pages">Build Pages</a></li>
<li class="item"><a href="/admin/build/build?id=fieldnotes">Build FieldNotes</a></li>