313 |
313 |
314 def _wf_items_for_relation(req, wfeid, wfrelation, field): |
314 def _wf_items_for_relation(req, wfeid, wfrelation, field): |
315 wf = req.entity_from_eid(wfeid) |
315 wf = req.entity_from_eid(wfeid) |
316 rschema = req.vreg.schema[field.name] |
316 rschema = req.vreg.schema[field.name] |
317 param = 'toeid' if field.role == 'subject' else 'fromeid' |
317 param = 'toeid' if field.role == 'subject' else 'fromeid' |
318 return sorted((e.view('combobox'), e.eid) |
318 return sorted((e.view('combobox'), unicode(e.eid)) |
319 for e in getattr(wf, 'reverse_%s' % wfrelation) |
319 for e in getattr(wf, 'reverse_%s' % wfrelation) |
320 if rschema.has_perm(req, 'add', **{param: e.eid})) |
320 if rschema.has_perm(req, 'add', **{param: e.eid})) |
321 |
321 |
322 # TrInfo |
322 # TrInfo |
323 _afs.tag_subject_of(('TrInfo', 'to_state', '*'), 'main', 'hidden') |
323 _afs.tag_subject_of(('TrInfo', 'to_state', '*'), 'main', 'hidden') |
328 # XXX * allowed_transition BaseTransition |
328 # XXX * allowed_transition BaseTransition |
329 # XXX BaseTransition destination_state * |
329 # XXX BaseTransition destination_state * |
330 |
330 |
331 def transition_states_vocabulary(form, field): |
331 def transition_states_vocabulary(form, field): |
332 entity = form.edited_entity |
332 entity = form.edited_entity |
333 if not entity.has_eid(): |
333 if entity.has_eid(): |
|
334 wfeid = entity.transition_of[0].eid |
|
335 else: |
334 eids = form.linked_to.get(('transition_of', 'subject')) |
336 eids = form.linked_to.get(('transition_of', 'subject')) |
335 if not eids: |
337 if not eids: |
336 return [] |
338 return [] |
337 return _wf_items_for_relation(form._cw, eids[0], 'state_of', field) |
339 wfeid = eids[0] |
338 return field.relvoc_unrelated(form) |
340 return _wf_items_for_relation(form._cw, wfeid, 'state_of', field) |
339 |
341 |
340 _afs.tag_subject_of(('*', 'destination_state', '*'), 'main', 'attributes') |
342 _afs.tag_subject_of(('*', 'destination_state', '*'), 'main', 'attributes') |
341 _affk.tag_subject_of(('*', 'destination_state', '*'), |
343 _affk.tag_subject_of(('*', 'destination_state', '*'), |
342 {'choices': transition_states_vocabulary}) |
344 {'choices': transition_states_vocabulary}) |
343 _afs.tag_object_of(('*', 'allowed_transition', '*'), 'main', 'attributes') |
345 _afs.tag_object_of(('*', 'allowed_transition', '*'), 'main', 'attributes') |
346 |
348 |
347 # State |
349 # State |
348 |
350 |
349 def state_transitions_vocabulary(form, field): |
351 def state_transitions_vocabulary(form, field): |
350 entity = form.edited_entity |
352 entity = form.edited_entity |
351 if not entity.has_eid(): |
353 if entity.has_eid(): |
|
354 wfeid = entity.state_of[0].eid |
|
355 else : |
352 eids = form.linked_to.get(('state_of', 'subject')) |
356 eids = form.linked_to.get(('state_of', 'subject')) |
353 if eids: |
357 if not eids: |
354 return _wf_items_for_relation(form._cw, eids[0], 'transition_of', field) |
358 return [] |
355 return [] |
359 wfeid = eids[0] |
356 return field.relvoc_unrelated(form) |
360 return _wf_items_for_relation(form._cw, wfeid, 'transition_of', field) |
357 |
361 |
358 _afs.tag_subject_of(('State', 'allowed_transition', '*'), 'main', 'attributes') |
362 _afs.tag_subject_of(('State', 'allowed_transition', '*'), 'main', 'attributes') |
359 _affk.tag_subject_of(('State', 'allowed_transition', '*'), |
363 _affk.tag_subject_of(('State', 'allowed_transition', '*'), |
360 {'choices': state_transitions_vocabulary}) |
364 {'choices': state_transitions_vocabulary}) |
361 |
365 |