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

[ui] Display message instead of 'search' button when we're missing information...

[ui] Display message instead of 'search' button when we're missing information to resolve constraint
parent 12fa24315052
......@@ -39,6 +39,30 @@ affk = uicfg.autoform_field_kwargs
class ContainedRelationFacetWidget(rwdg.RelationFacetWidget):
def _render_triggers(self, w, domid, form, field, rtype):
parent, container = parent_and_container(form.edited_entity)
req = form._cw
if container is None:
w(req._('you must validate first to select a possible value'))
constraint = RDEF_CONSTRAINTS[(form.edited_entity.cw_etype,]
except KeyError:
constraint = RDEF_CONSTRAINTS[]
rql = 'Any CS WHERE ' + (
constraint.replace('O in_scheme CS, ', '').replace(', S container AT', ''))
rql += ', AT eid %(at)s'
if not req.execute(rql, {'at': container.eid}):
scheme_relations = [x for x in rql.split() if x.startswith('seda_')]
if len(scheme_relations) == 1:
scheme_relation = req._(scheme_relations[0])
scheme_relation = req.__(scheme_relations[0] + '_object')
w(req._('you must specify a scheme for {0} to select a value').format(
return super(ContainedRelationFacetWidget, self)._render_triggers(
w, domid, form, field, rtype)
def trigger_search_url(self, entity, url_params):
"""Overriden to add information about who is the container
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