forked from GeoNode/geonode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…eoNode#10045) * -[Fixes GeoNode#10040] Remove auto-generated thumbnail for documents * - add migration to clean available thumbs * - fix migration * - modify functionality
- Loading branch information
1 parent
7fc1826
commit 733340c
Showing
3 changed files
with
45 additions
and
60 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
geonode/documents/migrations/0036_clean_document_thumbnails.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import logging | ||
|
||
from django.db import migrations | ||
|
||
from ..models import Document | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def set_null_to_non_image_docs_thumbnails(apps, _): | ||
"Sets thumbnail_url to null for documents which are not images" | ||
try: | ||
# update thumbnail urls | ||
for document in Document.objects.all(): | ||
if not document.is_image: | ||
document.thumbnail_url=None | ||
document.save() | ||
# Remove thumbnail links | ||
link_model = apps.get_model('base', 'Link') | ||
link_model.objects.filter(resource__thumbnail_url__isnull=True, name='Thumbnail').delete() | ||
except Exception as e: | ||
logger.exception(e) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('documents', '0033_remove_document_doc_type'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(set_null_to_non_image_docs_thumbnails, migrations.RunPython.noop), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters