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
|
import os
from builder.base import BuildNew
from django.urls import reverse
from . import models
class BuildSrc(BuildNew):
def build(self):
self.build_list_view(
base_path=reverse("src:list"),
paginate_by=99999
)
self.build_list_view(
base_path=reverse("src:list_books"),
paginate_by=99999
)
self.build_detail_view()
# These are the unique classes for this model:
self.build_books_view()
self.build_topic_view()
self.build_feed("src:feed")
def build_topic_view(self):
for topic in models.Topic.objects.all():
url = reverse("src:list_topics", kwargs={'slug': topic.slug, })
path, slug = os.path.split(url)
response = self.client.get(url, HTTP_HOST='127.0.0.1')
self.write_file('%s/' % path, response.content, filename=slug)
def build_books_view(self):
for obj in models.Book.objects.all():
url = reverse("src:detail_book", kwargs={'slug': obj.slug, })
path, slug = os.path.split(url)
response = self.client.get(url, HTTP_HOST='127.0.0.1')
self.write_file('%s/' % path, response.content, filename=slug)
def builder():
j = BuildSrc("src", "post")
j.build()
"""
def build_books(self):
path = 'src/books/'
c = Context({
'object_list': Book.objects.filter(status__exact=1),
'MEDIA_URL': settings.BAKED_MEDIA_URL,
'IMAGES_URL': settings.BAKED_IMAGES_URL
})
t = render_to_string('archives/src_books.html', c).encode('utf-8')
self.write_file(path, t)
"""
|