summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/posts/build.py7
-rw-r--r--app/posts/models.py9
-rw-r--r--app/posts/templates/posts/range_list.html2
-rw-r--r--app/posts/urls/essay_urls.py13
-rw-r--r--app/posts/views/craft_views.py2
-rw-r--r--app/posts/views/essay_views.py23
-rw-r--r--app/posts/views/range_views.py2
-rw-r--r--config/base_urls.py12
-rw-r--r--templates/base.html4
9 files changed, 56 insertions, 18 deletions
diff --git a/app/posts/build.py b/app/posts/build.py
index 1b21666..23d67d5 100644
--- a/app/posts/build.py
+++ b/app/posts/build.py
@@ -5,7 +5,7 @@ from builder.base import BuildNew
from itertools import chain
from django.conf import settings
-from .models import PostType
+from .models import PostType, PostTopic
class BuildSrc(BuildNew):
@@ -122,6 +122,11 @@ class BuildEssays(BuildNew):
base_path=reverse("essay-list:list"),
paginate_by=50
)
+ for t in PostTopic.labels:
+ self.build_list_view(
+ base_path=reverse("essay-list:category-detail", kwargs={'topic':t}),
+ paginate_by=50
+ )
self.build_detail_view()
diff --git a/app/posts/models.py b/app/posts/models.py
index 2ce7d96..c6ce559 100644
--- a/app/posts/models.py
+++ b/app/posts/models.py
@@ -76,7 +76,8 @@ class PostType(models.IntegerChoices):
FIELD_NOTE = 5, ('field note')
GUIDE = 6, ('guide')
FILM = 7, ('film')
- HOWTO = 8, ('how to')
+ CRAFT = 8, ('craft')
+
class PostTopic(models.IntegerChoices):
SPIRIT = 0, ('spirit')
@@ -86,7 +87,7 @@ class PostTopic(models.IntegerChoices):
class Post(models.Model):
site = models.ForeignKey(Site, on_delete=models.SET_NULL, default=1, null=True)
- title = models.CharField(max_length=200)
+ title = models.CharField(max_length=200,help_text="49 characters is ideal for essays")
short_title = models.CharField(max_length=200, blank=True, null=True)
subtitle = models.CharField(max_length=200, blank=True)
slug = models.SlugField(unique_for_date='pub_date')
@@ -135,12 +136,12 @@ class Post(models.Model):
if self.post_type == PostType.FILM:
return reverse('film:detail', kwargs={"slug": self.slug})
if self.post_type == PostType.ESSAY:
- return reverse('essays:detail', kwargs={"slug": self.slug})
+ return reverse('essays:detail', kwargs={"cat": self.get_post_topic_display(), "slug": self.slug})
if self.post_type == PostType.SRC:
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:
+ if self.post_type == PostType.CRAFT:
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})
diff --git a/app/posts/templates/posts/range_list.html b/app/posts/templates/posts/range_list.html
index 09ad56d..c6c16d3 100644
--- a/app/posts/templates/posts/range_list.html
+++ b/app/posts/templates/posts/range_list.html
@@ -8,7 +8,7 @@
<h1 class="list-hed">Subscribe to <em>Range</em></h1>
<iframe target='_parent' style="border:none; background:white; width:100%;" title="embedded form for subscribing the the Friends of a Long Year newsletter" src="{% url 'lttr:subscribe' slug='range' %}"></iframe>
<h2 class="list-subhed">A weekly post, ranging.</h2>
- <p><em>Range</em> is a weekly mailing about life and how to live it. We talk about the intersection of <a href="/essays/">Spirit</a>, <a href="/how-to/">Craft</a>, and <a href="/reviews/">Tools</a>. Browse the archive below. If you like what you see, join us.</p>
+ <p><em>Range</em> is a weekly mailing about life and how to live it. We talk about the intersection of <a href="/essays/spirit/">Spirit</a>, <a href="/essays/craft/">Craft</a>, and <a href="/essays/tools/">Tools</a>. Browse the archive below. If you like what you see, join us.</p>
<h3><i>Être fort pour être utile</i></h3>
</div>
<h3 class="archive-sans archive-hed">Archive</h3>
diff --git a/app/posts/urls/essay_urls.py b/app/posts/urls/essay_urls.py
index 7eb872d..90a087c 100644
--- a/app/posts/urls/essay_urls.py
+++ b/app/posts/urls/essay_urls.py
@@ -6,7 +6,18 @@ app_name = "essays"
urlpatterns = [
path(
- r'<str:slug>',
+ r'<str:topic>/<int:page>/',
+ views.EssayCategoryList.as_view(),
+ name="category-detail"
+ ),
+ path(
+ r'<str:topic>/',
+ views.EssayCategoryList.as_view(),
+ {'page':1},
+ name="category-detail"
+ ),
+ path(
+ r'<str:cat>/<str:slug>',
views.EssayDetailView.as_view(),
name="detail"
),
diff --git a/app/posts/views/craft_views.py b/app/posts/views/craft_views.py
index da5f2b1..409e393 100644
--- a/app/posts/views/craft_views.py
+++ b/app/posts/views/craft_views.py
@@ -17,7 +17,7 @@ class CraftListView(PaginatedListView):
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')
+ return queryset.filter(site__domain='luxagraf.net').filter(post_type__in=[PostType.CRAFT]).filter(status__exact=1).order_by('-pub_date').prefetch_related('location').prefetch_related('featured_image')
def get_context_data(self, **kwargs):
'''
diff --git a/app/posts/views/essay_views.py b/app/posts/views/essay_views.py
index 02a1087..3c28834 100644
--- a/app/posts/views/essay_views.py
+++ b/app/posts/views/essay_views.py
@@ -7,7 +7,7 @@ from django.conf import settings
from utils.views import PaginatedListView, LuxDetailView
-from ..models import Post, PostType
+from ..models import Post, PostType, PostTopic
from taxonomy.models import Category
@@ -29,6 +29,27 @@ class EssayListView(PaginatedListView):
return context
+class EssayCategoryList(PaginatedListView):
+ model = Post
+ template_name = "posts/essay_list.html"
+
+ def get_queryset(self):
+ queryset = super(EssayCategoryList, self).get_queryset()
+ for t in PostTopic:
+ if t.label == self.kwargs['topic']:
+ topic = t
+ return queryset.filter(site__domain='luxagraf.net').filter(post_type__in=[PostType.ESSAY],post_topic=topic).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(EssayCategoryList, self).get_context_data(**kwargs)
+ context['breadcrumbs'] = ('Essay',)
+ return context
+
+
class EssayDetailView(LuxDetailView):
model = Post
slug_field = "slug"
diff --git a/app/posts/views/range_views.py b/app/posts/views/range_views.py
index f196e5e..dc09cee 100644
--- a/app/posts/views/range_views.py
+++ b/app/posts/views/range_views.py
@@ -24,7 +24,7 @@ class RangeListView(PaginatedListView):
"""
model = Post
template_name = "posts/range_list.html"
- queryset = Post.objects.filter(post_type__in=[PostType.ESSAY,PostType.FILM,PostType.HOWTO,PostType.REVIEW],status=1).order_by('-pub_date')
+ queryset = Post.objects.filter(post_type__in=[PostType.ESSAY,PostType.FILM,PostType.CRAFT,PostType.REVIEW],status=1).order_by('-pub_date')
def get_context_data(self, **kwargs):
context = super(RangeListView, self).get_context_data(**kwargs)
diff --git a/config/base_urls.py b/config/base_urls.py
index 96b1082..bf623df 100644
--- a/config/base_urls.py
+++ b/config/base_urls.py
@@ -54,9 +54,9 @@ urlpatterns = [
re_path(r'^trip/$', RedirectView.as_view(url='/trips/')),
path(r'trip/', include('posts.urls.trip_urls')),
path(r'trips/', include('posts.urls.trip_urls', namespace='trips')),
- path(r'review/', include('posts.urls.review_urls')),
- re_path(r'^review/$', RedirectView.as_view(url='/reviews/')),
- path(r'reviews/', include('posts.urls.review_urls', namespace='review-list')),
+ #path(r'review/', include('posts.urls.review_urls')),
+ #re_path(r'^review/$', RedirectView.as_view(url='/reviews/')),
+ #path(r'reviews/', include('posts.urls.review_urls', namespace='review-list')),
re_path(r'^guide/$', RedirectView.as_view(url='/guides/')),
path(r'guides/', include('posts.urls.guide_urls', namespace='guides')),
path(r'guide/', include('posts.urls.guide_urls')),
@@ -65,9 +65,9 @@ urlpatterns = [
path(r'essays/', include('posts.urls.essay_urls', namespace='essay-list')),
path(r'range/', include('posts.urls.range_urls', namespace='range')),
path(r'friends/', include('posts.urls.friends_urls', namespace='friends')),
- path(r'how-to/', include('posts.urls.craft_urls')),
- re_path(r'^how-to/$', RedirectView.as_view(url='/how-to/')),
- path(r'how-tos/', include('posts.urls.craft_urls', namespace='craft')),
+ #path(r'how-to/', include('posts.urls.craft_urls')),
+ #re_path(r'^how-to/$', RedirectView.as_view(url='/how-to/')),
+ #path(r'how-tos/', include('posts.urls.craft_urls', namespace='craft')),
path(r'book-notes/', include('books.urls')),
#path(r'people/', include('people.urls')),
path(r'dialogues/', include('sightings.urls', namespace='sightings')),
diff --git a/templates/base.html b/templates/base.html
index 0636f22..c63152d 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -28,8 +28,8 @@
</div>
<nav>
<a class="nav-item smcaps" href="{% url "jrnl:list" %}" title="Stories of life on the road.">Friends</a>
- <a class="nav-item smcaps" href="{% url "range:range-list" %}" title="Essays">Range</a>
- <a class="nav-item smcaps" href="{% url "guides:guide-list" %}" title="Guides">Guides</a>
+ <a class="nav-item smcaps" href="{% url "range:range-list" %}" title="Life and how to live it">Range</a>
+ <!--<a class="nav-item smcaps" href="{% url "guides:guide-list" %}" title="Guides">Guides</a> -->
<a class="nav-item smcaps" href="/about" title="About Scott">About</a>
<!--
<a class="nav-item smcaps" href="/guides/" title="Useful Stuff">Guides</a> -->