diff --git a/combo/data/models.py b/combo/data/models.py
index 298dca46..968cd567 100644
--- a/combo/data/models.py
+++ b/combo/data/models.py
@@ -162,6 +162,11 @@ class Page(models.Model):
def natural_key(self):
return (self.get_online_url().strip('/'), )
+ def picture_extension(self):
+ if not self.picture:
+ return None
+ return os.path.splitext(self.picture.name)[-1]
+
def save(self, *args, **kwargs):
if not self.id:
self.related_cells = {'cell_types': []}
diff --git a/combo/manager/fields.py b/combo/manager/fields.py
new file mode 100644
index 00000000..384bd721
--- /dev/null
+++ b/combo/manager/fields.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+#
+# combo - content management system
+# Copyright (C) 2015-2019 Entr'ouvert
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see
{% if object.picture %} -{% thumbnail object.picture "320x240" crop="50% 25%" as im %} - + {% if object.picture_extension != '.svg' %} + {% thumbnail object.picture "320x240" crop="50% 25%" as im %} + + {% endthumbnail %} + {% else %} + + {% endif %} ({% trans 'remove' %}) -{% endthumbnail %} {% else %}{% trans 'none' %}{% endif %} ({% trans 'change' %})
diff --git a/tests/test_manager.py b/tests/test_manager.py index 8aafd611..e9748e63 100644 --- a/tests/test_manager.py +++ b/tests/test_manager.py @@ -170,11 +170,22 @@ def test_page_edit_picture(app, admin_user): resp = resp.follow() assert '