Commit 0e0193b4 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[ui] Add some specific uicfg rules and translation for entities related to binary data objects

Including a new view to display alternatives.
parent 47b839e905ab
......@@ -851,10 +851,6 @@ msgstr ""
msgid "SEDACompressed"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_compressed.object"
msgid "SEDACompressed"
msgstr ""
msgid "SEDACompressed_plural"
msgstr ""
......@@ -989,14 +985,6 @@ msgstr ""
msgid "SEDADataObjectVersion"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_data_object_version_from.object"
msgid "SEDADataObjectVersion"
msgstr ""
msgctxt "inlined:SEDAPhysicalDataObject.seda_data_object_version_from.object"
msgid "SEDADataObjectVersion"
msgstr ""
msgid "SEDADataObjectVersionCodeListVersion"
msgstr ""
......@@ -1628,14 +1616,6 @@ msgstr ""
msgid "SEDARelationship"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_relationship.object"
msgid "SEDARelationship"
msgstr ""
msgctxt "inlined:SEDAPhysicalDataObject.seda_relationship.object"
msgid "SEDARelationship"
msgstr ""
msgid "SEDARelationshipCodeListVersion"
msgstr ""
......@@ -3422,10 +3402,6 @@ msgstr ""
msgid "add a SEDACompressed"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_compressed.object"
msgid "add a SEDACompressed"
msgstr ""
msgid "add a SEDACompressionAlgorithmCodeListVersion"
msgstr ""
......@@ -3521,14 +3497,6 @@ msgstr ""
msgid "add a SEDADataObjectVersion"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_data_object_version_from.object"
msgid "add a SEDADataObjectVersion"
msgstr ""
msgctxt "inlined:SEDAPhysicalDataObject.seda_data_object_version_from.object"
msgid "add a SEDADataObjectVersion"
msgstr ""
msgid "add a SEDADataObjectVersionCodeListVersion"
msgstr ""
......@@ -3977,14 +3945,6 @@ msgstr ""
msgid "add a SEDARelationship"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_relationship.object"
msgid "add a SEDARelationship"
msgstr ""
msgctxt "inlined:SEDAPhysicalDataObject.seda_relationship.object"
msgid "add a SEDARelationship"
msgstr ""
msgid "add a SEDARelationshipCodeListVersion"
msgstr ""
......
......@@ -854,10 +854,6 @@ msgstr ""
msgid "SEDACompressed"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_compressed.object"
msgid "SEDACompressed"
msgstr ""
msgid "SEDACompressed_plural"
msgstr ""
......@@ -992,14 +988,6 @@ msgstr ""
msgid "SEDADataObjectVersion"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_data_object_version_from.object"
msgid "SEDADataObjectVersion"
msgstr ""
msgctxt "inlined:SEDAPhysicalDataObject.seda_data_object_version_from.object"
msgid "SEDADataObjectVersion"
msgstr ""
msgid "SEDADataObjectVersionCodeListVersion"
msgstr ""
......@@ -1631,14 +1619,6 @@ msgstr ""
msgid "SEDARelationship"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_relationship.object"
msgid "SEDARelationship"
msgstr ""
msgctxt "inlined:SEDAPhysicalDataObject.seda_relationship.object"
msgid "SEDARelationship"
msgstr ""
msgid "SEDARelationshipCodeListVersion"
msgstr ""
......@@ -3377,7 +3357,7 @@ msgid "add a SEDAArchiveUnitRefId"
msgstr ""
msgid "add a SEDAAttachment"
msgstr ""
msgstr "ajouter un attachement"
msgctxt "inlined:SEDAAltBinaryDataObjectAttachment.seda_attachment.object"
msgid "add a SEDAAttachment"
......@@ -3425,10 +3405,6 @@ msgstr ""
msgid "add a SEDACompressed"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_compressed.object"
msgid "add a SEDACompressed"
msgstr ""
msgid "add a SEDACompressionAlgorithmCodeListVersion"
msgstr ""
......@@ -3524,14 +3500,6 @@ msgstr ""
msgid "add a SEDADataObjectVersion"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_data_object_version_from.object"
msgid "add a SEDADataObjectVersion"
msgstr ""
msgctxt "inlined:SEDAPhysicalDataObject.seda_data_object_version_from.object"
msgid "add a SEDADataObjectVersion"
msgstr ""
msgid "add a SEDADataObjectVersionCodeListVersion"
msgstr ""
......@@ -3980,14 +3948,6 @@ msgstr ""
msgid "add a SEDARelationship"
msgstr ""
msgctxt "inlined:SEDABinaryDataObject.seda_relationship.object"
msgid "add a SEDARelationship"
msgstr ""
msgctxt "inlined:SEDAPhysicalDataObject.seda_relationship.object"
msgid "add a SEDARelationship"
msgstr ""
msgid "add a SEDARelationshipCodeListVersion"
msgstr ""
......@@ -4338,7 +4298,7 @@ msgid "add a SEDAType"
msgstr ""
msgid "add a SEDAUri"
msgstr ""
msgstr "ajouter une URI"
msgctxt "inlined:SEDAAltBinaryDataObjectAttachment.seda_uri.object"
msgid "add a SEDAUri"
......@@ -4377,7 +4337,7 @@ msgid "add a SEDAWriter"
msgstr ""
msgid "add a SEDAfilename"
msgstr ""
msgstr "ajouter un nom de fichier"
msgctxt "inlined:SEDAAttachment.seda_filename.object"
msgid "add a SEDAfilename"
......@@ -4441,7 +4401,7 @@ msgid "comment"
msgstr ""
msgid "compressed"
msgstr ""
msgstr "fichier compressé"
msgctxt "SEDACompressed"
msgid "compressed"
......@@ -5589,7 +5549,7 @@ msgid "seda_alt_archive_unit_archive_unit_ref_id_object"
msgstr ""
msgid "seda_alt_binary_data_object_attachment"
msgstr ""
msgstr "données"
msgctxt "SEDABinaryDataObject"
msgid "seda_alt_binary_data_object_attachment"
......@@ -6074,7 +6034,7 @@ msgid "seda_compressed"
msgstr ""
msgid "seda_compressed_object"
msgstr ""
msgstr "compression"
msgctxt "SEDABinaryDataObject"
msgid "seda_compressed_object"
......@@ -6340,7 +6300,7 @@ msgid "seda_data_object_version_from"
msgstr ""
msgid "seda_data_object_version_from_object"
msgstr ""
msgstr "version"
msgctxt "SEDABinaryDataObject"
msgid "seda_data_object_version_from_object"
......@@ -6351,7 +6311,7 @@ msgid "seda_data_object_version_from_object"
msgstr ""
msgid "seda_data_object_version_to"
msgstr ""
msgstr "valeur"
msgctxt "SEDADataObjectVersion"
msgid "seda_data_object_version_to"
......@@ -7548,7 +7508,7 @@ msgid "seda_relationship_code_list_version_to_object"
msgstr ""
msgid "seda_relationship_object"
msgstr ""
msgstr "relations"
msgctxt "SEDABinaryDataObject"
msgid "seda_relationship_object"
......
......@@ -27,6 +27,9 @@ from cubes.seda.views import rtags_from_xsd_element
_ = unicode
pvs = uicfg.primaryview_section
rec = uicfg.reledit_ctrl
afs = uicfg.autoform_section
affk = uicfg.autoform_field_kwargs
......@@ -91,6 +94,27 @@ class ContainedSearchForRelatedEntitiesView(rwdg.SearchForRelatedEntitiesView):
return self._cw.execute(rql, {'at': int(self._cw.form['container'])})
# hide some relation from autoform because of limitation of _container_eid
pvs.tag_object_of(('*', 'seda_compressed', 'SEDABinaryDataObject'), 'attributes')
afs.tag_object_of(('*', 'seda_compressed', 'SEDABinaryDataObject'), 'main', 'hidden')
rec.tag_object_of(('*', 'seda_compressed', 'SEDABinaryDataObject'),
{'rvid': 'seda.reledit.complexlink',
'novalue_label': _('<unauthorized>')})
rec.tag_subject_of(('SEDABinaryDataObject', 'seda_alt_binary_data_object_attachment', '*'),
{'rvid': 'seda.reledit.alternative',
'novalue_label': _('<unauthorized>')})
for etype in ('SEDABinaryDataObject', 'SEDAPhysicalDataObject'):
for rtype in ('seda_data_object_version_from', 'seda_relationship'):
pvs.tag_object_of(('*', rtype, etype), 'attributes')
afs.tag_object_of(('*', rtype, etype), 'main', 'hidden')
rec.tag_object_of(('*', 'seda_data_object_version_from', etype),
{'rvid': 'seda.reledit.complexlink',
'novalue_label': _('<unauthorized>')})
def uri_cardinality_vocabulary(form, field):
req = form._cw
try:
......
......@@ -21,9 +21,10 @@ from cubicweb.view import EntityView
class XSDMetaEntityView(EntityView):
__regid__ = 'seda.xsdmeta'
def entity_call(self, entity):
cardinality = getattr(entity, 'user_cardinality', 1)
self.w(u' <span class="cardinality">[%s]</span>' % cardinality)
def entity_call(self, entity, skip_one_card=False):
cardinality = getattr(entity, 'user_cardinality', '1')
if cardinality != '1' or not skip_one_card:
self.w(u' <span class="cardinality">[%s]</span>' % cardinality)
description = getattr(entity, 'user_annotation', None)
if description:
self.w(u' <div class="description">%s</div>' % description)
......@@ -69,7 +70,31 @@ class ComplexLinkEntityAttributeView(EntityView):
self.w(u'</div>')
class AlternativeEntityAttributeView(EntityView):
"""Attribute view for SEDA alternative entities"""
__regid__ = 'seda.reledit.alternative'
def entity_call(self, entity):
alternatives = []
for rschema, _targets, role in entity.e_schema.relation_definitions():
rtype = rschema.type
if rtype.startswith('seda_') and rtype != self.cw_extra_kwargs['rtype']:
target_rset = entity.related(rtype, role)
if target_rset:
alternatives.append(self._cw.view('seda.business.typed', rset=target_rset))
self.w(u'<div class="alternative">')
if alternatives:
self.w((' <b>%s</b> ' % self._cw._(' ALT_I18N ')).join(alternatives))
else:
self.wdata(self._cw._('<no value specified>'))
entity.view('seda.xsdmeta', w=self.w)
self.w(u'</div>')
class BusinessValueEntityView(EntityView):
"""Entity view that will display value of the attribute specified by `value_attr` on the
entity's class
"""
__regid__ = 'seda.business'
def entity_call(self, entity):
......@@ -83,3 +108,13 @@ class BusinessValueEntityView(EntityView):
self.w(u'</span>')
else:
self.wdata(self._cw._('<no value specified>'))
class TypedBusinessValueEntityView(EntityView):
"""Similar to seda.business but with type information, for use within alternative"""
__regid__ = 'seda.business.typed'
def entity_call(self, entity):
self.w(entity.dc_type() + u' ')
entity.view('seda.business', w=self.w)
entity.view('seda.xsdmeta', w=self.w, skip_one_card=True)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment