0001-misc-record-parent-object-class-43361.patch
tests/test_form_pages.py | ||
---|---|---|
7799 | 7799 |
assert target_formdata.data.get('1').get_content() == b'foobar' |
7800 | 7800 |
assert target_formdata.status == 'draft' |
7801 | 7801 |
assert target_formdata.submission_context == { |
7802 |
'orig_object_type': 'formdef', |
|
7802 | 7803 |
'orig_formdata_id': str(create_formdata['source_formdef'].data_class().select()[0].id), |
7803 | 7804 |
'orig_formdef_id': str(create_formdata['source_formdef'].id), |
7804 | 7805 |
} |
... | ... | |
7850 | 7851 |
assert target_formdata.data.get('1').get_content() == b'foobar' |
7851 | 7852 |
assert target_formdata.status == 'wf-new' |
7852 | 7853 |
assert target_formdata.submission_context == { |
7854 |
'orig_object_type': 'formdef', |
|
7853 | 7855 |
'orig_formdata_id': str(create_formdata['source_formdef'].data_class().select()[0].id), |
7854 | 7856 |
'orig_formdef_id': str(create_formdata['source_formdef'].id), |
7855 | 7857 |
} |
tests/test_formdata.py | ||
---|---|---|
2019 | 2019 |
child = formdef.data_class()() |
2020 | 2020 |
child.data = {'0': 'world'} |
2021 | 2021 |
child.submission_context = { |
2022 |
'orig_object_type': 'formdef', |
|
2022 | 2023 |
'orig_formdef_id': formdef.id, |
2023 | 2024 |
'orig_formdata_id': parent.id, |
2024 | 2025 |
} |
wcs/formdata.py | ||
---|---|---|
358 | 358 |
def get_submission_channel_label(self): |
359 | 359 |
return self.get_submission_channels().get(self.submission_channel) or _('Web') |
360 | 360 | |
361 |
def get_parent(self): |
|
362 |
if not self.submission_context: |
|
363 |
return None |
|
364 |
object_type = self.submission_context.get('orig_object_type', 'formdef') |
|
365 |
objectdef_id = self.submission_context.get('orig_formdef_id') |
|
366 |
objectdata_id = self.submission_context.get('orig_formdata_id') |
|
367 |
if not (object_type and objectdef_id and objectdata_id): |
|
368 |
return None |
|
369 |
if object_type == 'carddef': |
|
370 |
from .carddef import CardDef |
|
371 |
objectdef_class = CardDef |
|
372 |
else: |
|
373 |
from .formdef import FormDef |
|
374 |
objectdef_class = FormDef |
|
375 |
try: |
|
376 |
return objectdef_class.get(objectdef_id).data_class().get(objectdata_id) |
|
377 |
except KeyError: |
|
378 |
return None |
|
379 | ||
361 | 380 |
def just_created(self): |
362 | 381 |
self.receipt_time = time.localtime() |
363 | 382 |
self.status = 'wf-%s' % self.formdef.workflow.possible_status[0].id |
wcs/variables.py | ||
---|---|---|
412 | 412 | |
413 | 413 |
@property |
414 | 414 |
def parent(self): |
415 |
if not self._formdata.submission_context: |
|
416 |
return None |
|
417 |
if 'orig_formdef_id' not in self._formdata.submission_context: |
|
418 |
return None |
|
419 |
if 'orig_formdata_id' not in self._formdata.submission_context: |
|
420 |
return None |
|
421 |
formdef = FormDef.get(self._formdata.submission_context['orig_formdef_id'], ignore_errors=True) |
|
422 |
if formdef is None: |
|
423 |
return None |
|
424 |
formdata = formdef.data_class().get(self._formdata.submission_context['orig_formdata_id'], ignore_errors=True) |
|
415 |
formdata = self._formdata.get_parent() |
|
425 | 416 |
if formdata is None: |
426 | 417 |
return None |
427 | 418 |
return formdata.get_substitution_variables() |
wcs/wf/create_formdata.py | ||
---|---|---|
323 | 323 |
if self.backoffice_submission and get_request() and get_request().user is not None: |
324 | 324 |
new_formdata.submission_context['agent_id'] = str(get_request().user.id) |
325 | 325 | |
326 |
new_formdata.submission_context['orig_object_type'] = formdata.formdef.xml_root_node |
|
326 | 327 |
new_formdata.submission_context['orig_formdef_id'] = str(formdata.formdef.id) |
327 | 328 |
new_formdata.submission_context['orig_formdata_id'] = str(formdata.id) |
328 | 329 |
new_formdata.data = {} |
wcs/wf/resubmit.py | ||
---|---|---|
80 | 80 |
new_formdata.backoffice_submission = get_request().is_in_backoffice() |
81 | 81 |
if not new_formdata.submission_context: |
82 | 82 |
new_formdata.submission_context = {} |
83 |
new_formdata.submission_context['orig_object_type'] = formdata.formdef.xml_root_node |
|
83 | 84 |
new_formdata.submission_context['orig_formdef_id'] = formdata.formdef.id |
84 | 85 |
new_formdata.submission_context['orig_formdata_id'] = formdata.id |
85 | 86 |
new_formdata.data = {} |
86 |
- |