blob: 4e53e3929056ff3cfb810820c7bf7eb283767e48 (
plain)
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
|
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-friends').exclude(slug='test-range').exclude(slug='test-src').exclude(slug='src')
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()
|