summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/posts/migrations/0021_alter_post_post_type.py18
-rw-r--r--app/posts/models.py4
-rw-r--r--app/posts/templates/posts/film_detail.html115
-rw-r--r--app/posts/templates/posts/film_list.html22
-rw-r--r--app/posts/urls/film_urls.py24
-rw-r--r--app/posts/urls/friends_urls.py20
-rw-r--r--app/posts/views/film_views.py51
-rw-r--r--app/posts/views/friends_views.py1
8 files changed, 243 insertions, 12 deletions
diff --git a/app/posts/migrations/0021_alter_post_post_type.py b/app/posts/migrations/0021_alter_post_post_type.py
new file mode 100644
index 0000000..c05c6e7
--- /dev/null
+++ b/app/posts/migrations/0021_alter_post_post_type.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.2.1 on 2023-05-06 11:49
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('posts', '0020_remove_post_issue'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='post',
+ name='post_type',
+ field=models.IntegerField(choices=[(0, 'range'), (1, 'review'), (2, 'essay'), (3, 'src'), (4, 'jrnl'), (5, 'field note'), (6, 'guide'), (7, 'film')], default=4),
+ ),
+ ]
diff --git a/app/posts/models.py b/app/posts/models.py
index 9697f27..1dafa1a 100644
--- a/app/posts/models.py
+++ b/app/posts/models.py
@@ -46,7 +46,7 @@ class PostType(models.IntegerChoices):
JRNL = 4, ('jrnl')
FIELD_NOTE = 5, ('field note')
GUIDE = 6, ('guide')
- FRIENDS = 7, ('friends')
+ FILM = 7, ('film')
class Post(models.Model):
@@ -104,6 +104,8 @@ class Post(models.Model):
return self.title
def get_absolute_url(self):
+ if self.post_type == PostType.FILM:
+ return reverse('essays:detail', kwargs={"slug": self.slug})
if self.post_type == PostType.ESSAY:
return reverse('essays:detail', kwargs={"slug": self.slug})
if self.post_type == PostType.RANGE:
diff --git a/app/posts/templates/posts/film_detail.html b/app/posts/templates/posts/film_detail.html
new file mode 100644
index 0000000..42d06a2
--- /dev/null
+++ b/app/posts/templates/posts/film_detail.html
@@ -0,0 +1,115 @@
+{% extends 'base.html' %}
+{% load typogrify_tags %}
+{% load comments %}
+{%block htmlclass%}class="detail single"{%endblock%}
+{% block pagetitle %}{{object.title|title|smartypants|safe}} - by Scott Gilbertson{% endblock %}
+
+{% block metadescription %}{% autoescape on %}{{object.meta_description|striptags|safe}}{% endautoescape %}{% endblock %}{%block extrahead%}
+ <link rel="canonical" href="https://luxagraf.net{{object.get_absolute_url}}" />
+{% if object.has_code %} <link rel="stylesheet" href="/media/src/solarized.css" type="text/css" media="screen"/>{%endif %}
+{%endblock%}
+{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %}
+{% block primary %}<main>
+ <article class="h-entry hentry entry-content content" itemscope itemType="http://schema.org/BlogPosting">
+ <header id="header" class="post-header">
+ <h1 class="p-name post-title" itemprop="headline">{{object.title|smartypants|safe}}</h1>
+ {% if object.subtitle %}<h2 class="post-subtitle">{{object.subtitle|smartypants|safe}}</h2>{%endif%}
+ <div class="post-dateline">
+ {% if object.originally_published_by %}<h4 class="post-source">Originally Published By: <a href="{{object.originally_published_by_url}}" title="View {{object.title}} on {{object.originally_published_by}}">{{object.originally_published_by}}</a></h4>{%endif%}
+ {% if object.location %}<div class="p-location h-adr adr post-location" itemprop="contentLocation" itemscope itemtype="http://schema.org/Place">
+ <span class="h-adr" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">{% if object.location.country_name == "United States" %}
+ <span class="p-locality locality" itemprop="addressLocality">{{object.location.name|smartypants|safe}}</span>, <span class="p-region region">{{object.location.state_name|safe}}</span><span class="p-country-name" itemprop="addressCountry"></span>{%else%}
+ <span class="p-region" itemprop="addressRegion">{{object.location.name|smartypants|safe}}</span>, <span class="p-country-name country-name"><span itemprop="addressCountry">{{object.location.country_name|safe}}</span></span>{%endif%}
+ </span>
+ </div>{%endif%}
+ <time class="dt-published published dt-updated post-date" datetime="{{object.pub_date|date:'c'}}" itemprop="datePublished">{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time>
+ <span class="hide" itemprop="author" itemscope itemtype="http://schema.org/Person">by <a class="p-author h-card" href="/about"><span itemprop="name">Scott Gilbertson</span></a></span>
+ </div>
+ </header>
+ <div class="e-content entry-content post-body" itemprop="articleBody">
+ {% if object.prologue_html %}<div class="post-afterward ">
+ {{object.prologue_html|smartypants|safe}}
+ </div><hr />{%endif%}
+ {{object.body_html|safe|smartypants}}
+ {% if object.epilogue_html %}<div class="post-afterward">
+ {{object.epilogue_html|smartypants|safe}}
+ </div>{%endif%}
+ </div>
+ {%if wildlife or object.field_notes.all or object.books.all %}<div class="entry-footer">{%if wildlife %}
+ <aside id="wildlife">
+ <h3>Fauna and Flora</h3>
+ {% regroup wildlife by ap.apclass.get_kind_display as wildlife_list %}
+ <ul>
+ {% for object_list in wildlife_list %}
+ <li class="grouper">{{object_list.grouper}}<ul>
+ {% for object in object_list.list %}
+ <li>{%if object.ap.body_markdown%}<a href="{% url 'sightings:detail' object.ap.slug %}">{{object}}</a>{%else%}{{object}}{%endif%} </li>
+ {% endfor %}</ul>
+ {% endfor %}</ul>
+ </aside>
+ {% endif %}{%if object.field_notes.all %}
+ <aside {% if wildlife %}class="margin-left-none" {%endif%}id="field_notes">
+ <h3>Field Notes</h3>
+ <ul>{% for obj in object.field_notes.all %}
+ <li><a href="{% url 'fieldnotes:detail' year=obj.pub_date.year month=obj.pub_date|date:"m" slug=obj.slug %}">{{obj}}</a></li>
+ {% endfor %}</ul>
+ </aside>{% endif %}
+ {%if object.books.all %}
+ <aside id="recommended-reading" {%if object.field_notes.all and wildlife %}class="rr-clear{%endif%}" >
+ <h3>Recommended Reading</h3>
+ <ul>{% for obj in object.books.all %}
+ <li><a href="{% url 'books:detail' slug=obj.slug %}"><img src="{{obj.get_small_image_url}}" /></a></li>
+ {% endfor %}</ul>
+ </aside>{% endif %}
+ </div>{%endif%}
+ </article>
+ </main>
+ {% if object.related.all %}<div class="article-afterward related">
+ <div class="related-bottom">
+ <h6 class="hedtinycaps">You might also enjoy</h6>
+ <div class="archive-grid-quad">{% for object in related %}
+ <div class="archive-grid-card archive-grid-card-simple" itemscope itemtype="https://schema.org/Article">
+ <a href="{{object.get_absolute_url}}" title="{{object.title}}">
+ <div class="card-image-tiny">
+ {% if object.featured_image %}
+ {% include "lib/img_archive.html" with image=object.featured_image nolightbox=True %}
+ {%endif%}
+ </div>
+ <h4 class="p-name card-hed" itemprop="headline">{% if object.title %}{{object.title|safe|smartypants|widont}}{% else %}{{object.common_name}}{%endif%}</h4>
+ <p class="p-author author hide" itemprop="author"><span class="byline-author" itemscope itemtype="https://schema.org/Person"><span itemprop="name">Scott Gilbertson</span></span></p>
+ <span class="card-smcaps">
+ {% if object.location %}<span class="p-location h-adr adr card-location" itemprop="contentLocation" itemscope itemtype="https://schema.org/Place">
+ {% if object.location.country_name == "United States" %}{{object.location.state_name}}{%else%}{{object.location.country_name}}{%endif%}
+ </span>{%endif%}
+ {% if object.location and object.model_name.model != 'page' %}&ndash;{%endif%}
+ {% if object.model_name.model != 'page' %}<time class="dt-published published dt-updated" datetime="{{object.pub_date|date:'c'}}"><span>{{object.pub_date|date:" Y"}}</span></time>{%endif%}
+ </span>
+ </a>
+ </div>
+ {% endfor %}</div>
+ </div>
+ </div>{%endif%}
+ {% comment %} <div class="mailing-list--wrapper">
+ <h5>If you enjoyed this, you should join the mailing&nbsp;list&hellip;</h5>
+ {% include 'mailing_list.html' %}
+ </div> {% endcomment %}
+ {% if object.enable_comments %}
+{% get_comment_count for object as comment_count %}
+{%if comment_count > 0 %}
+<div class="comment-wrapper">
+<p class="comments-header">{{comment_count}} Comment{{ comment_count|pluralize }}</p>
+{% render_comment_list for object %}
+{%endif%}
+<div class="comment-form-wrapper {%if comment_count > 0%}comment-form-border{%endif%}">
+{% render_comment_form for object %}
+</div>
+{% else %}
+<p class="comments--header" style="text-align: center">Sorry, comments have been disabled for this post.</p>
+</div>
+{%endif%}
+</div>
+{% endblock %}
+{% block js %}
+<script src="/media/js/detail.min.js"></script>
+{{ block.super }}
+{%endblock%}
diff --git a/app/posts/templates/posts/film_list.html b/app/posts/templates/posts/film_list.html
new file mode 100644
index 0000000..7a68058
--- /dev/null
+++ b/app/posts/templates/posts/film_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 class="archive-wrapper">
+ <div class="archive-intro">
+ <h1 class="archive-sans">Films</h1>
+ <p><em>Être fort pour être utile</em></p>
+ <p>Films about paddleboarding, hiking, repair, tools, birding, walking, living well, and other bric-à-brac. Please, enjoy.</p>
+ </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/urls/film_urls.py b/app/posts/urls/film_urls.py
new file mode 100644
index 0000000..872d3f4
--- /dev/null
+++ b/app/posts/urls/film_urls.py
@@ -0,0 +1,24 @@
+from django.urls import path, re_path
+
+from ..views import film_views as views
+
+app_name = "film"
+
+urlpatterns = [
+ path(
+ r'<str:slug>',
+ views.FilmDetailView.as_view(),
+ name="detail"
+ ),
+ path(
+ r'<int:page>/',
+ views.FilmListView.as_view(),
+ name="list"
+ ),
+ path(
+ r'',
+ views.FilmListView.as_view(),
+ {'page':1},
+ name="list"
+ ),
+]
diff --git a/app/posts/urls/friends_urls.py b/app/posts/urls/friends_urls.py
index b7f7608..ca68ca0 100644
--- a/app/posts/urls/friends_urls.py
+++ b/app/posts/urls/friends_urls.py
@@ -6,16 +6,16 @@ from ..views import friends_views as views
app_name = "range"
urlpatterns = [
- path(
- r'feed.xml',
- views.FriendsRSSFeedView(),
- name="feed"
- ),
- path(
- r'<int:issue>/<str:slug>',
- views.FriendsDetailView.as_view(),
- name="friends-detail"
- ),
+ # path(
+ # r'feed.xml',
+ # views.FriendsRSSFeedView(),
+ # name="feed"
+ # ),
+ # path(
+ # r'<int:issue>/<str:slug>',
+ # views.FriendsDetailView.as_view(),
+ # name="friends-detail"
+ # ),
path(
r'',
views.FriendsListView.as_view(),
diff --git a/app/posts/views/film_views.py b/app/posts/views/film_views.py
new file mode 100644
index 0000000..3122240
--- /dev/null
+++ b/app/posts/views/film_views.py
@@ -0,0 +1,51 @@
+from django.views.generic import ListView
+from django.views.generic.detail import DetailView
+from django.contrib.syndication.views import Feed
+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 FilmListView(PaginatedListView):
+ model = Post
+ template_name = "posts/film_list.html"
+
+ def get_queryset(self):
+ queryset = super(FilmListView, self).get_queryset()
+ return queryset.filter(site__domain='luxagraf.net').filter(post_type__in=[PostType.FILM]).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(FilmListView, self).get_context_data(**kwargs)
+ context['breadcrumbs'] = ('Film',)
+ return context
+
+
+class FilmDetailView(LuxDetailView):
+ model = Post
+ slug_field = "slug"
+
+ def get_queryset(self):
+ queryset = super(FilmDetailView, self).get_queryset()
+ return queryset.select_related('location').prefetch_related('field_notes')
+
+ def get_context_data(self, **kwargs):
+ context = super(FilmDetailView, 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
+ return context
+
+ def get_template_names(self):
+ obj = self.get_object()
+ return ["posts/film_detail.html"]
+
diff --git a/app/posts/views/friends_views.py b/app/posts/views/friends_views.py
index 3d6ea8d..c83ca36 100644
--- a/app/posts/views/friends_views.py
+++ b/app/posts/views/friends_views.py
@@ -29,7 +29,6 @@ class FriendsListView(PaginatedListView):
"""
model = Post
template_name = "posts/friends_list.html"
- queryset = Post.objects.filter(post_type=PostType.FRIENDS,status=1).order_by('-pub_date')
def get_context_data(self, **kwargs):
context = super(FriendsListView, self).get_context_data(**kwargs)