From 657d719bfdc33c8b01a430ea3f58a4907c558f9d Mon Sep 17 00:00:00 2001 From: luxagraf Date: Thu, 3 Dec 2015 11:06:47 -0500 Subject: moved books to new build system --- app/books/build.py | 35 +++++++++++++++++++++++++++++++++++ app/books/urls.py | 4 ++-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 app/books/build.py (limited to 'app/books') diff --git a/app/books/build.py b/app/books/build.py new file mode 100644 index 0000000..6743e89 --- /dev/null +++ b/app/books/build.py @@ -0,0 +1,35 @@ +import os +from django.core.urlresolvers import reverse +from builder.base import BuildNew + + +class BuildBooks(BuildNew): + + def build(self): + self.build_detail_view() + self.build_list_view( + base_path=reverse("books:live_redirect"), + paginate_by=24 + ) + print("building books") + + def get_model_queryset(self): + return self.model.objects.all() + + def build_detail_view(self): + ''' + write out all the expenses for each trip + ''' + for obj in self.get_model_queryset(): + 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 builder(): + j = BuildBooks("books", "book") + j.build() diff --git a/app/books/urls.py b/app/books/urls.py index be075ab..89c125e 100644 --- a/app/books/urls.py +++ b/app/books/urls.py @@ -12,13 +12,13 @@ urlpatterns = [ name='list', ), url( - r'(?P[-\w]+)/$', + r'(?P[-\w]+)$', views.BookDetailView.as_view(), name='detail', ), url( r'^$', RedirectView.as_view(url="/books/1/", permanent=False), - name="live-redirect" + name="live_redirect" ), ] -- cgit v1.2.3-70-g09d2