601 |
601 |
evo.parts = None
|
602 |
602 |
self.store()
|
603 |
603 |
|
604 |
|
def get_json_export_dict(self, include_files=True):
|
|
604 |
def get_json_export_dict(self, include_files=True, anonymise=False):
|
605 |
605 |
data = {}
|
606 |
606 |
data['id'] = '%s/%s' % (self.formdef.url_name, self.id)
|
607 |
607 |
data['display_id'] = self.get_display_id()
|
... | ... | |
612 |
612 |
data['last_update_time'] = self.last_update_time
|
613 |
613 |
data['url'] = self.get_url()
|
614 |
614 |
|
615 |
|
try:
|
616 |
|
user = get_publisher().user_class.get(self.user_id)
|
617 |
|
except KeyError:
|
618 |
|
user = None
|
619 |
|
# this is custom code so it is possible to mark forms as anonyms, this
|
620 |
|
# is done through the VoteAnonymity field, this is very specific but
|
621 |
|
# isn't generalised yet into an useful extension mechanism, as it's not
|
622 |
|
# clear at the moment what could be useful.
|
623 |
|
for f in self.formdef.fields:
|
624 |
|
if f.key == 'vote-anonymity':
|
|
615 |
if not anonymise:
|
|
616 |
try:
|
|
617 |
user = get_publisher().user_class.get(self.user_id)
|
|
618 |
except KeyError:
|
625 |
619 |
user = None
|
626 |
|
break
|
627 |
|
if user:
|
628 |
|
data['user'] = {'id': user.id, 'name': user.display_name}
|
|
620 |
# this is custom code so it is possible to mark forms as anonyms, this
|
|
621 |
# is done through the VoteAnonymity field, this is very specific but
|
|
622 |
# isn't generalised yet into an useful extension mechanism, as it's not
|
|
623 |
# clear at the moment what could be useful.
|
|
624 |
for f in self.formdef.fields:
|
|
625 |
if f.key == 'vote-anonymity':
|
|
626 |
user = None
|
|
627 |
break
|
|
628 |
if user:
|
|
629 |
data['user'] = {'id': user.id, 'name': user.display_name}
|
629 |
630 |
|
630 |
631 |
data['fields'] = get_json_dict(self.formdef.fields, self.data,
|
631 |
|
include_files=include_files)
|
|
632 |
include_files=include_files, anonymise=anonymise)
|
632 |
633 |
|
633 |
634 |
data['workflow'] = {}
|
634 |
635 |
wf_status = self.get_visible_status()
|
635 |
636 |
if wf_status:
|
636 |
637 |
data['workflow']['status'] = {'id': wf_status.id, 'name': wf_status.name}
|
637 |
|
if self.workflow_data:
|
|
638 |
# Workflow data have unknown purpose, do not store then in anonymised export
|
|
639 |
if self.workflow_data and not anonymise:
|
638 |
640 |
data['workflow']['data'] = self.workflow_data
|
639 |
641 |
|
640 |
642 |
# add a roles dictionary, with workflow functions and two special
|
641 |
|
-
|