Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fixes #9604] Report empty thumbnail in case a thumbnail has not been…
… generated for a resource (#9613) (#9810) * -[Fixes #9604] Report empty thumbnail in case a thumbnail has not been generated for a resource * - update tests * -remove unused import * -remove unused import * - create Thumbnail Link if thumbnail_url exists * - fix tests * - fix pep8 * - add command to clean resources thumbs * - fix lgtm * - rename migration file * - fix migration dependence Co-authored-by: Alessio Fabiani <alessio.fabiani@geosolutionsgroup.com> (cherry picked from commit 38cbd9d) Co-authored-by: NAGGINDA MARTHA <marthamareal@gmail.com>
- Loading branch information
1 parent
6d773d6
commit a5df4ec
Showing
13 changed files
with
61 additions
and
70 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
geonode/base/migrations/0083_clean_resources_with_missing_thumb.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,32 @@ | ||
import logging | ||
|
||
from django.db import migrations | ||
from django.templatetags.static import static | ||
|
||
from geonode.thumbs.utils import MISSING_THUMB | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def set_null_thumbnail(apps, _): | ||
"Sets thumbnail_url to null for resources with thumbnail_url=missing_thumb" | ||
try: | ||
resource_model = apps.get_model('base', 'ResourceBase') | ||
link_model = apps.get_model('base', 'Link') | ||
# update thumbnail urls | ||
resource_model.objects.filter(thumbnail_url__icontains=static(MISSING_THUMB)).update(thumbnail_url=None) | ||
# Remove thumbnail links | ||
link_model.objects.filter(resource__thumbnail_url__isnull=True, name='Thumbnail').delete() | ||
except Exception as e: | ||
logger.exception(e) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('base', '0082_remove_dialogos_comment'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(set_null_thumbnail, 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
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
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
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
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
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