Fix display of 'compressed' attribute of a binary data object
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 06 Jan 2017 12:34:33 +0100
changeset 2262 63e336cdbc8c
parent 2261 6a2991d3a896
child 2263 b6a2ad4c7683
Fix display of 'compressed' attribute of a binary data object
i18n/en.po
i18n/fr.po
views/dataobject.py
--- a/i18n/en.po	Thu Jan 05 14:37:47 2017 +0100
+++ b/i18n/en.po	Fri Jan 06 12:34:33 2017 +0100
@@ -23,6 +23,10 @@
 msgid ", of relationship type %s"
 msgstr ""
 
+#, python-brace-format
+msgid ", using {algorithm}"
+msgstr ""
+
 msgid "0..1"
 msgstr ""
 
--- a/i18n/fr.po	Thu Jan 05 14:37:47 2017 +0100
+++ b/i18n/fr.po	Fri Jan 06 12:34:33 2017 +0100
@@ -23,6 +23,10 @@
 msgid ", of relationship type %s"
 msgstr ", de type %s"
 
+#, python-brace-format
+msgid ", using {algorithm}"
+msgstr ", avec l'algorithme {algorithm}"
+
 msgid "0..1"
 msgstr "facultatif et unique (0..1)"
 
--- a/views/dataobject.py	Thu Jan 05 14:37:47 2017 +0100
+++ b/views/dataobject.py	Fri Jan 06 12:34:33 2017 +0100
@@ -132,6 +132,10 @@
                    {'rvid': 'seda.reledit.alternative',
                     'novalue_label': _('<unauthorized>')})
 
+rec.tag_object_of(('*', 'seda_compressed', '*'),
+                  {'rvid': 'seda.reledit.text',
+                   'novalue_label': _('<unauthorized>')})
+
 
 def uri_cardinality_vocabulary(form, field):
     req = form._cw
@@ -276,6 +280,20 @@
         return value
 
 
+class CompressedBusinessValueEntityView(viewlib.BusinessValueEntityView):
+    __select__ = is_instance('SEDACompressed')
+
+    def entity_value(self, entity):
+        if entity.compressed is None:
+            value = self._cw.__('indifferent')
+        else:
+            value = self._cw.__('yes' if entity.compressed else 'no')
+        if entity.seda_algorithm:
+            algorithm = entity.seda_algorithm[0].label()
+            value += self._cw._(u', using {algorithm}').format(algorithm=algorithm)
+        return value
+
+
 class RelationshipReverseEntityView(view.EntityView):
 
     __regid__ = 'seda.relationship.reverse'