diff options
author | luxagraf <sng@luxagraf.net> | 2019-01-18 12:23:17 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2019-01-18 12:23:17 -0600 |
commit | a6360f4fda42a3f5339f66385001ea983323f00b (patch) | |
tree | ebb40cf896e7b584017172c55d4a71cfb412ccf8 | |
parent | fde59bfc55ae049f57f7f73599b4f9c9d2eb5224 (diff) |
cleaned up urls for work app
-rw-r--r-- | app/resume/urls.py | 36 | ||||
-rw-r--r-- | app/resume/views.py | 20 | ||||
-rw-r--r-- | config/base_urls.py | 2 | ||||
-rw-r--r-- | 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 @@ -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 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 @@ </div> <div class="profile"> <h3>Profile</h3> - <p class="p-summary">{{object.profile_html|smartypants|widont|safe}}</p> + <p class="p-summary">{{resume.profile_html|smartypants|widont|safe}}</p> </div> <div id="skills"> <h3>Skills</h3> - {{object.skills_html|smartypants|widont|safe}} + {{resume.skills_html|smartypants|widont|safe}} </div> <div class="h-calendar" id="experience"> - <h3>Experience</h3>{% for job in object.jobs.all %} + <h3>Experience</h3>{% for job in resume.jobs.all %} <div class="p-experience h-event"> <h2 class="p-name">{{job.title}}</h2> <ul class="meta"> |