0004-workflow-display-targeted-card-form-data-on-inspect-.patch
tests/backoffice_pages/test_all.py | ||
---|---|---|
4307 | 4307 |
# parent |
4308 | 4308 |
assert '<li><a href="http://example.net/backoffice/management/external-action-form/1/">External action form #2-1 (Parent)</a></li>' in resp.text |
4309 | 4309 | |
4310 |
# check manual targeting |
|
4311 |
action.target_mode = 'manual' |
|
4312 |
action.target_id = '1' |
|
4313 |
wf.store() |
|
4314 |
resp = app.get('/backoffice/management/external-action-form/1/inspect') |
|
4315 |
assert 'Related Forms/Cards' in resp.text |
|
4316 |
assert '<li><a href="http://example.net/backoffice/management/external-form/1/">External Form #1-1 (Evolution)</a></li>' in resp.text |
|
4317 |
assert '<li><a href="http://example.net/backoffice/data/external-card/1/">External Card #1-1 (Evolution)</a></li>' in resp.text |
|
4318 |
assert '<li><a href="http://example.net/backoffice/management/external-form/1/">External Form #1-1 (Manual targeting)</a></li>' in resp.text |
|
4319 | ||
4310 | 4320 |
external_formdef.data_class().wipe() |
4311 | 4321 |
external_carddef.data_class().wipe() |
4312 | 4322 | |
... | ... | |
4315 | 4325 |
assert 'Related Forms/Cards' in resp.text |
4316 | 4326 |
assert '<li><a href="">Linked "External Form" object by id 1 (Evolution - not found)</a></li>' in resp.text |
4317 | 4327 |
assert '<li><a href="">Linked "External Card" object by id 1 (Evolution - not found)</a></li>' in resp.text |
4328 |
assert '<li><a href="">Targeted "External Form" object by id 1 (Manual targeting - not found)' in resp.text |
|
4318 | 4329 | |
4319 | 4330 |
formdef.data_class().wipe() |
4320 | 4331 |
carddef.data_class().wipe() |
4321 | 4332 | |
4333 |
action.target_mode = 'all' |
|
4334 |
wf.store() |
|
4335 | ||
4322 | 4336 |
carddata = carddef.data_class()() |
4323 | 4337 |
carddata.data = {'0': 'test card'} |
4324 | 4338 |
carddata.user = user |
wcs/backoffice/management.py | ||
---|---|---|
3214 | 3214 |
r += htmltext('</div>') |
3215 | 3215 | |
3216 | 3216 |
children = list(self.filled.iter_target_datas()) |
3217 |
for status in self.formdef.workflow.possible_status + self.formdef.workflow.global_actions: |
|
3218 |
for item in status.items: |
|
3219 |
if not hasattr(item, 'get_manual_target'): |
|
3220 |
continue |
|
3221 |
target = item.get_manual_target(self.filled, from_inspect=True) |
|
3222 |
if target: |
|
3223 |
children.append(target) |
|
3217 | 3224 |
if children: |
3218 | 3225 |
r += htmltext('<div id="inspect-related" class="section">') |
3219 | 3226 |
r += htmltext('<h2>%s</h2>') % _('Related Forms/Cards') |
wcs/wf/external_workflow.py | ||
---|---|---|
130 | 130 |
'object_name': objectdef.name} |
131 | 131 |
return _('not completed') |
132 | 132 | |
133 |
def get_manual_target(self, formdata): |
|
133 |
def get_manual_target(self, formdata, from_inspect=False):
|
|
134 | 134 |
if self.target_mode != 'manual': |
135 | 135 |
return |
136 | 136 | |
137 | 137 |
objectdef = self.get_object_def() |
138 |
if not objectdef: |
|
139 |
return |
|
140 | ||
138 | 141 |
target_id = self.compute(self.target_id, formdata=formdata, status_item=self) |
139 | 142 |
if not target_id: |
140 | 143 |
return |
141 | 144 | |
142 | 145 |
try: |
146 |
if from_inspect: |
|
147 |
return objectdef.data_class().get(target_id), _('Manual targeting') |
|
143 | 148 |
return objectdef.data_class().get(target_id) |
144 | 149 |
except KeyError as e: |
150 |
if from_inspect: |
|
151 |
return (_('Targeted "%(object_name)s" object by id %(object_id)s') |
|
152 |
% {'object_name': objectdef.name, 'object_id': target_id}, |
|
153 |
_('Manual targeting - not found')) |
|
145 | 154 |
# use custom error message depending on target type |
146 | 155 |
LoggedError.record(_('Could not find targeted "%(object_name)s" object by id %(object_id)s') % { |
147 | 156 |
'object_name': objectdef.name, 'object_id': target_id}, |
148 |
- |