summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/media/models.py72
-rw-r--r--design/templates/admin/index.html6
2 files changed, 41 insertions, 37 deletions
diff --git a/app/media/models.py b/app/media/models.py
index 1c2037a..f2a74bc 100644
--- a/app/media/models.py
+++ b/app/media/models.py
@@ -166,7 +166,7 @@ class LuxImage(models.Model):
return self.get_image_url_by_size("tn")
def admin_thumbnail(self):
- return format_html('<a href="%s"><img src="%s"></a>' % (self.get_image_url_by_size(), self.get_image_url_by_size("admin-thumbnail")))
+ return format_html('<a href="%s"><img src="%s"></a>' % (self.get_image_url_by_size(), self.get_image_url_by_size("tn")))
admin_thumbnail.short_description = 'Thumbnail'
@property
@@ -349,38 +349,42 @@ class LuxAudio(models.Model):
@receiver(m2m_changed, sender=LuxImage.sizes.through)
def update_photo_sizes(sender, instance, **kwargs):
# update the local cache of sizes
- instance.sizes_cache = ",".join(s.slug for s in instance.sizes.all())
- for size in instance.get_sizes:
- # check each size and see if there's an image there already
- my_file = Path(instance.get_image_path_by_size(size))
- if not my_file.is_file():
- print("creating new image file")
- #file doesn't exist, so create it
- new_size = LuxImageSize.objects.get(slug=size)
- if new_size.width:
- img = Image.open(instance.image.path)
- try:
- if new_size.width <= img.width:
- resize_image(img, new_size.width, None, new_size.quality, instance.get_image_path_by_size(size))
- else:
- raise ValidationError({'items': ["Size is larger than source image"]})
- except ImageSizeError:
- m2m_changed.disconnect(update_photo_sizes, sender=LuxImage.sizes.through)
- instance.sizes.remove(new_size)
- m2m_changed.connect(update_photo_sizes, sender=LuxImage.sizes.through)
- if new_size.height:
- try:
- if new_size.height <= img.height:
- resize_image(img, None, new_size.height, new_size.quality, instance.get_image_path_by_size(size))
- else:
- pass
- except ImageSizeError:
- m2m_changed.disconnect(update_photo_sizes, sender=LuxImage.sizes.through)
- instance.sizes.remove(new_size)
- m2m_changed.connect(update_photo_sizes, sender=LuxImage.sizes.through)
- else:
- # file exists, might add something here to force it to do the above when I want
- print("file %s exists" % size)
- pass
+ sizes = instance.sizes.all()
+ if sizes:
+ instance.sizes_cache = ",".join(s.slug for s in sizes)
+ print(instance.sizes.all())
+ for size in instance.get_sizes:
+ print("SIZE is: %s" % size)
+ # check each size and see if there's an image there already
+ my_file = Path(instance.get_image_path_by_size(size))
+ if not my_file.is_file():
+ #file doesn't exist, so create it
+ new_size = LuxImageSize.objects.get(slug=size)
+ if new_size.width:
+ img = Image.open(instance.image.path)
+ try:
+ if new_size.width <= img.width:
+ resize_image(img, new_size.width, None, new_size.quality, instance.get_image_path_by_size(size))
+ else:
+ raise ValidationError({'items': ["Size is larger than source image"]})
+ except ImageSizeError:
+ m2m_changed.disconnect(update_photo_sizes, sender=LuxImage.sizes.through)
+ instance.sizes.remove(new_size)
+ m2m_changed.connect(update_photo_sizes, sender=LuxImage.sizes.through)
+ if new_size.height:
+ img = Image.open(instance.image.path)
+ try:
+ if new_size.height <= img.height:
+ resize_image(img, None, new_size.height, new_size.quality, instance.get_image_path_by_size(size))
+ else:
+ pass
+ except ImageSizeError:
+ m2m_changed.disconnect(update_photo_sizes, sender=LuxImage.sizes.through)
+ instance.sizes.remove(new_size)
+ m2m_changed.connect(update_photo_sizes, sender=LuxImage.sizes.through)
+ else:
+ # file exists, might add something here to force it to do the above when I want
+ print("file %s exists" % size)
+ pass
instance.save()
diff --git a/design/templates/admin/index.html b/design/templates/admin/index.html
index b4ac678..d2aae7c 100644
--- a/design/templates/admin/index.html
+++ b/design/templates/admin/index.html
@@ -68,12 +68,12 @@ td, th {
<td><a href="/admin/posts/post/add/" class="addlink">Add</a></td>
<td><a href="/admin/build/build?id=writingarchives">Build JrnlArc</a></td>
</tr>
- <th scope="row"><a href="/admin/photos/luximage/">photos</a></th>
- <td><a href="/admin/photos/luximage/add/" class="addlink">Add</a></td>
+ <th scope="row"><a href="/admin/media/luximage/">images</a></th>
+ <td><a href="/admin/media/luximage/add/" class="addlink">Add</a></td>
<td><a href="/admin/build/build?id=homepage">Build Homepage</a></td>
</tr>
<tr>
- <th scope="row"><a href="/admin/lttr/newslettermailing/">Newsletter Mailings</a></th>
+ <th scope="row"><a href="/admin/lttr/newslettermailing/">newsletter mailings</a></th>
<td><a href="/admin/lttr/newslettermailing/add/" class="addlink">Add</a></td>
<td><a href="/admin/build/build?id=sitemap">Build Sitemap</a></td>
</tr>