-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…10135) (#10136) * PDF thumbnail renderer * - add unit tests * command to generate thumbnails for docs * flake fix * renamed management command * add requirement to setup.cfg * make command similar to other sync commands * removed unused import * fix flake8 Co-authored-by: marthamareal <[email protected]> Co-authored-by: Giovanni Allegri <[email protected]> Co-authored-by: marthamareal <[email protected]>
- Loading branch information
1 parent
b17f801
commit 57b84fc
Showing
6 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
geonode/documents/management/commands/sync_geonode_documents.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,48 @@ | ||
######################################################################### | ||
# | ||
# Copyright (C) 2022 OSGeo | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
######################################################################### | ||
|
||
import logging | ||
|
||
from django.core.management.base import BaseCommand | ||
from geonode.documents.models import Document | ||
from geonode.documents.tasks import create_document_thumbnail | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class Command(BaseCommand): | ||
help = ("Update documents. For the moment only thumbnails can be updated") | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument( | ||
'--updatethumbnails', | ||
action='store_true', | ||
dest="updatethumbnails", | ||
default=False, | ||
help="Update the document thumbnails.") | ||
|
||
def handle(self, *args, **options): | ||
updatethumbnails = options.get('updatethumbnails') | ||
for doc in Document.objects.all(): | ||
if updatethumbnails: | ||
if doc.thumbnail_url is None or doc.thumbnail_url == '': | ||
try: | ||
create_document_thumbnail(doc.id) | ||
except Exception: | ||
logger.error(f"[ERROR] Thumbnail for [{doc.name}] couldn't be created") |
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
Binary file not shown.
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