summaryrefslogtreecommitdiff
path: root/app/utils
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2022-12-02 14:16:08 -0600
committerluxagraf <sng@luxagraf.net>2022-12-02 14:16:08 -0600
commit656505098a80e653319236ac302fd6dd9f485b33 (patch)
tree03fe2f552496e2a2b459f5227dc11273d1b94211 /app/utils
parentbf2fa131cba6430ba93f584f4693c3444e0c455f (diff)
reset migrations to zero out some changes (deleting the geodata for
example)
Diffstat (limited to 'app/utils')
-rw-r--r--app/utils/static/image-loader.js10
-rw-r--r--app/utils/util.py6
-rw-r--r--app/utils/views.py35
-rw-r--r--app/utils/widgets.py2
4 files changed, 30 insertions, 23 deletions
diff --git a/app/utils/static/image-loader.js b/app/utils/static/image-loader.js
index 2744251..ca96565 100644
--- a/app/utils/static/image-loader.js
+++ b/app/utils/static/image-loader.js
@@ -13,9 +13,9 @@ function add_images(){
var loop = Number(element.dataset.loopcounter);
if (cur != "") {
if (loop <= 100) {
- console.log(loop);
+ console.log('/photos/data/admin/tn/'+cur+'/');
var request = new XMLHttpRequest();
- request.open('GET', '/photos/luximage/data/admin/tn/'+cur+'/', true);
+ request.open('GET', '/photos/data/admin/tn/'+cur+'/', true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
var data = JSON.parse(request.responseText);
@@ -41,7 +41,11 @@ function add_images(){
}
document.addEventListener("DOMContentLoaded", function(event) {
add_images();
- md = document.forms["entry_form"].elements["body_markdown"];
+ if (document.forms["post_form"]) {
+ md = document.forms["post_form"].elements["body_markdown"];
+ } else {
+ md = document.forms["track_form"].elements["body_markdown"];
+ }
md.style.maxHeight = "300rem";
md.style.maxWidth = "300rem";
});
diff --git a/app/utils/util.py b/app/utils/util.py
index dc04b0b..d9b2318 100644
--- a/app/utils/util.py
+++ b/app/utils/util.py
@@ -45,7 +45,7 @@ def extract_main_image(markdown):
try:
image = soup.find_all('img')[0]['id']
img_pk = image.split('image-')[1]
- return apps.get_model('photos', 'LuxImage').objects.get(pk=img_pk)
+ return apps.get_model('media', 'LuxImage').objects.get(pk=img_pk)
except IndexError:
return None
@@ -74,7 +74,7 @@ def parse_image(s):
else:
try:
image_id = img['id'].split("image-")[1]
- i = apps.get_model('photos', 'LuxImage').objects.get(pk=image_id)
+ i = apps.get_model('media', 'LuxImage').objects.get(pk=image_id)
caption = False
exif = False
cluster_class = None
@@ -141,7 +141,7 @@ def parse_reg_bio_page():
try:
image = soup.find_all('img')[0]['id']
img_pk = image.split('image-')[1]
- return apps.get_model('photos', 'LuxImage').objects.get(pk=img_pk)
+ return apps.get_model('media', 'LuxImage').objects.get(pk=img_pk)
except IndexError:
return None
diff --git a/app/utils/views.py b/app/utils/views.py
index 6b69b25..b678a33 100644
--- a/app/utils/views.py
+++ b/app/utils/views.py
@@ -6,16 +6,17 @@ from django.views.generic import ListView, DetailView
from django.apps import apps
from django.shortcuts import render
from django.template import RequestContext
+from django.template.defaultfilters import slugify
from media.models import LuxImage, LuxVideo, LuxAudio
BREADCRUMBS = {
- 'SrcPost':'SRC',
+ 'AP':'dialogue',
'Book':'Book Notes',
'Entry':'Jrnl',
'NewsletterMailing':'lttr',
- 'LuxImage':'lttr'
+ 'LuxImage':'lttr',
}
class PaginatedListView(ListView):
@@ -35,13 +36,6 @@ class PaginatedListView(ListView):
request.base_path = path
return super(PaginatedListView, self).dispatch(request, *args, **kwargs)
- def get_context_data(self, **kwargs):
- '''
- Adds breadcrumb path to every view
- '''
- # Call the base implementation first to get a context
- context = super(PaginatedListView, self).get_context_data(**kwargs)
- print('model=', self.model)
try:
context['breadcrumbs'] = (BREADCRUMBS[self.model.__name__],)
except KeyError:
@@ -61,22 +55,31 @@ class LuxDetailView(DetailView):
context = super(LuxDetailView, self).get_context_data(**kwargs)
print(self.object._meta.verbose_name_plural)
try:
- context['breadcrumbs'] = (BREADCRUMBS[self.object._meta.model],)
+ context['breadcrumbs'] = (BREADCRUMBS[self.object._meta.label.split(".")[1]],)
except KeyError:
if self.object._meta.verbose_name_plural == 'posts':
- context['breadcrumbs'] = (self.object.get_post_type_display()+"s",)
- context['crumb_url'] = "/%ss/" % self.object.get_post_type_display()
+ if self.object.get_post_type_display() != 'src':
+ context['breadcrumbs'] = (self.object.get_post_type_display()+"s",)
+ else:
+ context['breadcrumbs'] = (self.object.get_post_type_display(),)
+ context['crumb_url'] = "/%ss/" % slugify(self.object.get_post_type_display())
else:
context['breadcrumbs'] = (self.object._meta.verbose_name_plural,)
try:
context['crumb_url']
except KeyError:
try:
- context['crumb_url'] = reverse('%s:list' % self.object._meta.verbose_name_plural.slugify())
+ context['crumb_url'] = reverse('%s:list' % slugify(self.object._meta.verbose_name_plural))
except:
- # special case for pages:
- context['breadcrumbs'] = (self.object.title,)
- context['crumb_url'] = None
+ # special case for books:
+ if self.object._meta.verbose_name_plural == 'books':
+ context['crumb_url'] = reverse('books:list')
+ elif self.object._meta.verbose_name_plural == 'Animal/Plant':
+ context['crumb_url'] = reverse('sightings:list')
+ else:
+ # special case for pages:
+ context['breadcrumbs'] = (self.object.title,)
+ context['crumb_url'] = None
return context
diff --git a/app/utils/widgets.py b/app/utils/widgets.py
index f4a7a4a..87b39ec 100644
--- a/app/utils/widgets.py
+++ b/app/utils/widgets.py
@@ -4,7 +4,7 @@ from django.contrib import admin
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 ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from django.template.loader import render_to_string
from django.template import Context
from django.forms.widgets import SelectMultiple