diff options
Diffstat (limited to 'app/posts')
-rw-r--r-- | app/posts/admin.py | 2 | ||||
-rw-r--r-- | app/posts/build.py | 13 | ||||
-rw-r--r-- | app/posts/models.py | 6 | ||||
-rw-r--r-- | app/posts/templates/posts/trip_detail.html | 37 | ||||
-rw-r--r-- | app/posts/templates/posts/trip_list.html | 2 | ||||
-rw-r--r-- | app/posts/urls/trip_urls.py | 12 | ||||
-rw-r--r-- | app/posts/views/trip_views.py | 18 |
7 files changed, 72 insertions, 18 deletions
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 %} +<main class="archive-wrapper"> + <figure class="large-top-image"> + <a href="{{object.get_absolute_url}}" title="{{object.title}}">{%with image=object.featured_image%} + <img style="margin:0;" sizes="(max-width: 960px) 100vw" + srcset="{{image.get_srcset}}" + src="{{image.get_src}}" + alt="{{image.alt}} photographed by {% if image.photo_credit_source %}{{image.photo_credit_source}}{%else%}luxagraf{%endif%}"> + </a>{%endwith%} + </figure> + <div class="archive-intro"> + <h1 class="list-hed">{{object.title|safe|smartypants|widont}}</h1> + {{object.body_html|safe|smartypants|widont}} + </div> + <h3 class="archive-sans">Stories</h3> + <div class="archive-grid">{% for object in posts %} + <article class="h-entry hentry archive-grid-card" itemscope itemType="http://schema.org/Article"> + <div class="card-image"> + <a href="{{object.get_absolute_url}}" title="{{object.title}}"> + {% include "lib/img_archive.html" with image=object.featured_image %} + </a> + </div> + <h2 class="p-name card-hed-it" itemprop="headline"><a href="{{object.get_absolute_url}}" class="u-url" title="{{object.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.pub_date|date:'c'}}">{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time> + </article> {% endfor %} + </div> + </main> +{%endblock%} + + <p>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 <a href="https://www.darktable.org/usermanual/en/">darktable user manual</a> is very helpful if you're brand new. I also recommend <a href="https://www.youtube.com/user/audio2u">Bruce Williams' darktable videos</a>, and <a href="https://www.youtube.com/user/s7habo/videos">Boris Hajdukovic's videos</a>, which were the inspiration for what you see here.</p> + <p>I'm no expert either, so feel free to hit reply and let me know if I get something wrong.</p> 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 @@ <time class="dt-published published dt-updated card-smcaps" datetime="{{object.date_started|date:'c'}}">{{object.date_started|date:"F Y"}} – {% 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}} + {{object.dek|smartypants|safe}} </span> </p> </article> {% 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 @@ -7,9 +7,19 @@ app_name = "trips" urlpatterns = [ path( + r'<str:slug>', + views.TripDetailView.as_view(), + name="detail" + ), + path( + r'<int:page>/', + 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'] |