diff options
author | luxagraf <sng@luxagraf.net> | 2024-07-24 16:37:26 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2024-07-24 16:37:26 -0500 |
commit | 88e0f0ac2bd5874256bf7e84fa460965bacdd761 (patch) | |
tree | c79a3cc81a2a85be809605b9042b00ca32db095c | |
parent | 074ec1e21a7bfa867bbb2c35057c19b5cfc375c4 (diff) |
general update
-rw-r--r-- | app/books/admin.py | 5 | ||||
-rw-r--r-- | app/books/models.py | 5 | ||||
-rw-r--r-- | app/media/admin.py | 8 | ||||
-rw-r--r-- | app/media/models.py | 17 | ||||
-rw-r--r-- | app/normalize/models.py | 8 | ||||
-rw-r--r-- | app/pages/templates/pages/homepage.html | 8 | ||||
-rw-r--r-- | app/pages/views.py | 2 | ||||
-rw-r--r-- | app/posts/admin.py | 4 | ||||
-rw-r--r-- | app/posts/models.py | 19 | ||||
-rw-r--r-- | app/utils/util.py | 6 | ||||
-rw-r--r-- | app/utils/views.py | 6 | ||||
-rw-r--r-- | app/utils/widgets.py | 17 | ||||
-rw-r--r-- | templates/base.html | 7 |
13 files changed, 66 insertions, 46 deletions
diff --git a/app/books/admin.py b/app/books/admin.py index 3faa14e..a00c896 100644 --- a/app/books/admin.py +++ b/app/books/admin.py @@ -1,10 +1,9 @@ from django.contrib import admin from .models import Book -from orderable.admin import OrderableAdmin @admin.register(Book) -class BookAdmin(OrderableAdmin): - list_display = ('title', 'admin_thumbnail', 'isbn', 'author_last_name', 'sort_order_display') +class BookAdmin(admin.ModelAdmin): + list_display = ('title', 'admin_thumbnail', 'isbn', 'author_last_name',) search_fields = ['title', 'body_markdown'] class Media: diff --git a/app/books/models.py b/app/books/models.py index 0e17621..d4410fb 100644 --- a/app/books/models.py +++ b/app/books/models.py @@ -9,9 +9,6 @@ from django.apps import apps from django.utils.html import format_html from django.conf import settings -# allows for manually ordering items: -from orderable.models import Orderable - from media.utils import resize_image from utils.util import markdown_to_html @@ -20,7 +17,7 @@ def get_upload_path(self, filename): return "wandrenbooks.net/media/images/book-covers/%s" % (filename) -class Book(Orderable): +class Book(models.Model): title = models.CharField(max_length=200) author_last_name = models.CharField(max_length=200) author_first_name = models.CharField(max_length=200) diff --git a/app/media/admin.py b/app/media/admin.py index 50eb879..a9b60f0 100644 --- a/app/media/admin.py +++ b/app/media/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin from django import forms -from django.contrib.gis.admin import OSMGeoAdmin +from django.contrib.gis.admin import GISModelAdmin from .models import LuxImage, LuxGallery, LuxImageSize, LuxVideo from django.shortcuts import render from django.contrib.admin import helpers @@ -8,17 +8,17 @@ from django.http import HttpResponseRedirect @admin.register(LuxImageSize) -class LuxImageSizeAdmin(OSMGeoAdmin): +class LuxImageSizeAdmin(GISModelAdmin): list_display = ('name','slug', 'width', 'height', 'quality') @admin.register(LuxVideo) -class LuxVideoAdmin(OSMGeoAdmin): +class LuxVideoAdmin(GISModelAdmin): pass @admin.register(LuxImage) -class LuxImageAdmin(OSMGeoAdmin): +class LuxImageAdmin(GISModelAdmin): list_display = ('pk', 'admin_thumbnail', 'pub_date', 'caption') list_filter = ('pub_date',) search_fields = ['title', 'caption', 'alt'] diff --git a/app/media/models.py b/app/media/models.py index dcf7ccc..b5b4e06 100644 --- a/app/media/models.py +++ b/app/media/models.py @@ -5,6 +5,7 @@ from pathlib import Path from PIL import Image from django.core.exceptions import ValidationError +from django.core.files import File from django.contrib.gis.db import models from django.contrib.sitemaps import Sitemap from django.db.models.signals import post_save @@ -25,6 +26,22 @@ from .readexif import readexif from .utils import resize_image +def add_mp4(filepath, luxvideo): + full_filepath = "/home/lxf/sites/django/luxagraf.net/"+filepath + v = open(full_filepath, "rb") + django_file = File(v) + video = LuxVideo.objects.get(title=luxvideo) + video.video_mp4.save(filepath, django_file, save=True) + + +def add_webm(filepath, luxvideo): + full_filepath = "/home/lxf/sites/django/luxagraf.net/"+filepath + v = open(full_filepath, "rb") + django_file = File(v) + video = LuxVideo.objects.get(title=luxvideo) + video.video_webm.save(filepath, django_file, save=True) + + def get_upload_path(self, filename): return "images/original/%s/%s" % (datetime.datetime.today().strftime("%Y"), filename) diff --git a/app/normalize/models.py b/app/normalize/models.py index f45f90b..8333681 100644 --- a/app/normalize/models.py +++ b/app/normalize/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.apps import apps from django.contrib.contenttypes.models import ContentType @@ -7,6 +8,7 @@ class RelatedPost(models.Model): entry_id = models.IntegerField() title = models.CharField(max_length=200) slug = models.CharField(max_length=50) + post_type = models.CharField(null=True, blank=True, max_length=50) pub_date = models.DateTimeField('Date published') class Meta: @@ -14,4 +16,8 @@ class RelatedPost(models.Model): get_latest_by = 'pub_date' def __str__(self): - return "%s - %s" % (self.model_name, self.title) + if self.model_name.name == 'post': + p = apps.get_model("posts", "Post").objects.get(id=self.entry_id) + return "%s - %s" % (p.get_post_type_display(), self.title) + else: + return "%s - %s" % (self.model_name, self.title) diff --git a/app/pages/templates/pages/homepage.html b/app/pages/templates/pages/homepage.html index 31aa32e..ed67f80 100644 --- a/app/pages/templates/pages/homepage.html +++ b/app/pages/templates/pages/homepage.html @@ -30,11 +30,11 @@ <section class="full-one-col"> <h2 class="homepage-section-header">The Wandren Code</h2> <ol> - <li>I will be brave and courageous</li> - <li>I will strengthen my body</li> - <li>I will help my family</li> + <li>I Will Be Brave and Courageous</li> + <li>I Will Strengthen My Mind and Will</li> + <li>I Will Strengthen My Body</li> </ol> - <a href="{% url 'pages:detail' 'code' %}" class="btn" title="Read the Wandren code">Read the full code</a> + <a href="{% url 'pages:detail' 'code' %}" class="btn" title="Read the Wandren code">Read the Full Code →</a> </section> <section class="full-two-col"> <div class="col-one"> diff --git a/app/pages/views.py b/app/pages/views.py index 5262806..9226dbe 100644 --- a/app/pages/views.py +++ b/app/pages/views.py @@ -36,5 +36,3 @@ class HomePageList(DetailView): context = super(HomePageList, self).get_context_data(**kwargs) #context['object_list'] = Post.objects.filter(post_type=PostType.JRNL).filter(status__exact=1).order_by('-pub_date').exclude().select_related('location').select_related('featured_image')[1:9] return context - - diff --git a/app/posts/admin.py b/app/posts/admin.py index 27ec145..bed6b1d 100644 --- a/app/posts/admin.py +++ b/app/posts/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin from django import forms -from django.contrib.gis.admin import OSMGeoAdmin +from django.contrib.gis.admin import GISModelAdmin from django.contrib.contenttypes.admin import GenericStackedInline from utils.widgets import AdminImageWidget, LGEntryForm @@ -10,7 +10,7 @@ from utils.util import get_latlon @admin.register(Post) -class PostAdmin(OSMGeoAdmin): +class PostAdmin(GISModelAdmin): form = LGEntryForm def get_queryset(self, request): diff --git a/app/posts/models.py b/app/posts/models.py index 37c4c9b..7430bf3 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -63,9 +63,18 @@ class Post(models.Model): (1, 'Published'), ) status = models.IntegerField(choices=PUB_STATUS, default=0) - featured_image = models.ForeignKey(LuxImage, on_delete=models.CASCADE, null=True, blank=True) - featured_audio = models.ForeignKey(LuxAudio, on_delete=models.CASCADE, null=True, blank=True) + featured_image = models.ForeignKey(LuxImage, on_delete=models.SET_NULL, null=True, blank=True) + featured_audio = models.ForeignKey(LuxAudio, on_delete=models.SET_NULL, null=True, blank=True) + TEMPLATES = ( + (0, 'single'), + (1, 'double'), + (2, 'single-dark'), + (3, 'double-dark'), + (4, 'single-black'), + (5, 'double-black'), + ) post_type = models.IntegerField(choices=PostType.choices, default=PostType.JRNL) + template_name = models.IntegerField(choices=TEMPLATES, default=0) has_video = models.BooleanField(blank=True, default=False) has_code = models.BooleanField(blank=True, default=False) disclaimer = models.BooleanField(blank=True, default=False) @@ -171,9 +180,9 @@ class Post(models.Model): prods = render_products(md) print(self.title) self.body_html = markdown_to_html(prods) - if self.epilogue_html: + if self.epilogue_markdown: self.epilogue_html = markdown_to_html(self.epilogue_markdown) - if self.prologue_html: + if self.prologue_markdown: self.prologue_html = markdown_to_html(self.prologue_markdown) self.has_video = parse_video(self.body_html) #if created and not self.featured_image: @@ -229,7 +238,7 @@ def cache_gravatar(sender, comment, **kwargs): @receiver(post_save, sender=Post) def post_save_events(sender, update_fields, created, instance, **kwargs): - related, created = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id, pub_date=instance.pub_date, title=instance.title, slug=instance.slug) + related, created = RelatedPost.objects.get_or_create(model_name=instance.get_content_type(), entry_id = instance.id, pub_date=instance.pub_date, title=instance.title, slug=instance.slug, post_type=instance.get_post_type_display()) post_save.disconnect(post_save_events, sender=Post) instance.save() post_save.connect(post_save_events, sender=Post) diff --git a/app/utils/util.py b/app/utils/util.py index d9b2318..32a9838 100644 --- a/app/utils/util.py +++ b/app/utils/util.py @@ -36,8 +36,10 @@ def convertll(lat, lon): def get_latlon(): loc = apps.get_model('locations', 'LuxCheckIn').objects.latest() - lat_converted, lon_converted = convertll(loc.lat, loc.lon) - return lat_converted, lon_converted + # as of django 5, this isn't necessary anymore: + #lat_converted, lon_converted = convertll(loc.lat, loc.lon) + lat, lon = loc.point.y, loc.point.x + return lat, lon def extract_main_image(markdown): diff --git a/app/utils/views.py b/app/utils/views.py index b678a33..76f1574 100644 --- a/app/utils/views.py +++ b/app/utils/views.py @@ -14,9 +14,9 @@ from media.models import LuxImage, LuxVideo, LuxAudio BREADCRUMBS = { 'AP':'dialogue', 'Book':'Book Notes', - 'Entry':'Jrnl', 'NewsletterMailing':'lttr', 'LuxImage':'lttr', + 'Sighting':'dialogue' } class PaginatedListView(ListView): @@ -53,16 +53,16 @@ class LuxDetailView(DetailView): ''' # Call the base implementation first to get a context context = super(LuxDetailView, self).get_context_data(**kwargs) - print(self.object._meta.verbose_name_plural) try: context['breadcrumbs'] = (BREADCRUMBS[self.object._meta.label.split(".")[1]],) except KeyError: if self.object._meta.verbose_name_plural == 'posts': if self.object.get_post_type_display() != 'src': context['breadcrumbs'] = (self.object.get_post_type_display()+"s",) + context['crumb_url'] = "/%ss/" % slugify(self.object.get_post_type_display()) else: context['breadcrumbs'] = (self.object.get_post_type_display(),) - context['crumb_url'] = "/%ss/" % slugify(self.object.get_post_type_display()) + context['crumb_url'] = "/%s/" % slugify(self.object.get_post_type_display()) else: context['breadcrumbs'] = (self.object._meta.verbose_name_plural,) try: diff --git a/app/utils/widgets.py b/app/utils/widgets.py index 87b39ec..ffad8b1 100644 --- a/app/utils/widgets.py +++ b/app/utils/widgets.py @@ -1,8 +1,9 @@ import os from django import forms from django.contrib import admin + +from django.contrib.gis.admin import GISModelAdmin from django.contrib.admin.widgets import AdminFileWidget -from django.contrib.gis.admin import OSMGeoAdmin from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _ from django.template.loader import render_to_string @@ -14,6 +15,7 @@ import markdown from bs4 import BeautifulSoup from django.utils.module_loading import import_string +from utils.util import get_latlon class CustomSelectMultiple(SelectMultiple): @@ -130,15 +132,6 @@ class LGEntryFormSmall(forms.ModelForm): } -class OLAdminBase(OSMGeoAdmin): - default_lon = -9285175 - default_lat = 4025046 - default_zoom = 15 - units = True - scrollable = False - map_width = 700 - map_height = 425 - map_template = 'gis/admin/osm.html' - openlayers_url = '/static/admin/js/OpenLayers.js' - +class OLAdminBase(GISModelAdmin): + pass diff --git a/templates/base.html b/templates/base.html index 175e913..e00dd62 100644 --- a/templates/base.html +++ b/templates/base.html @@ -28,7 +28,7 @@ <nav> <a class="nav-item smcaps" href="/bookshop/" title="Buy the Adventures of Lulu and Birdie"><span>Buy the </span>Books</a> <a class="nav-item smcaps" href="{% url 'podcasts:list' 'lulu-birdie' %}" title="Listen to the Podcast"><span>Listen to the </span>Podcast</a> - <a class="nav-item smcaps" href="/friends/" title="Join the Wandren Crew">Join <span>the </span>Crew</a> + <a class="nav-item smcaps" href="/crew/" title="Join the Wandren Crew">Join <span>the </span>Crew</a> </nav> </header> {% block breadcrumbs %}{% endblock %} @@ -37,14 +37,13 @@ {% block disclaimer %}{% endblock%} <footer class="page-footer"> <nav> - <a class="nav-item smcaps" href="/blogroll" title="Sites to inspire you">Blogroll</a> <a class="nav-item smcaps" href="/contact/" title="contact luxagraf">Contact</a> <a class="nav-item smcaps" href="/feed.xml" title="RSS feed">RSS</a> </nav> <p id="license"> © 2020-{% now "Y" %} - <span class="h-card"><a class="p-name u-url" href="https://luxagraf.net/">scott gilbertson</a><data class="p-nickname" value="luxagraf"></data><data class="p-locality" value="Earth"></data><data class="p-region" value="Earth"></data><data class="p-country-name" value="United States"></data></span>. - made with ♥ on earth. + <span class="h-card"><a class="p-name u-url" href="https://luxagraf.net/">libregraf publishing llc</a><data class="p-nickname" value="luxagraf"></data><data class="p-locality" value="United States"></data><data class="p-region" value="United States"></data><data class="p-country-name" value="United States"></data></span>. + made in the USA. </p> </footer> {% block js %}{% endblock%} |