From 21795671955fb4d675b740bba73b4d4f90d37739 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Sun, 10 Mar 2024 09:31:05 -0500 Subject: posts: added template option for photo posts, got rid of some things --- app/posts/admin.py | 15 ++- ...remove_post_short_title_alter_post_post_type.py | 22 ++++ app/posts/migrations/0030_post_template_name.py | 18 +++ .../migrations/0031_alter_post_enable_comments.py | 18 +++ app/posts/models.py | 11 +- app/posts/templates/posts/essay_detail_lt.html | 139 +++++++++++++++++++++ app/posts/urls/essay_urls.py | 6 +- app/posts/urls/range_urls.py | 5 - app/posts/views/essay_views.py | 6 +- app/posts/views/range_views.py | 21 +--- config/base_urls.py | 6 +- 11 files changed, 223 insertions(+), 44 deletions(-) create mode 100644 app/posts/migrations/0029_remove_post_short_title_alter_post_post_type.py create mode 100644 app/posts/migrations/0030_post_template_name.py create mode 100644 app/posts/migrations/0031_alter_post_enable_comments.py create mode 100644 app/posts/templates/posts/essay_detail_lt.html diff --git a/app/posts/admin.py b/app/posts/admin.py index c0081af..d2d1a33 100644 --- a/app/posts/admin.py +++ b/app/posts/admin.py @@ -42,16 +42,15 @@ class PostAdmin(OSMGeoAdmin): fieldsets = ( ('Entry', { 'fields': ( - ('title', 'short_title'), - ('subtitle', 'trip'), + ('title', 'subtitle'), 'body_markdown', - ('pub_date', 'status', 'post_type', 'post_topic'), - ('slug', 'enable_comments',), + ('featured_image', 'pub_date'), + ('dek', 'meta_description'), + ('status', 'post_type', 'post_topic'), + ('slug', "template_name", 'enable_comments'), 'point', - 'dek', - 'meta_description', - ('featured_image','related'), - 'site' + ('related'), + ('site', 'trip'), ), 'classes': ( 'show', diff --git a/app/posts/migrations/0029_remove_post_short_title_alter_post_post_type.py b/app/posts/migrations/0029_remove_post_short_title_alter_post_post_type.py new file mode 100644 index 0000000..a5b98cc --- /dev/null +++ b/app/posts/migrations/0029_remove_post_short_title_alter_post_post_type.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.7 on 2024-03-10 09:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('posts', '0028_alter_post_post_type_alter_post_title'), + ] + + operations = [ + migrations.RemoveField( + model_name='post', + name='short_title', + ), + migrations.AlterField( + model_name='post', + name='post_type', + field=models.IntegerField(choices=[(2, 'essay'), (3, 'src'), (4, 'jrnl'), (5, 'field note')], default=4), + ), + ] diff --git a/app/posts/migrations/0030_post_template_name.py b/app/posts/migrations/0030_post_template_name.py new file mode 100644 index 0000000..9d52571 --- /dev/null +++ b/app/posts/migrations/0030_post_template_name.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-03-10 09:56 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('posts', '0029_remove_post_short_title_alter_post_post_type'), + ] + + operations = [ + migrations.AddField( + model_name='post', + name='template_name', + field=models.IntegerField(choices=[(0, 'Default'), (1, 'Large Top Image')], default=0), + ), + ] diff --git a/app/posts/migrations/0031_alter_post_enable_comments.py b/app/posts/migrations/0031_alter_post_enable_comments.py new file mode 100644 index 0000000..7b6e588 --- /dev/null +++ b/app/posts/migrations/0031_alter_post_enable_comments.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-03-10 10:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('posts', '0030_post_template_name'), + ] + + operations = [ + migrations.AlterField( + model_name='post', + name='enable_comments', + field=models.BooleanField(default=True), + ), + ] diff --git a/app/posts/models.py b/app/posts/models.py index 11ad509..80153e0 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -73,7 +73,6 @@ class PostType(models.IntegerChoices): SRC = 3, ('src') JRNL = 4, ('jrnl') FIELD_NOTE = 5, ('field note') - FILM = 7, ('film') class PostTopic(models.IntegerChoices): @@ -85,7 +84,6 @@ 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,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') prologue_markdown = models.TextField(blank=True, null=True) @@ -98,12 +96,17 @@ class Post(models.Model): meta_description = models.CharField(max_length=256, blank=True) pub_date = models.DateTimeField('Date published') last_updated = models.DateTimeField(auto_now=True) - enable_comments = models.BooleanField(default=False) + enable_comments = models.BooleanField(default=True) PUB_STATUS = ( (0, 'Draft'), (1, 'Published'), ) status = models.IntegerField(choices=PUB_STATUS, default=0) + TEMPLATE_NAMES = ( + (0, 'Default'), + (1, 'Large Top Image'), + ) + template_name = models.IntegerField(choices=TEMPLATE_NAMES, default=0) featured_image = models.ForeignKey(LuxImage, on_delete=models.SET_NULL, null=True, blank=True) post_type = models.IntegerField(choices=PostType.choices, default=PostType.JRNL) post_topic = models.IntegerField(choices=PostTopic.choices, default=PostTopic.SPIRIT) @@ -131,8 +134,6 @@ class Post(models.Model): return self.title def get_absolute_url(self): - 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={"cat": self.get_post_topic_display(), "slug": self.slug}) if self.post_type == PostType.SRC: diff --git a/app/posts/templates/posts/essay_detail_lt.html b/app/posts/templates/posts/essay_detail_lt.html new file mode 100644 index 0000000..3dc8de5 --- /dev/null +++ b/app/posts/templates/posts/essay_detail_lt.html @@ -0,0 +1,139 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load get_image_by_size %} +{%block htmlclass%}{%endblock%} +{% block sitename %} + + {{object.title|safe}} by Scott Gilbertson + {%endblock%} + + {%block extrahead%} + +{%endblock%} +{%block bodyid%}id="essay"{%endblock%} +{% block breadcrumbs %} +{% endblock %} +{% block primary %} +
+
+ {%with image=object.featured_image%} + {{image.alt}} photographed by {% if image.photo_credit_source %}{{image.photo_credit_source}}{%else%}luxagraf{%endif%} + +
+ {{image.location}}, {{image.location.state}}, {{image.location.state.country}} +
+
{%endwith%} +
+
+

{{object.title|smartypants|safe}}

+ {% if object.subtitle %}

{{object.subtitle|smartypants|safe}}

{%endif%} + +
+
+ {{object.body_html|safe|smartypants}} +
+ {%if object.books.all %}
+ + {% with object.get_next_published as next %} + {% with object.get_previous_published as prev %} + {%endwith%}{%endwith%} + + {% if object.related.all %}
+ +
{%endif%} +
+{% endblock %} diff --git a/app/posts/urls/essay_urls.py b/app/posts/urls/essay_urls.py index 90a087c..197e72c 100644 --- a/app/posts/urls/essay_urls.py +++ b/app/posts/urls/essay_urls.py @@ -6,14 +6,14 @@ app_name = "essays" urlpatterns = [ path( - r'//', + r'/', views.EssayCategoryList.as_view(), + {'page':1}, name="category-detail" ), path( - r'/', + r'//', views.EssayCategoryList.as_view(), - {'page':1}, name="category-detail" ), path( diff --git a/app/posts/urls/range_urls.py b/app/posts/urls/range_urls.py index 57d72a7..65638ce 100644 --- a/app/posts/urls/range_urls.py +++ b/app/posts/urls/range_urls.py @@ -6,11 +6,6 @@ from ..views import range_views as views app_name = "range" urlpatterns = [ - path( - r'feed.xml', - views.RangeRSSFeedView(), - name="feed" - ), path( r'', views.RangeListView.as_view(), diff --git a/app/posts/views/essay_views.py b/app/posts/views/essay_views.py index 76a022c..41fbc03 100644 --- a/app/posts/views/essay_views.py +++ b/app/posts/views/essay_views.py @@ -71,7 +71,11 @@ class EssayDetailView(LuxDetailView): def get_template_names(self): obj = self.get_object() - return ["posts/essay_detail.html"] + if obj.template_name == 1: + t = "posts/essay_detail_lt.html" + else: + t = "posts/essay_detail.html" + return t class EssayDetailViewTXT(EssayDetailView): diff --git a/app/posts/views/range_views.py b/app/posts/views/range_views.py index b358051..7ef5054 100644 --- a/app/posts/views/range_views.py +++ b/app/posts/views/range_views.py @@ -20,30 +20,13 @@ from sightings.models import Sighting class RangeListView(PaginatedListView): """ - Return a list of Newsletter posts in reverse chronological order + Return a list of Essay posts in reverse chronological order """ model = Post template_name = "posts/range_list.html" - queryset = Post.objects.filter(post_type__in=[PostType.ESSAY,PostType.FILM],status=1).order_by('-pub_date') + queryset = Post.objects.filter(post_type__in=[PostType.ESSAY],status=1).order_by('-pub_date') def get_context_data(self, **kwargs): context = super(RangeListView, self).get_context_data(**kwargs) context['breadcrumbs'] = ['range',] return context - - -class RangeRSSFeedView(Feed): - title = "Range: A weekly photo, developed" - link = "/range/" - description = "Range: A weekly photo, developed" - description_template = 'feeds/blog_description.html' - - def items(self): - return Post.objects.filter(status__exact=1).filter(post_type=PostType.RANGE).order_by('-pub_date')[:10] - - def item_pubdate(self, item): - """ - Takes an item, as returned by items(), and returns the item's - pubdate. - """ - return item.pub_date diff --git a/config/base_urls.py b/config/base_urls.py index bf623df..9d0a507 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -48,9 +48,9 @@ urlpatterns = [ #path(r'expenses/', include('expenses.urls', namespace='expenses')), path(r'newsletter/', include('lttr.urls')), path(r'photos/', include('media.urls')), - path(r'film/', include('posts.urls.film_urls')), - re_path(r'^film/$', RedirectView.as_view(url='/films/')), - path(r'films/', include('posts.urls.film_urls', namespace='films')), + #path(r'film/', include('posts.urls.film_urls')), + #re_path(r'^film/$', RedirectView.as_view(url='/films/')), + #path(r'films/', include('posts.urls.film_urls', namespace='films')), 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')), -- cgit v1.2.3-70-g09d2