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/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 ++++----------- 7 files changed, 72 insertions(+), 18 deletions(-) create mode 100644 app/posts/templates/posts/trip_detail.html (limited to 'app/posts') 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'] -- cgit v1.2.3