From 7ba1f6de4a39d294594dc1e93a58400f6991398f Mon Sep 17 00:00:00 2001 From: luxagraf Date: Sun, 28 May 2023 09:40:10 -0500 Subject: jrnl: finished up trip section --- app/builder/views.py | 5 +++- app/pages/templates/pages/luxagraf/homepage.html | 2 +- app/posts/admin.py | 2 +- app/posts/build.py | 13 +++++++++ app/posts/models.py | 6 +++- app/posts/templates/posts/trip_detail.html | 37 ++++++++++++++++++++++++ app/posts/templates/posts/trip_list.html | 2 +- app/posts/urls/trip_urls.py | 12 +++++++- app/posts/views/trip_views.py | 18 +++--------- config/base_urls.py | 4 ++- templates/admin/index.html | 2 +- 11 files changed, 81 insertions(+), 22 deletions(-) create mode 100644 app/posts/templates/posts/trip_detail.html diff --git a/app/builder/views.py b/app/builder/views.py index 85e7226..bb23686 100644 --- a/app/builder/views.py +++ b/app/builder/views.py @@ -6,7 +6,7 @@ from resume.build import pub_builder, resume_builder from books.build import builder as book_builder from sightings.build import builder as sightings_builder from pages.build import BuildPages, BuildHome -from posts.build import BuildJrnl, BuildFieldNotes, BuildSrc, BuildGuide, BuildEssays, BuildRange, BuildFriends, BuildFilms +from posts.build import BuildJrnl, BuildFieldNotes, BuildSrc, BuildGuide, BuildEssays, BuildRange, BuildFriends, BuildFilms, BuildTrips def do_build(request): section = request.GET.get('id', '') @@ -28,6 +28,9 @@ def do_build(request): elif section == 'films': context = {'message': 'Writing films to Disk'} BuildFilms("posts", "post").build() + elif section == 'trips': + context = {'message': 'Writing trips to Disk'} + BuildTrips("posts", "trip").build() elif section == 'essays': context = {'message': 'Writing essays to Disk'} BuildEssays("posts", "post").build() diff --git a/app/pages/templates/pages/luxagraf/homepage.html b/app/pages/templates/pages/luxagraf/homepage.html index df97ba3..db08c0f 100644 --- a/app/pages/templates/pages/luxagraf/homepage.html +++ b/app/pages/templates/pages/luxagraf/homepage.html @@ -44,7 +44,7 @@

About Luxagraf

- map of travels + map of travels

We’re a family of five living full time in a vintage 1969 Dodge Travco motorhome. We’ve been at it for six years now. Sometimes we break down, which led to this Wired magazine story. People sometimes ask: What's it like for five people to live in a 26ft RV? Why do we live this way?

If you're curious, read through the journal. If you like it, sign up for the private mailing list, Friends of a Long Year. You can also sign up to get a postcard from us on the road. Yes. Seriously. Or you might prefer to subscribe to the RSS feed.

diff --git a/app/posts/admin.py b/app/posts/admin.py index ea1d8a4..196e6b3 100644 --- a/app/posts/admin.py +++ b/app/posts/admin.py @@ -43,7 +43,7 @@ class PostAdmin(OSMGeoAdmin): ('Entry', { 'fields': ( ('title', 'short_title'), - 'subtitle', + ('subtitle', 'trip'), 'body_markdown', ('pub_date', 'status', 'post_type'), ('slug', 'enable_comments',), diff --git a/app/posts/build.py b/app/posts/build.py index 7f5dc7b..e5dc1ed 100644 --- a/app/posts/build.py +++ b/app/posts/build.py @@ -163,3 +163,16 @@ class BuildFilms(BuildNew): paginate_by=30 ) self.build_detail_view() + + +class BuildTrips(BuildNew): + + def get_model_queryset(self): + return self.model.objects.all() + + def build(self): + self.build_list_view( + base_path=reverse("trips:list"), + paginate_by=30 + ) + self.build_detail_view() diff --git a/app/posts/models.py b/app/posts/models.py index 7322881..93d686a 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -41,6 +41,7 @@ def get_upload_path(self, filename): class Trip(models.Model): title = models.CharField(max_length=300) subtitle = models.CharField(max_length=200, blank=True) + dek = models.TextField(null=True, blank=True) slug = models.SlugField() body_markdown = models.TextField() body_html = models.TextField(blank=True) @@ -49,12 +50,15 @@ class Trip(models.Model): 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): + def __str__(self): return self.title class Meta: ordering = ('-order',) + def get_absolute_url(self): + return reverse('trips:detail', kwargs={"slug": self.slug}) + def save(self, *args, **kwargs): created = self.pk is None if not created: diff --git a/app/posts/templates/posts/trip_detail.html b/app/posts/templates/posts/trip_detail.html new file mode 100644 index 0000000..82bd5e3 --- /dev/null +++ b/app/posts/templates/posts/trip_detail.html @@ -0,0 +1,37 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% block pagetitle %}Luxagraf | Range {% endblock %} +{% block metadescription %}A weekly photo, developed.{% endblock %} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=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%} + {%endwith%} +
+
+

{{object.title|safe|smartypants|widont}}

+ {{object.body_html|safe|smartypants|widont}} +
+

Stories

+
{% for object in posts %} + {% endfor %} +
+
+{%endblock%} + +

If you're not familiar, darktable is open source raw image developer. It's free, you can download a copy for Linux, macOS, or Windows. The darktable user manual is very helpful if you're brand new. I also recommend Bruce Williams' darktable videos, and Boris Hajdukovic's videos, which were the inspiration for what you see here.

+

I'm no expert either, so feel free to hit reply and let me know if I get something wrong.

diff --git a/app/posts/templates/posts/trip_list.html b/app/posts/templates/posts/trip_list.html index 9fa2495..f8d6450 100644 --- a/app/posts/templates/posts/trip_list.html +++ b/app/posts/templates/posts/trip_list.html @@ -24,7 +24,7 @@

- {{object.body_html|smartypants|safe}} + {{object.dek|smartypants|safe}}

{% endfor %} diff --git a/app/posts/urls/trip_urls.py b/app/posts/urls/trip_urls.py index 91d3c33..7e9c95f 100644 --- a/app/posts/urls/trip_urls.py +++ b/app/posts/urls/trip_urls.py @@ -6,10 +6,20 @@ from ..views import trip_views as views app_name = "trips" urlpatterns = [ + path( + r'', + views.TripDetailView.as_view(), + name="detail" + ), + path( + r'/', + views.TripListView.as_view(), + name="list" + ), path( r'', views.TripListView.as_view(), {'page':1}, - name="trip-list" + name="list" ), ] diff --git a/app/posts/views/trip_views.py b/app/posts/views/trip_views.py index 0079652..5753069 100644 --- a/app/posts/views/trip_views.py +++ b/app/posts/views/trip_views.py @@ -17,22 +17,12 @@ class TripListView(PaginatedListView): template_name = "posts/trips_list.html" class TripDetailView(LuxDetailView): - model = Post + model = Trip slug_field = "slug" + template_name = "posts/trip_detail.html" - 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 + context = super(TripDetailView, self).get_context_data(**kwargs) + context['posts'] = Post.objects.filter(status__exact=1,trip=self.object) 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'] diff --git a/config/base_urls.py b/config/base_urls.py index e684e3f..b5e0f1e 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -52,6 +52,8 @@ urlpatterns = [ 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')), #path(r'review/', include('posts.urls.review_urls')), #re_path(r'^review/$', RedirectView.as_view(url='/reviews/')), @@ -59,8 +61,8 @@ urlpatterns = [ #path(r'guide/', include('posts.urls.guide_urls')), #re_path(r'^guide/$', RedirectView.as_view(url='/guides/')), #path(r'guides/', include('posts.urls.guide_urls', namespace='guide-list')), - path(r'essay/', include('posts.urls.essay_urls')), re_path(r'^essay/$', RedirectView.as_view(url='/essays/')), + path(r'essay/', include('posts.urls.essay_urls')), 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')), diff --git a/templates/admin/index.html b/templates/admin/index.html index e2285f8..91678f6 100644 --- a/templates/admin/index.html +++ b/templates/admin/index.html @@ -49,7 +49,7 @@ td, th {