diff --git a/dockerize/.env.template b/dockerize/.env.template index 4c6d3ad4..3704753d 100644 --- a/dockerize/.env.template +++ b/dockerize/.env.template @@ -36,6 +36,10 @@ ENABLE_LDAP=False # SENTRY SENTRY_DSN='' +# Set traces_sample_rate to 1.0 to capture 100% +# of transactions for performance monitoring. +SENTRY_RATE=1.0 + # Download stats URL METABASE_DOWNLOAD_STATS_URL='https://plugins.qgis.org/metabase/public/dashboard/' diff --git a/dockerize/docker-compose.yml b/dockerize/docker-compose.yml index 1fbcb987..ec112781 100644 --- a/dockerize/docker-compose.yml +++ b/dockerize/docker-compose.yml @@ -52,6 +52,7 @@ services: - EMAIL_HOST_PASSWORD=${EMAIL_HOST_PASSWORD} - DEFAULT_PLUGINS_SITE=${DEFAULT_PLUGINS_SITE:-https://plugins.qgis.org/} - SENTRY_DSN=${SENTRY_DSN} + - SENTRY_RATE=${SENTRY_RATE} volumes: - ../qgis-app:/home/web/django_project - ./docker/uwsgi.conf:/uwsgi.conf diff --git a/qgis-app/plugins/templates/plugins/plugin_detail.html b/qgis-app/plugins/templates/plugins/plugin_detail.html index 726360f9..c85b2c04 100644 --- a/qgis-app/plugins/templates/plugins/plugin_detail.html +++ b/qgis-app/plugins/templates/plugins/plugin_detail.html @@ -144,7 +144,7 @@

{% endif %}

{{ object.name }} - {% if object.icon and object.icon.file %} + {% if object.icon and object.icon.file and object.icon|is_image_valid %} {% with image_extension=object.icon.name|file_extension %} {% if image_extension == 'svg' %} {% trans @@ -154,6 +154,8 @@

{{ object.name }} {% endthumbnail %} {% endif %} {% endwith %} + {% else %} + {% trans {% endif %}

diff --git a/qgis-app/plugins/templates/plugins/plugin_list.html b/qgis-app/plugins/templates/plugins/plugin_list.html index 788053d6..c0457a35 100644 --- a/qgis-app/plugins/templates/plugins/plugin_list.html +++ b/qgis-app/plugins/templates/plugins/plugin_list.html @@ -80,7 +80,7 @@

{% if title %}{{title}}{% else %}{% trans "All plugins" %}{% endif %}

{% for object in object_list %} - {% if object.icon and object.icon.file %} + {% if object.icon and object.icon.file and object.icon|is_image_valid %} {% with image_extension=object.icon.name|file_extension %} {% if image_extension == 'svg' %} {% trans diff --git a/qgis-app/plugins/templatetags/plugin_utils.py b/qgis-app/plugins/templatetags/plugin_utils.py index 887eee83..182c410c 100755 --- a/qgis-app/plugins/templatetags/plugin_utils.py +++ b/qgis-app/plugins/templatetags/plugin_utils.py @@ -1,4 +1,5 @@ from django import template +from PIL import Image, UnidentifiedImageError register = template.Library() @@ -27,4 +28,15 @@ def plugin_title(context): @register.filter def file_extension(value): - return value.split('.')[-1].lower() \ No newline at end of file + return value.split('.')[-1].lower() + +@register.filter +def is_image_valid(image): + if not image: + return False + try: + img = Image.open(image.path) + img.verify() + return True + except (FileNotFoundError, UnidentifiedImageError): + return False diff --git a/qgis-app/settings_docker.py b/qgis-app/settings_docker.py index 9d1903c0..a7f58444 100644 --- a/qgis-app/settings_docker.py +++ b/qgis-app/settings_docker.py @@ -173,6 +173,7 @@ # Sentry SENTRY_DSN = os.environ.get("SENTRY_DSN", "") +SENTRY_RATE = os.environ.get("SENTRY_RATE", 1.0) if SENTRY_DSN and SENTRY_DSN != "": import sentry_sdk @@ -181,5 +182,5 @@ dsn=SENTRY_DSN, # Set traces_sample_rate to 1.0 to capture 100% # of transactions for performance monitoring. - traces_sample_rate=1.0, + traces_sample_rate=SENTRY_RATE, )