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

[views] UI to edit file_category instead of format_id / mime_type relations

Do it minimal with no js involved but a simple multiple select. This still have
to be coupled to format_id / mime_type but this will be done in later csets.

Related to #36331831
parent 5b3ec7300aae
......@@ -119,6 +119,8 @@ pvdc.tag_object_of(('*', 'seda_data_object_reference_id', '*'),
pvs.tag_subject_of(('*', 'seda_algorithm', '*'), 'attributes')
pvs.tag_object_of(('*', 'seda_target', '*'), 'hidden') # in the relationship tab
# hide file_category from the main tab, it lives in the format tab
pvs.tag_subject_of(('SEDABinaryDataObject', 'file_category', '*'), 'hidden')
for rtype in ('seda_compressed', 'seda_data_object_version_from'):
# hide relation from autoform because of limitation of _container_eid
......@@ -182,6 +184,17 @@ class BinaryDataObjectTabbedPrimaryView(tabs.TabbedPrimaryView):
]
def _setup_format_tab(rsection, display_ctrl):
# hide format_id / mime_type, in favor of custom 'file_category'. Actual
# format_id and mime_type will be derived from that value (XXX hook or profile
# gen time ?)
rsection.tag_object_of(('*', 'seda_format_id_from', 'SEDABinaryDataObject'), 'hidden')
rsection.tag_object_of(('*', 'seda_mime_type_from', 'SEDABinaryDataObject'), 'hidden')
rsection.tag_subject_of(('SEDABinaryDataObject', 'file_category', '*'), 'attributes')
# dunno why it crashes without this
display_ctrl.tag_subject_of(('SEDABinaryDataObject', 'file_category', '*'), {'order': 0})
class BinaryDataObjectFormatIdentificationTab(viewlib.PrimaryTabWithoutBoxes):
"""Display format identification information of a binary data object"""
......@@ -189,6 +202,7 @@ class BinaryDataObjectFormatIdentificationTab(viewlib.PrimaryTabWithoutBoxes):
__select__ = is_instance('SEDABinaryDataObject')
rsection, display_ctrl = rtags_from_xsd_element('SEDABinaryDataObject', 'FormatIdentification')
_setup_format_tab(rsection, display_ctrl)
class SimplifiedBinaryDataObjectFormatIdentificationTab(BinaryDataObjectFormatIdentificationTab):
......@@ -196,9 +210,33 @@ class SimplifiedBinaryDataObjectFormatIdentificationTab(BinaryDataObjectFormatId
__select__ = BinaryDataObjectFormatIdentificationTab.__select__ & simplified_profile()
rsection, display_ctrl = rtags_from_xsd_element('SEDABinaryDataObject', 'FormatIdentification')
_setup_format_tab(rsection, display_ctrl)
rsection.tag_object_of(('*', 'seda_format_litteral', 'SEDABinaryDataObject'), 'hidden')
def file_category_vocabulary(form, field):
rset = form._cw.execute(
'Any C,CLL,E,ELL ORDERBY CLL,ELL WHERE '
'C in_scheme CS, CS scheme_relation_type CR, CR name "file_category", '
'NOT C broader_concept SC, E broader_concept C, '
'CL label_of C, CL label CLL,'
'EL label_of E, EL label ELL'
)
values = []
current_category = None
for category, category_label, extension, extension_label in rset:
if current_category is None or current_category != category:
current_category = category
values.append((category_label, str(category)))
values.append((u'{} > {}'.format(category_label, extension_label),
str(extension)))
return values
affk.tag_subject_of(('SEDABinaryDataObject', 'file_category', '*'),
{'choices': file_category_vocabulary})
class BinaryDataObjectFileInfoTab(viewlib.PrimaryTabWithoutBoxes):
"""Display file information of a binary data object"""
......
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