summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2023-05-26 09:53:56 -0500
committerluxagraf <sng@luxagraf.net>2023-05-26 09:53:56 -0500
commitccf5541458db1cc4c1b46de95ee877ac67a0684a (patch)
treee9719ece7fdef9c89b666c2253015531a7e5e999 /app
parent28a613a8efda914eb5abb1d3d5551aa8be83a620 (diff)
posts: added the concept of trips and a template for displaying them
Diffstat (limited to 'app')
-rw-r--r--app/posts/admin.py3
-rw-r--r--app/posts/migrations/0023_trip_order.py18
-rw-r--r--app/posts/models.py3
-rw-r--r--app/posts/templates/posts/trip_list.html36
-rw-r--r--app/posts/urls/trip_urls.py15
-rw-r--r--app/posts/views/trip_views.py38
6 files changed, 111 insertions, 2 deletions
diff --git a/app/posts/admin.py b/app/posts/admin.py
index f9d679b..ea1d8a4 100644
--- a/app/posts/admin.py
+++ b/app/posts/admin.py
@@ -100,13 +100,14 @@ class PostAdmin(OSMGeoAdmin):
@admin.register(Trip)
class TripAdmin(OSMGeoAdmin):
form = LGEntryForm
- list_display = ('title', )
+ list_display = ('title', 'order', 'date_started' )
prepopulated_fields = {'slug': ('title',)}
search_fields = ('title',)
fieldsets = (
('Region', {
'fields': (
'title',
+ 'order',
'subtitle',
'body_markdown',
'slug',
diff --git a/app/posts/migrations/0023_trip_order.py b/app/posts/migrations/0023_trip_order.py
new file mode 100644
index 0000000..75c643a
--- /dev/null
+++ b/app/posts/migrations/0023_trip_order.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.2.1 on 2023-05-24 10:56
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('posts', '0022_trip_post_trip'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='trip',
+ name='order',
+ field=models.PositiveIntegerField(blank=True, null=True, verbose_name='order'),
+ ),
+ ]
diff --git a/app/posts/models.py b/app/posts/models.py
index fb0ea46..7322881 100644
--- a/app/posts/models.py
+++ b/app/posts/models.py
@@ -47,12 +47,13 @@ class Trip(models.Model):
date_started = models.DateField()
date_ended = models.DateField()
featured_image = models.ForeignKey(LuxImage, on_delete=models.SET_NULL, null=True, blank=True)
+ order = models.PositiveIntegerField("order", null=True, blank=True)
def __str_(self):
return self.title
class Meta:
- ordering = ('-date_started',)
+ ordering = ('-order',)
def save(self, *args, **kwargs):
created = self.pk is None
diff --git a/app/posts/templates/posts/trip_list.html b/app/posts/templates/posts/trip_list.html
new file mode 100644
index 0000000..02e4b67
--- /dev/null
+++ b/app/posts/templates/posts/trip_list.html
@@ -0,0 +1,36 @@
+{% extends 'base.html' %}
+{% load typogrify_tags %}
+{% load pagination_tags %}
+{% block pagetitle %}Luxagraf - Trips {% endblock %}
+{% block metadescription %}Adventures {% endblock %}
+{%block bodyid%}id="travels" class="archive"{%endblock%}
+{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %}
+{% block primary %}<main class="archive-wrapper">
+ <h1 class="hide">Adventures</h1>
+ <div class="archive-intro">
+ <h1 class="list-hed">Trips</h1>
+ <p>When we set out on them, we didn't think of any of these as "trips", but in hindsight, it does make a handy way of organizing things.</p>
+ <p>If you'd like to follow along, join the <em><a href="/friends/">Friends of a Long Year</a></em> newsletter, which will deliver some stories in your inbox.</p>
+ </div>
+ <div class="archive-grid">{% autopaginate object_list 24 %} {% for object in object_list %}
+ <article class="h-entry hentry archive-grid-card" itemscope itemType="http://schema.org/Article">
+ <div class="card-image">
+ {%comment%}<a href="{{object.get_absolute_url}}" title="{{object.title}}">
+ {% include "lib/img_archive.html" with image=object.featured_image %}
+ </a>{%endcomment%}
+ </div>
+ <h2 class="p-name card-hed-it" itemprop="headline"><a href="{{object.get_absolute_url}}" class="u-url" title="">{{object.title|safe|smartypants|widont}}</a></h2>
+ <p class="p-author author hide" itemprop="author"><span class="byline-author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Scott Gilbertson</span></span></p>
+ <time class="dt-published published dt-updated card-smcaps" datetime="{{object.date_started|date:'c'}}">{{object.date_started|date:"F Y"}} &ndash; {% if object.title == "The Big Blue Bus"%}<a href="/jrnl/">present</a>{%else%}{{object.date_ended|date:"F Y"}}{%endif%}</time>
+ <p class="card-summary card-dek">
+ <span class="p-summary" itemprop="description">
+ {{object.body_html|smartypants|safe}}
+ </span>
+ </p>
+ </article> {% endfor %}
+ </div>
+ </main>
+ <nav aria-label="page navigation" class="pagination">
+ {% paginate %}
+ </nav>
+{% endblock %}
diff --git a/app/posts/urls/trip_urls.py b/app/posts/urls/trip_urls.py
new file mode 100644
index 0000000..91d3c33
--- /dev/null
+++ b/app/posts/urls/trip_urls.py
@@ -0,0 +1,15 @@
+from django.urls import path, re_path, include
+from django.views.generic.base import RedirectView
+
+from ..views import trip_views as views
+
+app_name = "trips"
+
+urlpatterns = [
+ path(
+ r'',
+ views.TripListView.as_view(),
+ {'page':1},
+ name="trip-list"
+ ),
+]
diff --git a/app/posts/views/trip_views.py b/app/posts/views/trip_views.py
new file mode 100644
index 0000000..0079652
--- /dev/null
+++ b/app/posts/views/trip_views.py
@@ -0,0 +1,38 @@
+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, Trip
+
+
+class TripListView(PaginatedListView):
+ """
+ Return a list of Entries in reverse chronological order
+ """
+ model = Trip
+ template_name = "posts/trips_list.html"
+
+class TripDetailView(LuxDetailView):
+ model = Post
+ slug_field = "slug"
+
+ def get_queryset(self):
+ queryset = super(PostDetailView, self).get_queryset()
+ return queryset.select_related('location').prefetch_related('field_notes')
+
+ def get_context_data(self, **kwargs):
+ context = super(PostDetailView, 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/%s_detail.html" % obj.get_post_type_display(), 'posts/post_detail.html']