forked from mirrors/bookwyrm
Merge pull request #212 from mouse-reeve/covers-bug
Fixes celery media path
This commit is contained in:
commit
33fe00f190
4 changed files with 18 additions and 2 deletions
|
@ -249,7 +249,10 @@ def update_from_mappings(obj, data, mappings):
|
|||
continue
|
||||
|
||||
# extract the value in the right format
|
||||
value = mapping.formatter(value)
|
||||
try:
|
||||
value = mapping.formatter(value)
|
||||
except:
|
||||
continue
|
||||
|
||||
# assign the formatted value to the model
|
||||
obj.__setattr__(mapping.local_field, value)
|
||||
|
|
|
@ -143,17 +143,24 @@ class Connector(AbstractConnector):
|
|||
|
||||
def expand_book_data(self, book):
|
||||
work = book
|
||||
# go from the edition to the work, if necessary
|
||||
if isinstance(book, models.Edition):
|
||||
work = book.parent_work
|
||||
|
||||
# we can mass download edition data from OL to avoid repeatedly querying
|
||||
edition_options = self.load_edition_data(work.openlibrary_key)
|
||||
for edition_data in edition_options.get('entries'):
|
||||
olkey = edition_data.get('key').split('/')[-1]
|
||||
# make sure the edition isn't already in the database
|
||||
if models.Edition.objects.filter(openlibrary_key=olkey).count():
|
||||
continue
|
||||
|
||||
# creates and populates the book from the data
|
||||
edition = self.create_book(olkey, edition_data, models.Edition)
|
||||
# ensures that the edition is associated with the work
|
||||
edition.parent_work = work
|
||||
edition.save()
|
||||
# get author data from the work if it's missing from the edition
|
||||
if not edition.authors and work.authors:
|
||||
edition.authors.set(work.authors.all())
|
||||
|
||||
|
|
|
@ -144,3 +144,6 @@ USE_TZ = True
|
|||
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, env('STATIC_ROOT', 'static'))
|
||||
MEDIA_URL = '/images/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, env('MEDIA_ROOT', 'images'))
|
||||
|
|
|
@ -14,8 +14,11 @@ Including another URLconf
|
|||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.conf.urls.static import static
|
||||
from django.urls import path
|
||||
|
||||
from celerywyrm import settings
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
|
Loading…
Reference in a new issue