import os from builder.base import BuildNew from django.core.urlresolvers 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) """