From 98c7a7d7831cb898b764a28907594fdf969045f5 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Wed, 23 Jan 2019 11:40:13 -0600 Subject: Fixed resume and pub builder --- app/resume/build.py | 49 ++++++++++++++++++++++++++++++++++--------------- app/resume/urls.py | 33 +++++++++++++++++---------------- 2 files changed, 51 insertions(+), 31 deletions(-) (limited to 'app/resume') diff --git a/app/resume/build.py b/app/resume/build.py index 285521a..4f051d5 100644 --- a/app/resume/build.py +++ b/app/resume/build.py @@ -6,12 +6,15 @@ from pages.models import Page from .models import Publisher -class BuildResume(BuildNew): +class BuildPubs(BuildNew): def build(self): self.build_detail_view() self.build_publisher_list() - self.build_pages() + self.build_list_view( + base_path=reverse("resume:list"), + paginate_by=9999 + ) def get_model_queryset(self): return self.model.objects.all() @@ -19,6 +22,7 @@ class BuildResume(BuildNew): def build_detail_view(self): for obj in self.get_model_queryset(): url = obj.get_absolute_url() + print(url) path, slug = os.path.split(url) path = '%s/' % path # write html @@ -30,27 +34,42 @@ class BuildResume(BuildNew): publishers = Publisher.objects.all() for publisher in publishers: self.build_list_view( - base_path=reverse("resume:live_publisher_redirect", kwargs={'publisher': publisher.slug, }), + base_path=reverse("resume:list_by_publisher", kwargs={'publisher': publisher.slug, }), paginate_by=9999 ) + +class BuildResume(BuildNew): + + def build(self): + self.build_pages() + + def get_model_queryset(self): + return self.model.objects.all() + def build_pages(self): ''' - build out /resume and /resume/cv + build out /work/index.html and work/resume.html ''' - pages = Page.objects.filter(app="resume") + pages = self.get_model_queryset().filter(app="resume", build=True) for obj in pages: - url = obj.get_absolute_url() - path, slug = os.path.split(url) - path = '%s/' % path - # write html - response = self.client.get(url) - if obj.slug == "resume": - path = "/resume/" + path = "work/" + if obj.slug == "profile": + url = '/work/' slug = "index" - print(path, slug) + else: + url = "/%s%s/" % (path, obj.slug) + slug = obj.slug + # write html + response = self.client.get(url, HTTP_HOST='127.0.0.1') self.write_file(path, response.content, filename=slug) -def builder(): - j = BuildResume("resume", "pubitem") + +def pub_builder(): + j = BuildPubs("resume", "pubitem") + j.build() + + +def resume_builder(): + j = BuildResume("pages", "page") j.build() diff --git a/app/resume/urls.py b/app/resume/urls.py index 0086a2b..de95866 100644 --- a/app/resume/urls.py +++ b/app/resume/urls.py @@ -7,16 +7,15 @@ app_name = "resume" urlpatterns = [ path( - r'', - views.PageView.as_view(), - {'path': 'work', 'slug': 'profile'}, - name="pages" + r'pubs///', + views.ByPublisherListView.as_view(), + name='list_by_publisher', ), path( - r'/', - views.PageView.as_view(), - {'path': 'work'}, - name="pages" + r'pubs//', + views.ByPublisherListView.as_view(), + {'page': 1}, + name='list_by_publisher', ), path( r'pubs//', @@ -29,19 +28,21 @@ urlpatterns = [ {'page': 1}, name="list" ), - path( - r'pubs///', - views.ByPublisherListView.as_view(), - name='list_by_publisher', - ), path( r'pubs//', views.PubItemDetailView.as_view(), name='detail', ), path( - r'pubs/(?P[-\w]+)/$', - RedirectView.as_view(url="/resume/pubs/%(publisher)s/1/", permanent=False), - name="live_publisher_redirect" + r'/', + views.PageView.as_view(), + {'path': 'work'}, + name="pages" + ), + path( + r'', + views.PageView.as_view(), + {'path': 'work', 'slug': 'profile'}, + name="pages" ), ] -- cgit v1.2.3-70-g09d2