diff options
Diffstat (limited to 'app/lttr/build.py')
-rw-r--r-- | app/lttr/build.py | 36 |
1 files changed, 36 insertions, 0 deletions
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() |