From a6360f4fda42a3f5339f66385001ea983323f00b Mon Sep 17 00:00:00 2001 From: luxagraf Date: Fri, 18 Jan 2019 12:23:17 -0600 Subject: cleaned up urls for work app --- app/resume/urls.py | 36 +++++++++++++++++++----------------- app/resume/views.py | 20 ++++++++++---------- config/base_urls.py | 2 +- design/templates/details/resume.html | 6 +++--- 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/app/resume/urls.py b/app/resume/urls.py index 0f74c70..0086a2b 100644 --- a/app/resume/urls.py +++ b/app/resume/urls.py @@ -6,13 +6,31 @@ from . import views app_name = "resume" urlpatterns = [ + path( + r'', + views.PageView.as_view(), + {'path': 'work', 'slug': 'profile'}, + name="pages" + ), + path( + r'/', + views.PageView.as_view(), + {'path': 'work'}, + name="pages" + ), path( r'pubs//', views.PublisherListView.as_view(), name='list', ), path( - r'pubs///', + r'pubs/', + views.PublisherListView.as_view(), + {'page': 1}, + name="list" + ), + path( + r'pubs///', views.ByPublisherListView.as_view(), name='list_by_publisher', ), @@ -21,25 +39,9 @@ urlpatterns = [ views.PubItemDetailView.as_view(), name='detail', ), - # redirect /slug/ to /slug/1/ for live server path( r'pubs/(?P[-\w]+)/$', RedirectView.as_view(url="/resume/pubs/%(publisher)s/1/", permanent=False), name="live_publisher_redirect" ), - path( - r'pubs', - RedirectView.as_view(url="/resume/pubs/1/", permanent=False), - name="live_redirect" - ), - path( - r'/', - views.PageView.as_view(), - name="pages" - ), - path( - r'', - views.ResumeView.as_view(), - name='resume', - ), ] diff --git a/app/resume/views.py b/app/resume/views.py index 9cdd8e7..b4b6762 100644 --- a/app/resume/views.py +++ b/app/resume/views.py @@ -1,5 +1,6 @@ from django.views.generic.detail import DetailView from django.views.generic.base import TemplateView +from django.shortcuts import get_object_or_404 from utils.views import PaginatedListView from .models import PubItem, Publisher, Resume @@ -43,17 +44,16 @@ class PageView(DetailView): model = Page slug_field = "slug" - def get_queryset(self): - try: - return Page.objects.get(path__startswith=self.kwargs['path']) - except: - return Page.objects.get(path__startswith=self.kwargs['path'],slug=self.kwargs['slug']) - + def get_object(self, **kwargs): + print("calling page view") + return get_object_or_404(Page, path=self.kwargs['path'], slug=self.kwargs['slug']) def get_template_names(self): return ["details/%s.html" % self.object.slug, 'details/page.html'] - -class ResumeView(DetailView): - model = Resume - template_name = "details/resume.html" + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(PageView, self).get_context_data(**kwargs) + if self.kwargs['slug'] == 'resume': + context['resume'] = Resume.objects.get(title='base') + return context diff --git a/config/base_urls.py b/config/base_urls.py index 7b8e75b..e212e29 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -54,7 +54,7 @@ urlpatterns = [ path(r'field-notes/', include('sketches.urls', namespace='sketches')), path(r'src/', include('src.urls', namespace='src')), path(r'figments/', include('figments.urls', namespace='figments')), - path(r'resume/', include('resume.urls', namespace='resume')), + path(r'work/', include('resume.urls', namespace='resume')), path(r'map', include('locations.urls', namespace='map')), path(r'map/', include('locations.urls', namespace='map')), path(r'', HomepageList.as_view(), name="homepage"), diff --git a/design/templates/details/resume.html b/design/templates/details/resume.html index eaff2db..860b03b 100644 --- a/design/templates/details/resume.html +++ b/design/templates/details/resume.html @@ -51,17 +51,17 @@

Profile

-

{{object.profile_html|smartypants|widont|safe}}

+

{{resume.profile_html|smartypants|widont|safe}}

Skills

- {{object.skills_html|smartypants|widont|safe}} + {{resume.skills_html|smartypants|widont|safe}}
-

Experience

{% for job in object.jobs.all %} +

Experience

{% for job in resume.jobs.all %}

{{job.title}}

    -- cgit v1.2.3