diff options
author | luxagraf <sng@luxagraf.net> | 2021-09-13 12:37:19 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2021-09-13 12:37:19 -0400 |
commit | c80742b329c4955336188f186eaa933193c6c735 (patch) | |
tree | d090460baf7e9eb189b5207a226f8e5408207dea | |
parent | 65312b9a798215fa27a389cb60ca00cd616e15b0 (diff) |
books: tweaked the admin and fixed file paths for generated thumbs
-rw-r--r-- | app/books/admin.py | 6 | ||||
-rw-r--r-- | app/books/models.py | 4 | ||||
-rw-r--r-- | config/base_urls.py | 1 |
3 files changed, 6 insertions, 5 deletions
diff --git a/app/books/admin.py b/app/books/admin.py index 8366510..3faa14e 100644 --- a/app/books/admin.py +++ b/app/books/admin.py @@ -1,10 +1,10 @@ from django.contrib import admin from .models import Book - +from orderable.admin import OrderableAdmin @admin.register(Book) -class BookAdmin(admin.ModelAdmin): - list_display = ('title', 'admin_thumbnail', 'isbn', 'author_last_name') +class BookAdmin(OrderableAdmin): + list_display = ('title', 'admin_thumbnail', 'isbn', 'author_last_name', 'sort_order_display') search_fields = ['title', 'body_markdown'] class Media: diff --git a/app/books/models.py b/app/books/models.py index 2ebc769..0e17621 100644 --- a/app/books/models.py +++ b/app/books/models.py @@ -74,11 +74,11 @@ class Book(Orderable): @receiver(post_save, sender=Book) def post_save_events(sender, update_fields, created, instance, **kwargs): if instance.image: - base_path = "%s/%s/" % (settings.IMAGES_ROOT, "/".join(str(i) for i in instance.image.name.split('/')[1:-1])) + base_path = "%s/%s/" % (settings.IMAGES_ROOT, "/".join(str(i) for i in instance.image.name.split('/')[3:-1])) filename, file_extension = os.path.splitext(instance.image.path) img = Image.open(instance.image.path) resize_image(img, None, 160, 78, base_path, "%s_tn%s" % (filename.split('/')[-1], file_extension)) - resize_image(img, None, 650, 78, base_path, "%s_small%s" % (filename.split('/')[-1], file_extension)) + resize_image(img, None, 600, 78, base_path, "%s_small%s" % (filename.split('/')[-1], file_extension)) class BookSitemap(Sitemap): diff --git a/config/base_urls.py b/config/base_urls.py index 6f40180..8a9c3ef 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -37,6 +37,7 @@ urlpatterns = [ path(r'<slug>.txt', PageDetailTXTView.as_view()), path(r'<slug>', include('pages.urls', namespace='pages')), path(r'<path>/<slug>/', PageDetailView.as_view()), + path(r'', HomePageList.as_view(), {'pk':1,}, name="homepage"), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) |