diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/sightings/migrations/0016_ap_have_seen.py | 18 | ||||
-rw-r--r-- | app/sightings/models.py | 22 | ||||
-rw-r--r-- | app/sightings/templates/sightings/life-list.html | 23 | ||||
-rw-r--r-- | app/sightings/templates/sightings/not_life_list.html | 19 | ||||
-rw-r--r-- | app/sightings/urls.py | 5 | ||||
-rw-r--r-- | app/sightings/views.py | 26 |
6 files changed, 103 insertions, 10 deletions
diff --git a/app/sightings/migrations/0016_ap_have_seen.py b/app/sightings/migrations/0016_ap_have_seen.py new file mode 100644 index 0000000..663110c --- /dev/null +++ b/app/sightings/migrations/0016_ap_have_seen.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.1 on 2023-09-23 17:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sightings', '0015_sighting_event'), + ] + + operations = [ + migrations.AddField( + model_name='ap', + name='have_seen', + field=models.BooleanField(default=False), + ), + ] diff --git a/app/sightings/models.py b/app/sightings/models.py index dfcde2c..ecf28a2 100644 --- a/app/sightings/models.py +++ b/app/sightings/models.py @@ -63,6 +63,7 @@ class AP(models.Model): body_html = models.TextField(null=True, blank=True) body_markdown = models.TextField(null=True, blank=True) featured_image = models.ForeignKey(LuxImage, on_delete=models.CASCADE, null=True, blank=True) + have_seen = models.BooleanField(default=False) # image = models.FileField(upload_to=get_upload_path, null=True, blank=True, help_text="width of high res is 1360px") # image_credit = models.CharField(max_length=200, blank=True, null=True) @@ -116,15 +117,20 @@ class AP(models.Model): def save(self, *args, **kwargs): if self.pk: - md = render_images(self.body_markdown) - self.body_html = markdown_to_html(md) - main_image = extract_main_image(self.body_markdown) - if main_image: - self.image = main_image - s = LuxImageSize.objects.get(name="featured_jrnl") - self.image.sizes.add(s) - self.image.save() + try: + md = render_images(self.body_markdown) + self.body_html = markdown_to_html(md) + main_image = extract_main_image(self.body_markdown) + if main_image: + self.image = main_image + s = LuxImageSize.objects.get(name="featured_jrnl") + self.image.sizes.add(s) + self.image.save() + except: + pass self.slug = slugify(self.common_name[:50]) + if self.seen == True: + self.have_seen = True super(AP, self).save(*args, **kwargs) diff --git a/app/sightings/templates/sightings/life-list.html b/app/sightings/templates/sightings/life-list.html new file mode 100644 index 0000000..8b11d8e --- /dev/null +++ b/app/sightings/templates/sightings/life-list.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load pagination_tags %} + +{% block pagetitle %}Luxagraf | Birding Life List {% if region %}in {{region.name|title|smartypants|safe}}{%else%}by {{user}}{%endif%}{% if page != "1" %} -- Page {{page}}{%endif%}{% endblock %} +{% block metadescription %}Briding Life List {% if region %} in {{region.name|title|smartypants|safe}}{%else%}by {{user}}{%endif%} Page {{page}}{% endblock %} +{%block bodyid%}id="birds"{%endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %} + <main class="archive-wrapper"> + <div class="archive-intro"> + <h1 class="hide">Birds Life List</h1> + <h4>Current Total: {{object_list|length}}</h4> + <div> + <ul class="archive-list">{% for object in object_list %} + <li class=""><a href="{{object.ap.get_absolute_url}}" title="{{object.ap}}">{{object.ap|safe|smartypants|widont}}</a></li> + {% endfor %}</ul> + </main> +{% endblock %} + + + +{% block js %}<script src="/media/js/hyphenate.min.js" type="text/javascript"></script>{% endblock%} diff --git a/app/sightings/templates/sightings/not_life_list.html b/app/sightings/templates/sightings/not_life_list.html new file mode 100644 index 0000000..c63960e --- /dev/null +++ b/app/sightings/templates/sightings/not_life_list.html @@ -0,0 +1,19 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load pagination_tags %} + +{% block pagetitle %}Luxagraf | Plants and Animals seen {% if region %}in {{region.name|title|smartypants|safe}}{%else%}by {{user}}{%endif%}{% if page != "1" %} -- Page {{page}}{%endif%}{% endblock %} +{% block metadescription %}Plants and Animals seen {% if region %} in {{region.name|title|smartypants|safe}}{%else%}by {{user}}{%endif%} Page {{page}}{% endblock %} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %} + <main class="archive-wrapper"> + <h1 class="hide">Plants and Animals seen {% if region %}in {%if region.name == 'United States'%}the United States{%else%}{{region.name|title|smartypants|safe}}{%endif%}{%else%} by {{user}}{%endif%}</h1> {% for object in object_list %} + <ul class="archive-list"> + <li class="card-hed-smit"><a href="{{object.get_absolute_url}}" title="{{object}}">{{object|safe|smartypants|widont}}</a></li> + </ul> {% endfor %} + </main> +{% endblock %} + + + +{% block js %}<script src="/media/js/hyphenate.min.js" type="text/javascript"></script>{% endblock%} diff --git a/app/sightings/urls.py b/app/sightings/urls.py index 5cb9275..619a269 100644 --- a/app/sightings/urls.py +++ b/app/sightings/urls.py @@ -21,6 +21,11 @@ urlpatterns = [ name='life-list' ), re_path( + r'not-life-list$', + views.NotLifeListView.as_view(), + name='not-life-list' + ), + re_path( r'(?P<page>\d+)/$', views.SightingListView.as_view(), name="list" diff --git a/app/sightings/views.py b/app/sightings/views.py index 1c42fd4..24c341d 100644 --- a/app/sightings/views.py +++ b/app/sightings/views.py @@ -12,16 +12,38 @@ class SightingListView(PaginatedListView): qs_ids = Sighting.objects.order_by('ap__id', '-pub_date').distinct('ap').values_list('id', flat=True) return Sighting.objects.filter(id__in=qs_ids).order_by('-pub_date').prefetch_related('ap') + def get_context_data(self, **kwargs): + context = super(SightingListView, self).get_context_data(**kwargs) + context['breadcrumbs'] = ['dialogues',] + return context + class LifeListView(ListView): - template_name = 'archives/life-list.html' + template_name = 'sightings/life-list.html' def get_queryset(self): return Sighting.objects.filter(ap__apclass__kind=1).order_by('ap__id').distinct('ap') + def get_context_data(self, **kwargs): + context = super(LifeListView, self).get_context_data(**kwargs) + context['breadcrumbs'] = ['dialogues',] + return context + + +class NotLifeListView(ListView): + template_name = 'sightings/not_life_list.html' + + def get_queryset(self): + return AP.objects.filter(apclass__kind=1).filter(have_seen=False) + + def get_context_data(self, **kwargs): + context = super(NotLifeListView, self).get_context_data(**kwargs) + context['breadcrumbs'] = ['dialogues',] + return context + class YearListView(ListView): - template_name = 'archives/life-list.html' + template_name = 'sightings/life-list.html' def get_queryset(self): return Sighting.objects.filter(ap__apclass__kind=1).filter(pub_date__year=self.kwargs['year']).order_by('ap__id').distinct('ap') |