diff options
-rw-r--r-- | app/fieldnotes/models.py | 6 | ||||
-rw-r--r-- | app/fieldnotes/templates/fieldnotes/fieldnote_list.html | 18 | ||||
-rw-r--r-- | app/fieldnotes/urls.py | 10 | ||||
-rw-r--r-- | app/fieldnotes/views.py | 35 | ||||
-rw-r--r-- | design/sass/_archives.scss | 13 |
5 files changed, 65 insertions, 17 deletions
diff --git a/app/fieldnotes/models.py b/app/fieldnotes/models.py index e3cb527..c14ba80 100644 --- a/app/fieldnotes/models.py +++ b/app/fieldnotes/models.py @@ -47,6 +47,9 @@ class FieldNote(models.Model): def get_absolute_url(self): return reverse("fieldnotes:detail", kwargs={"year": self.pub_date.year, "month": self.pub_date.strftime("%m"), "slug": self.slug}) + def get_object_type(self): + return 'fieldnote' + @property def region(self): return self.location.lux_region @@ -94,8 +97,7 @@ class FieldNote(models.Model): if not self.id: self.pub_date = timezone.now() self.date_last_updated = timezone.now() - if self.note_type == 1: - self.featured_image = extract_main_image(self.body_markdown) + self.featured_image = extract_main_image(self.body_markdown) super(FieldNote, self).save() diff --git a/app/fieldnotes/templates/fieldnotes/fieldnote_list.html b/app/fieldnotes/templates/fieldnotes/fieldnote_list.html index 5ee6f06..915d21f 100644 --- a/app/fieldnotes/templates/fieldnotes/fieldnote_list.html +++ b/app/fieldnotes/templates/fieldnotes/fieldnote_list.html @@ -9,14 +9,14 @@ {% block primary %}<main role="main" id="essay-archive" class="essay-archive archive-list"> <div class="essay-intro"> <h2>Field Notes</h2> - <p>Quick notes, sketches and images from the road. This is the semi-orgnized brain dump that comes before the more organized <a href="/jrnl/" title="read the journal">journal entries</a> and <a href="/essays/" title="read essays">essays</a>. If I used social media this is the stuff I'd probably put there, but I prefer to put it here, even if it means a lot fewer people read it.</p> + <p>Quick notes, sketches, and images from the road. This is the semi-organized brain dump that comes before the more organized <a href="/jrnl/" title="read the journal">journal entries</a>. If I used social media this is the stuff I'd probably put there, but I prefer to put it here, even if it means a lot fewer people read it.</p> </div> {% autopaginate object_list 30 %} - <ul class="fancy-archive-list">{% for object in object_list %}{% if object.slug != 'about' %} - <li class="h-entry hentry" itemscope itemType="http://schema.org/Article"> + <ul class="fancy-archive-list">{% for object in object_list %}{% if object.get_object_type == "fieldnote" %} + <li class="h-entry hentry field-note-item" itemscope itemType="http://schema.org/Article"> <a href="{{object.get_absolute_url}}" class="u-url"> {% if object.featured_image %}<div class="circle-img-wrapper"><img src="{{object.featured_image.get_thumbnail_url}}" alt="{{object.featured_image.alt}}" class="u-photo" /></div>{%endif%} - <span class="date dt-published">{{object.pub_date|date:"F d, Y"}}</span> + <span class="datei">Field Note: </span><span class="date dt-published">{{object.pub_date|date:"F d, Y"}}</span> <a href="{{object.get_absolute_url}}"> <h2>{{object.title|safe|smartypants|widont}}</h2> {% if object.subtitle %}<h3 class="p-summary">{{object.subtitle|safe|smartypants|widont}}</h3>{%endif%} @@ -28,8 +28,14 @@ <data class="p-latitude" value="{{object.latitude}}"></data> <data class="p-longitude" value="{{object.longitude}}"></data> </h4>{% endif %} - </li> - {%endif%}{%endfor%}</ul> + </li>{%else%} + <li class="field-photo-item"> + <figure class="daily-figure"> + {% include 'lib/img_picwide.html' with image=object caption=False exif=False is_cluster=False cluster_class='' extra='' %} + <figcaption class="picwide">{{object.location}}, {{object.location.state.country}} – {{object.pub_date|date:"M m, Y"}}</figcaption> + </figure> + </li>{%endif%} + {%endfor%}</ul> </main> <nav aria-label="page navigation" class="pagination"> {% paginate %} diff --git a/app/fieldnotes/urls.py b/app/fieldnotes/urls.py index 85ee710..52fb6fe 100644 --- a/app/fieldnotes/urls.py +++ b/app/fieldnotes/urls.py @@ -5,11 +5,6 @@ from . import views app_name = "field notes" urlpatterns = [ - re_path( - r'(?P<year>[0-9]{4})/$', - views.FieldNoteYearArchiveView.as_view(), - name="list_year" - ), path( r'', views.FieldNoteListView.as_view(), @@ -36,4 +31,9 @@ urlpatterns = [ views.FieldNoteMonthArchiveView.as_view(month_format='%m'), name="list_month" ), + re_path( + r'(?P<year>[0-9]{4})/$', + views.FieldNoteYearArchiveView.as_view(), + name="list_year" + ), ] diff --git a/app/fieldnotes/views.py b/app/fieldnotes/views.py index 9b49cc0..d9d1526 100644 --- a/app/fieldnotes/views.py +++ b/app/fieldnotes/views.py @@ -1,17 +1,44 @@ +from itertools import chain +from operator import attrgetter from django.views.generic.dates import YearArchiveView, MonthArchiveView from django.views.generic.detail import DetailView from utils.views import PaginatedListView, LuxDetailView from .models import FieldNote - +from photos.models import LuxImage class FieldNoteListView(PaginatedListView): - model = FieldNote """ - Return a list of Notes in reverse chronological order + Main Archive of Field Notes, which also includes photo posts """ - queryset = FieldNote.objects.filter(status=1).order_by('-pub_date') + model = FieldNote + template_name = "fieldnotes/fieldnote_list.html" + + def dispatch(self, request, *args, **kwargs): + path = request.path.split('/')[1:-1] + if int(path[-1]) == self.kwargs['page']: + path = "/".join(t for t in path[:-1]) + print(path) + request.page_url = "/" + path + '/%d/' + else: + request.page_url = request.path + '%d/' + request.page = int(self.kwargs['page']) + request.base_path = path + return super(PaginatedListView, self).dispatch(request, *args, **kwargs) + + def get_queryset(self): + """ + Return a list of Notes and Photos combined + in reverse chronological order + """ + qs1 = FieldNote.objects.filter(status=1).order_by('-pub_date').prefetch_related('location') + qs2 = LuxImage.objects.filter(is_public=True, title__startswith="daily_").prefetch_related('sizes').prefetch_related('location') + result_list = sorted( + chain(qs1, qs2), + key=attrgetter('pub_date') + ) + return result_list[:: -1] class FieldNoteDetailView(LuxDetailView): diff --git a/design/sass/_archives.scss b/design/sass/_archives.scss index 48acb43..b55e0aa 100644 --- a/design/sass/_archives.scss +++ b/design/sass/_archives.scss @@ -466,3 +466,16 @@ margin-top: -4px; } } + + +.field-photo-item + .field-note-item { + //make a field note among photos stand out more + margin-top: 10rem !important; + margin-bottom: 10rem !important; + &:before, &:after { + @include faded_line_after; + } +} +.field-photo-item+.field-note-item:before { + margin-bottom: 2.5rem; +} |