diff options
Diffstat (limited to 'app/posts')
-rw-r--r-- | app/posts/models.py | 2 | ||||
-rw-r--r-- | app/posts/templates/posts/howto_list.html | 22 | ||||
-rw-r--r-- | app/posts/templates/posts/review_list.html | 2 | ||||
-rw-r--r-- | app/posts/urls/craft_urls.py (renamed from app/posts/urls/guide_urls_old.py) | 14 | ||||
-rw-r--r-- | app/posts/views/craft_views.py | 57 |
5 files changed, 89 insertions, 8 deletions
diff --git a/app/posts/models.py b/app/posts/models.py index cf7212b..2ce7d96 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -140,6 +140,8 @@ class Post(models.Model): return reverse('src:detail', kwargs={"slug": self.slug}) if self.post_type == PostType.REVIEW: return reverse('reviews:review-detail', kwargs={"slug": self.slug}) + if self.post_type == PostType.HOWTO: + return reverse('craft:craft-detail', kwargs={"slug": self.slug}) if self.post_type == PostType.FIELD_NOTE: return reverse('fieldnote:detail', kwargs={"year": self.pub_date.year, "month": self.pub_date.strftime("%m"), "slug": self.slug}) if self.post_type == PostType.GUIDE: diff --git a/app/posts/templates/posts/howto_list.html b/app/posts/templates/posts/howto_list.html new file mode 100644 index 0000000..13b87c3 --- /dev/null +++ b/app/posts/templates/posts/howto_list.html @@ -0,0 +1,22 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% block pagetitle %}Notes and Essays On Living - By Scott Gilbertson {% endblock %} +{% block metadescription %}Essays and stories on self-reliance, DIY, repair, tools, birding, walking, living well, and other ephemera.{% endblock %} +{% block breadcrumbs %}{% if breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{%endif%}{% endblock %} +{% block primary %}<main role="main" id="essay-archive" class="essay-archive archive-list"> + <div class="archive-intro"> + <h1>Craft</h1> + <h3>It's not just what you do, but how you do it that creates the world around you. +</h3> + </div> + <ul class="archive-list">{% for object in object_list %} + <li class="h-entry hentry archive-list-card archive-list-card-sm" itemscope itemType="http://schema.org/Article"> + <span class="date dt-published card-smcaps">{{object.pub_date|date:"F Y"}}</span> + <a href="{{object.get_absolute_url}}"> + <h2 class="card-hed">{{object.title|safe|smartypants|widont}}</h2> + <p class="p-summary card-lede">{% if object.subtitle %}{{object.subtitle}}{%else%}{{object.meta_description|safe|smartypants|widont}}{%endif%}</p> + </a> + </li>{%endfor%} + </ul> + </main> +{%endblock%} diff --git a/app/posts/templates/posts/review_list.html b/app/posts/templates/posts/review_list.html index 5dcaa72..6c54f18 100644 --- a/app/posts/templates/posts/review_list.html +++ b/app/posts/templates/posts/review_list.html @@ -6,7 +6,7 @@ {% block primary %}<main role="main" id="essay-archive" class="essay-archive archive-list"> <div class="archive-intro"> <h1>Tools</h1> - <h3>At some point the wrench must be turned, the shutter clicked, the paper scratched. The right tool makes all the difference. In decades of testing, these are the best I've used.</h3> + <h3>I am fascinated by artifacts, stuff, the things we populate our lives with. I've chosen to call them tools, but they're more than that aren't they?</h3> </div> <ul class="archive-list">{% for object in object_list %} <li class="h-entry hentry archive-list-card archive-list-card-sm" itemscope itemType="http://schema.org/Article"> diff --git a/app/posts/urls/guide_urls_old.py b/app/posts/urls/craft_urls.py index d43d76a..92f0f87 100644 --- a/app/posts/urls/guide_urls_old.py +++ b/app/posts/urls/craft_urls.py @@ -1,28 +1,28 @@ from django.urls import path, re_path -from . import views +from ..views import craft_views as views -app_name = "guides" +app_name = "craft" urlpatterns = [ path( r'<str:slug>', - views.PostDetailView.as_view(), - name="detail" + views.CraftDetailView.as_view(), + name="craft-detail" ), path( r'<str:slug>.txt', - views.PostDetailViewTXT.as_view(), + views.CraftDetailViewTXT.as_view(), name="detail-txt" ), path( r'<int:page>/', - views.GuidesListView.as_view(), + views.CraftListView.as_view(), name="list" ), path( r'', - views.GuidesListView.as_view(), + views.CraftListView.as_view(), {'page':1}, name="list" ), diff --git a/app/posts/views/craft_views.py b/app/posts/views/craft_views.py new file mode 100644 index 0000000..da5f2b1 --- /dev/null +++ b/app/posts/views/craft_views.py @@ -0,0 +1,57 @@ +from django.views.generic import ListView +from django.views.generic.detail import DetailView +from django.contrib.syndication.views import Feed +from django.urls import reverse +from django.apps import apps +from django.conf import settings + +from utils.views import PaginatedListView, LuxDetailView + +from ..models import Post, PostType +from taxonomy.models import Category + + +class CraftListView(PaginatedListView): + model = Post + template_name = "posts/howto_list.html" + + def get_queryset(self): + queryset = super(CraftListView, self).get_queryset() + return queryset.filter(site__domain='luxagraf.net').filter(post_type__in=[PostType.HOWTO]).filter(status__exact=1).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image') + + def get_context_data(self, **kwargs): + ''' + override for custom breadcrumb path + ''' + # Call the base implementation first to get a context + context = super(CraftListView, self).get_context_data(**kwargs) + context['breadcrumbs'] = ('Craft',) + return context + + +class CraftDetailView(LuxDetailView): + model = Post + slug_field = "slug" + + def get_queryset(self): + queryset = super(CraftDetailView, self).get_queryset() + return queryset.select_related('location').prefetch_related('field_notes') + + def get_context_data(self, **kwargs): + context = super(CraftDetailView, self).get_context_data(**kwargs) + related = [] + for obj in self.object.related.all(): + model = apps.get_model(obj.model_name.app_label, obj.model_name.model) + related.append(model.objects.get(slug=obj.slug, pub_date=obj.pub_date)) + context['related'] = related + context['breadcrumbs'] = ('Range',) + context['crumb_url'] = reverse('range:range-list') + return context + + def get_template_names(self): + obj = self.get_object() + return ["posts/essay_detail.html"] + + +class CraftDetailViewTXT(CraftDetailView): + template_name = "posts/entry_detail.txt" |