diff options
Diffstat (limited to 'app/resume')
-rw-r--r-- | app/resume/urls.py | 36 | ||||
-rw-r--r-- | app/resume/views.py | 20 |
2 files changed, 29 insertions, 27 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 @@ -7,12 +7,30 @@ app_name = "resume" urlpatterns = [ path( + r'', + views.PageView.as_view(), + {'path': 'work', 'slug': 'profile'}, + name="pages" + ), + path( + r'<str:slug>/', + views.PageView.as_view(), + {'path': 'work'}, + name="pages" + ), + path( r'pubs/<str:page>/', views.PublisherListView.as_view(), name='list', ), path( - r'pubs/<str:publisher>/<str:page>/', + r'pubs/', + views.PublisherListView.as_view(), + {'page': 1}, + name="list" + ), + path( + r'pubs/<str:publisher>/<int:page>/', 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<publisher>[-\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'<str:path>/<str:slug>', - views.PageView.as_view(), - name="pages" - ), - path( - r'<str:slug>', - 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 |