diff options
author | luxagraf <sng@luxagraf.net> | 2020-11-11 22:39:19 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2020-11-11 22:39:19 -0500 |
commit | d16c597d1e4e52ab1df1c77bda54445437bac5c0 (patch) | |
tree | 30b8d52cb3c874ad7656be08d1295529353a97db /app/unused_apps/fieldnotes | |
parent | ef37adba510d3f18fe23f7bc34071c70df21a191 (diff) |
cleaned up Posts Admin and added field_notes
Diffstat (limited to 'app/unused_apps/fieldnotes')
-rw-r--r-- | app/unused_apps/fieldnotes/__init__.py | 0 | ||||
-rw-r--r-- | app/unused_apps/fieldnotes/admin.py | 38 | ||||
-rw-r--r-- | app/unused_apps/fieldnotes/build.py | 36 | ||||
-rw-r--r-- | app/unused_apps/fieldnotes/migrations/0001_initial.py | 37 | ||||
-rw-r--r-- | app/unused_apps/fieldnotes/migrations/0002_auto_20190303_1222.py | 25 | ||||
-rw-r--r-- | app/unused_apps/fieldnotes/migrations/__init__.py | 0 | ||||
-rw-r--r-- | app/unused_apps/fieldnotes/models.py | 113 | ||||
-rw-r--r-- | app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_archive_list_date.html | 43 | ||||
-rw-r--r-- | app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_detail.html | 95 | ||||
-rw-r--r-- | app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_list.html | 49 | ||||
-rw-r--r-- | app/unused_apps/fieldnotes/urls.py | 39 | ||||
-rw-r--r-- | app/unused_apps/fieldnotes/views.py | 37 |
12 files changed, 512 insertions, 0 deletions
diff --git a/app/unused_apps/fieldnotes/__init__.py b/app/unused_apps/fieldnotes/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/unused_apps/fieldnotes/__init__.py diff --git a/app/unused_apps/fieldnotes/admin.py b/app/unused_apps/fieldnotes/admin.py new file mode 100644 index 0000000..838063d --- /dev/null +++ b/app/unused_apps/fieldnotes/admin.py @@ -0,0 +1,38 @@ +from django.contrib import admin +from django.contrib.contenttypes.admin import GenericTabularInline + +from .models import FieldNote +from utils.widgets import LGEntryForm, OLAdminBase +from utils.util import get_latlon + + +@admin.register(FieldNote) +class NoteAdmin(OLAdminBase): + form = LGEntryForm + prepopulated_fields = {"slug": ('title',)} + list_display = ('title', 'slug', 'pub_date', 'location') + fieldsets = ( + ('Note', { + 'fields': ( + ('title', 'note_type'), + 'subtitle', + 'body_markdown', + 'slug', + ('pub_date', 'status'), + 'point' + ), + 'classes': ( + 'show', + 'extrapretty', + 'wide' + ) + } + ), + ) + lat, lon = get_latlon() + default_lon = lon + default_lat = lat + default_zoom = 10 + + class Media: + js = ('image-loader.js', 'next-prev-links.js') diff --git a/app/unused_apps/fieldnotes/build.py b/app/unused_apps/fieldnotes/build.py new file mode 100644 index 0000000..4c5c83b --- /dev/null +++ b/app/unused_apps/fieldnotes/build.py @@ -0,0 +1,36 @@ +import os +from django.urls import reverse +from builder.base import BuildNew + + +class BuildNotes(BuildNew): + + def build(self): + self.build_detail_view() + self.build_list_view( + base_path=reverse("fieldnotes:list"), + paginate_by=24 + ) + self.build_year_view("fieldnotes:list_year") + self.build_month_view("fieldnotes:list_month") + + def get_model_queryset(self): + return self.model.objects.all() + + def build_detail_view(self): + ''' + write out all the expenses for each trip + ''' + for obj in self.get_model_queryset(): + url = obj.get_absolute_url() + path, slug = os.path.split(url) + path = '%s/' % path + # write html + response = self.client.get(url) + print(path, slug) + self.write_file(path, response.content, filename=slug) + + +def builder(): + j = BuildNotes("fieldnotes", "fieldnote") + j.build() diff --git a/app/unused_apps/fieldnotes/migrations/0001_initial.py b/app/unused_apps/fieldnotes/migrations/0001_initial.py new file mode 100644 index 0000000..cec67fb --- /dev/null +++ b/app/unused_apps/fieldnotes/migrations/0001_initial.py @@ -0,0 +1,37 @@ +# Generated by Django 2.1.7 on 2019-03-03 12:13 + +import django.contrib.gis.db.models.fields +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('locations', '0017_auto_20190217_1849'), + ] + + operations = [ + migrations.CreateModel( + name='FieldNote', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(blank=True, max_length=250)), + ('subtitle', models.CharField(blank=True, max_length=250)), + ('slug', models.SlugField(blank=True, unique_for_date='pub_date')), + ('pub_date', models.DateTimeField(default=django.utils.timezone.now)), + ('body_html', models.TextField(blank=True)), + ('body_markdown', models.TextField(verbose_name='Note')), + ('point', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)), + ('status', models.IntegerField(choices=[(0, 'Draft'), (1, 'Published')], default=1)), + ('location', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='locations.Location')), + ], + options={ + 'get_latest_by': 'pub_date', + 'ordering': ('-pub_date',), + }, + ), + ] diff --git a/app/unused_apps/fieldnotes/migrations/0002_auto_20190303_1222.py b/app/unused_apps/fieldnotes/migrations/0002_auto_20190303_1222.py new file mode 100644 index 0000000..c0e352e --- /dev/null +++ b/app/unused_apps/fieldnotes/migrations/0002_auto_20190303_1222.py @@ -0,0 +1,25 @@ +# Generated by Django 2.1.7 on 2019-03-03 12:22 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('photos', '0018_auto_20161130_1218'), + ('fieldnotes', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='fieldnote', + name='featured_image', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='photos.LuxImage'), + ), + migrations.AddField( + model_name='fieldnote', + name='note_type', + field=models.IntegerField(choices=[(0, 'Note'), (1, 'Photo')], default=0), + ), + ] diff --git a/app/unused_apps/fieldnotes/migrations/__init__.py b/app/unused_apps/fieldnotes/migrations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/unused_apps/fieldnotes/migrations/__init__.py diff --git a/app/unused_apps/fieldnotes/models.py b/app/unused_apps/fieldnotes/models.py new file mode 100644 index 0000000..c14ba80 --- /dev/null +++ b/app/unused_apps/fieldnotes/models.py @@ -0,0 +1,113 @@ +import re +from django import forms +from django.contrib.gis.db import models +from django.utils import timezone +from django.urls import reverse +from django.conf import settings +from django.contrib.sitemaps import Sitemap + +from locations.models import Location, CheckIn +from photos.models import LuxImage +from utils.util import render_images, parse_image, markdown_to_html, extract_main_image + + +def render_images(s): + s = re.sub('<img(.*)/>', parse_image, s) + return s + + +class FieldNote(models.Model): + title = models.CharField(max_length=250, blank=True) + subtitle = models.CharField(max_length=250, blank=True) + slug = models.SlugField(unique_for_date='pub_date', blank=True) + pub_date = models.DateTimeField(default=timezone.now) + body_html = models.TextField(blank=True) + body_markdown = models.TextField('Note') + point = models.PointField(blank=True, null=True) + location = models.ForeignKey(Location, on_delete=models.CASCADE, blank=True, null=True) + PUB_STATUS = ( + (0, 'Draft'), + (1, 'Published'), + ) + status = models.IntegerField(choices=PUB_STATUS, default=1) + NOTE_TYPE = ( + (0, 'Note'), + (1, 'Photo'), + ) + note_type = models.IntegerField(choices=NOTE_TYPE, default=0) + featured_image = models.ForeignKey(LuxImage, on_delete=models.SET_NULL, blank=True, null=True) + + class Meta: + ordering = ('-pub_date',) + get_latest_by = 'pub_date' + + def __str__(self): + return self.title + + 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 + + @property + def longitude(self): + '''Get the site's longitude.''' + return round(self.point.x, 2) + + @property + def latitude(self): + '''Get the site's latitude.''' + return round(self.point.y, 2) + + @property + def get_previous_published(self): + return self.get_previous_by_pub_date() + + @property + def get_next_published(self): + return self.get_next_by_pub_date() + + @property + def get_previous_admin_url(self): + n = self.get_previous_by_pub_date() + return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[n.id] ) + + @property + def get_next_admin_url(self): + model = apps.get_model(app_label=self._meta.app_label, model_name=self._meta.model_name) + try: + return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[self.get_next_by_pub_date().pk] ) + except model.DoesNotExist: + return '' + + def save(self, *args, **kwargs): + md = render_images(self.body_markdown) + self.body_html = markdown_to_html(md) + if not self.point: + self.point = CheckIn.objects.latest().point + try: + self.location = Location.objects.filter(geometry__contains=self.point).get() + except Location.DoesNotExist: + raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL)) + if not self.id: + self.pub_date = timezone.now() + self.date_last_updated = timezone.now() + self.featured_image = extract_main_image(self.body_markdown) + super(FieldNote, self).save() + + +class FieldNoteSitemap(Sitemap): + changefreq = "never" + priority = 0.7 + protocol = "https" + + def items(self): + return FieldNote.objects.filter(status=1) + + def lastmod(self, obj): + return obj.pub_date diff --git a/app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_archive_list_date.html b/app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_archive_list_date.html new file mode 100644 index 0000000..5d6865f --- /dev/null +++ b/app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_archive_list_date.html @@ -0,0 +1,43 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load html5_datetime %} +{% block pagetitle %} Field Notes | luxagraf {% endblock %} +{% block metadescription %} Rough notes and sketches from the field {% endblock %} +{%block bodyid%}id="field-notes"{%endblock%} + +{% block primary %} + <ul class="bl" id="breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> + <li><a href="/" title="luxagraf homepage" itemprop="url"><span itemprop="title">Home</span></a> → </li> + <li>{% if month or year %}<a href="{% url 'fieldnotes:list' %}">Field Notes</a> →{%else%}Field Notes{%endif%}</li> + <li>{% if not month %}{{year|date:"Y"}}{%else%}<a href="/field-notes/{{month|date:"Y"}}/">{{month|date:"Y"}}</a> →{%endif%}</li> + {% if month %}<li itemprop="title">{{month|date:"F"}}</li>{% endif %} + </ul> + <main role="main" id="essay-archive" class="essay-archive archive-list"> + <div class="essay-intro"> + <h2>Field Notes {% if month or year %}{% if month %} from {{month|date:"F"}} {{month|date:"Y"}}{%else%} from {{year|date:"Y"}}{%endif%}{%endif%}</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 few people read it.</p> + </div> + <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"> + <a href="{{object.get_absolute_url}}"> + {% if object.featured_image %}<div class="circle-img-wrapper"><img src="{{object.featured_image.get_thumbnail_url}}" alt="{{object.featured_image.alt}}" /></div>{%endif%} + <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%} + </a> + {% if object.location %}<h4 class="p-location h-adr post-location" itemprop="geo" itemscope itemtype="http://data-vocabulary.org/Geo"> + <span class="p-locality">{{object.location.name|smartypants|safe}}</span>, + <span class="p-region">{{object.location.state_name}}</span>, + <span class="p-country-name">{{object.location.country_name}}</span> + <data class="p-latitude" value="{{object.latitude}}"></data> + <data class="p-longitude" value="{{object.longitude}}"></data> + </h4>{% endif %} + </li> + {%endif%}{%endfor%}</ul> + </main> + +{% endblock %} + + + diff --git a/app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_detail.html b/app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_detail.html new file mode 100644 index 0000000..d1c648b --- /dev/null +++ b/app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_detail.html @@ -0,0 +1,95 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load html5_datetime %} +{% load month_number_to_name %} +{% block pagetitle %}{{object.title|title|smartypants|safe}} - Luxagraf, Field Notes{% endblock %} + +{% block metadescription %}{{object.body_html|striptags|safe|truncatewords:30}}{% endblock %} +{%block extrahead%} + <link rel="canonical" href="http://luxagraf.net{{object.get_absolute_url}}" /> + <meta name="ICBM" content="{{object.latitude}}, {{object.longitude}}" /> + <meta name="geo.position" content="{{object.latitude}}; {{object.longitude}}" /> + <meta name="geo.placename" content="{% if object.location.country.name == "United States" %}{{object.location.name|smartypants|safe}}, {{object.state.name}}{%else%}{{object.location.name|smartypants|safe}}, {{object.country.name}}{%endif%}"> + <meta name="geo.region" content="{{object.country.iso2}}{%if object.state.code != '' %}-{{object.state.code}}{%endif%}"> +{%endblock%} +{% block bodyid %}class="notes--permalin detail" id="archive-{% if month %}{{month|month_number_to_name}}{%endif%}{{year}}"{%endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %}<main role="main"> + <article class="h-entry hentry {% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %} post--article--double{%endif%}{%endwith%}" itemscope itemType="http://schema.org/BlogPosting"> + <header id="header" class="post-header {% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %}post--header--double{%endif%}{%endwith%}"> + <h1 class="p-name entry-title post-title" itemprop="headline">{%if object.template_name == 1 or object.template_name == 3 %}{{object.title|smartypants|safe}}{%else%}{{object.title|smartypants|safe}}{%endif%}</h1> + {% if object.subtitle %}<h2 class="post-subtitle">{{object.subtitle|smartypants|safe}}</h2>{%endif%} + <div class="post-linewrapper"> + {% if object.location %}<div class="p-location h-adr adr post-location" itemprop="contentLocation" itemscope itemtype="http://schema.org/Place"> + <h3 class="h-adr" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">{% if object.location.country_name == "United States" %}<span class="p-locality locality" itemprop="addressLocality">{{object.location.name|smartypants|safe}}</span>, <a class="p-region region" href="/jrnl/united-states/" title="travel writing from the United States">{{object.location.state_name|safe}}</a>, <span class="p-country-name" itemprop="addressCountry">U.S.</span>{%else%}<span class="p-region" itemprop="addressRegion">{{object.location.name|smartypants|safe}}</span>, <a class="p-country-name country-name" href="/jrnl/{{object.location.country_slug}}/" title="travel writing from {{object.location.country_name}}"><span itemprop="addressCountry">{{object.location.country_name|safe}}</span></a>{%endif%}</h3> + – <a href="" onclick="showMap({{object.latitude}}, {{object.longitude}}, { type:'point', lat:'{{object.latitude}}', lon:'{{object.longitude}}'}); return false;" title="see a map">Map</a> + </div>{%endif%} + <time class="dt-published published dt-updated post-date" datetime="{{object.pub_date|date:'c'}}" itemprop="datePublished">{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time> + <span class="hide" itemprop="author" itemscope itemtype="http://schema.org/Person">by <a class="p-author h-card" href="/about"><span itemprop="name">Scott Gilbertson</span></a></span> + </div> + </header> + <div class="e-content"> + {{object.body_html|safe|smartypants}} + </div> + <span class="p-author h-card"> + <data class="p-name" value="Scott Gilbertson"></data> + <data class="u-url" value="https://luxagraf.net/"></data> + </span> + <footer> + {%comment%}<p class="note--date"> + <a class="u-url" href="{{object.get_absolute_url}}" rel="bookmark"><time class="dt-published" datetime="{{object.pub_date|html5_datetime}}">{{object.pub_date|date:"F j, Y"}}</time></a> + </p>{%endcomment%} + {% comment %} {% if object.twitter_id %} + <ul class="note--actions"> + <li><a rel="syndication" class="u-syndication" href="https://twitter.com/luxagraf/status/{{object.twitter_id}}">View on Twitter</a></li> + <li> + <indie-action do="reply" with="{{SITE_URL}}{{object.get_absolute_url}}"><a href="https://twitter.com/intent/tweet?in_reply_to={{object.twitter_id}}">Reply</a></indie-action> + </li> + <li> + <indie-action do="post" with="{{SITE_URL}}{{object.get_absolute_url}}"> + <a href="https://twitter.com/intent/retweet?tweet_id={{object.twitter_id}}">Retweet</a> + </indie-action> + </li> + <li> + <indie-action do="bookmark" with="{{SITE_URL}}{{object.get_absolute_url}}"> + <a href="https://twitter.com/intent/favorite?tweet_id={{object.twitter_id}}">Favourite</a> + </indie-action> + </li> + </ul>{% endif %}{% endcomment %} + </footer> + + + {% with object.get_next_published as next %} + {% with object.get_previous_published as prev %} + <nav id="page-navigation"> + <ul>{% if prev%} + <li rel="previous" id="next"><span class="bl">Previous:</span> + <a href="{{ prev.get_absolute_url }}" rel="prev" title=" {{prev.title}}">{{prev.title|safe}}</a> + </li>{%endif%}{% if next%} + <li rel="next" id="prev"><span class="bl">Next:</span> + <a href="{{ next.get_absolute_url }}" rel="next" title=" {{next.title}}">{{next.title|safe}}</a> + </li>{%endif%} + </ul> + </nav>{%endwith%}{%endwith%} + </article> +</main> +{% endblock %} + +{% block js %} +<script> +document.addEventListener("DOMContentLoaded", function(event) { + var leaflet = document.createElement('script'); + leaflet.src = "/media/js/leaflet-master/leaflet-mod.js"; + document.body.appendChild(leaflet); + leaflet.onload = function(){ + var detail = document.createElement('script'); + detail.src = "/media/js/detail.min.js"; + document.body.appendChild(detail); + detail.onload = function(){ + createMap(); + var open = false; + } + } +}); +</script> +{%endblock%} diff --git a/app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_list.html b/app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_list.html new file mode 100644 index 0000000..37cd0ca --- /dev/null +++ b/app/unused_apps/fieldnotes/templates/fieldnotes/fieldnote_list.html @@ -0,0 +1,49 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load get_next %} +{% load html5_datetime %} +{% load pagination_tags %} +{% block pagetitle %} Field Notes | luxagraf {% endblock %} +{% block metadescription %}Rough notes and sketches from the field {% endblock %} +{%block bodyid%}id="field-notes"{%endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% 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-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.get_object_type == "fieldnote" %} + {% with next_element=object_list|next:forloop.counter0 %} + {% with prev_element=object_list|previous:forloop.counter0 %} + <li class="h-entry hentry {% if not next_element.get_object_type == "fieldnote"%}note-pad-bottom{%endif%} {% if not prev_element.get_object_type == "fieldnote"%}note-pad-top{%endif%}" 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="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%} + </a> + {% if object.location %}<h4 class="p-location h-adr post-location" itemprop="geo" itemscope itemtype="http://data-vocabulary.org/Geo"> + <span class="p-locality">{{object.location.name|smartypants|safe}}</span>, + <span class="p-region">{{object.location.state_name}}</span>, + <span class="p-country-name">{{object.location.country_name}}</span> + <data class="p-latitude" value="{{object.latitude}}"></data> + <data class="p-longitude" value="{{object.longitude}}"></data> + </h4>{% endif %} + </li>{%endwith%}{%endwith%}{%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 %} + </nav> +{% endblock %} + + + diff --git a/app/unused_apps/fieldnotes/urls.py b/app/unused_apps/fieldnotes/urls.py new file mode 100644 index 0000000..85ee710 --- /dev/null +++ b/app/unused_apps/fieldnotes/urls.py @@ -0,0 +1,39 @@ +from django.urls import path, re_path + +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(), + {'page': 1}, + name="list" + ), + path( + r'<int:page>/', + views.FieldNoteListView.as_view(), + name="list" + ), + path( + r'<int:year>/<int:month>/<str:slug>.txt', + views.FieldNoteDetailViewTXT.as_view(), + name="detail-txt" + ), + path( + r'<int:year>/<int:month>/<str:slug>', + views.FieldNoteDetailView.as_view(), + name="detail" + ), + path( + r'<int:year>/<int:month>/', + views.FieldNoteMonthArchiveView.as_view(month_format='%m'), + name="list_month" + ), +] diff --git a/app/unused_apps/fieldnotes/views.py b/app/unused_apps/fieldnotes/views.py new file mode 100644 index 0000000..9b49cc0 --- /dev/null +++ b/app/unused_apps/fieldnotes/views.py @@ -0,0 +1,37 @@ +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 + + +class FieldNoteListView(PaginatedListView): + model = FieldNote + """ + Return a list of Notes in reverse chronological order + """ + queryset = FieldNote.objects.filter(status=1).order_by('-pub_date') + + +class FieldNoteDetailView(LuxDetailView): + model = FieldNote + slug_field = "slug" + + +class FieldNoteDetailViewTXT(FieldNoteDetailView): + template_name = "jrnl/entry.txt" + + +class FieldNoteYearArchiveView(YearArchiveView): + queryset = FieldNote.objects.filter(status=1) + date_field = "pub_date" + template_name = "fieldnotes/fieldnote_archive_list_date.html" + make_object_list = True + + +class FieldNoteMonthArchiveView(MonthArchiveView): + queryset = FieldNote.objects.filter(status=1) + date_field = "pub_date" + make_object_list = True + template_name = "fieldnotes/fieldnote_archive_list_date.html" |