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

Fix UI to add a data object to a parentless archive unit (aka SEDA component)

We still rely on the referenced_by trick, simply removing __linkto information.
This is the quickest way to make it work, because customizing data reference to
inline the binary data object for is painful (among other, this is an ambiguous
relation which isn't supported by inlined forms).

The main known drawback is that the form's title is contextless.
parent 891700ba269e
......@@ -56,6 +56,10 @@ def parent_and_container(entity):
if 'sedaContainerEID' in req.form:
container = req.entity_from_eid(int(req.form['sedaContainerEID']))
return None, container
if 'referenced_by' in req.form:
entity = req.entity_from_eid(int(req.form['referenced_by']))
container = entity.cw_adapt_to('IContained').container
return None, container
# unable to get parent eid for now :(
return None, None
parent = req.entity_from_eid(parent_eid)
......@@ -30,7 +30,7 @@ from cubes.relationwidget import views as rwdg
from cubes.seda.entities import simplified_profile, parent_and_container
from cubes.seda.entities.itree import parent_archive_unit
from cubes.seda.views import (add_subobject_link, add_subobjects_button, dropdown_button,
rtags_from_rtype_role_targets, copy_rtag)
rtags_from_rtype_role_targets, copy_rtag, has_rel_perm)
from cubes.seda.views import clone, viewlib, widgets, content
from cubes.seda.views import uicfg as sedauicfg # noqa - ensure those rules are defined first
......@@ -423,7 +423,18 @@ class SimplifiedArchiveUnitDataObjectReferencesTab(ArchiveUnitDataObjectReferenc
params = self.url_params(entity)
params['referenced_by'] = text_type(entity.eid)
transfer = entity.container[0]
button = add_subobjects_button(transfer, rtype_roles, params)
if transfer.cw_etype == 'SEDAArchiveTransfer':
button = add_subobjects_button(transfer, rtype_roles, params)
if has_rel_perm('add', entity, 'seda_data_object_reference', 'object'):
vreg = self._cw.vreg
url = vreg['etypes'].etype_class('SEDABinaryDataObject').cw_create_url(
self._cw, **params)
msg = self._cw.__('seda_binary_data_object_object')
link = tags.a(msg, href=url, title=self._cw.__('New SEDABinaryDataObject'))
button = dropdown_button(entity._cw._(msg), [link])
button = None
if button:
# No button if user cannot add any relation.
Supports Markdown
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