0001-export-evolutions-in-form-API-10820.patch
wcs/formdata.py | ||
---|---|---|
150 | 150 |
l.append(p.view()) |
151 | 151 |
return l |
152 | 152 | |
153 |
def get_json_export_dict(self, user): |
|
154 |
data = { |
|
155 |
'status': self.status, |
|
156 |
'time': self.time, |
|
157 |
} |
|
158 |
try: |
|
159 |
if self.who != '_submitter': |
|
160 |
user = get_publisher().user_class.get(self.who) |
|
161 |
except KeyError: |
|
162 |
pass |
|
163 |
else: |
|
164 |
if user: |
|
165 |
data['who'] = user.get_json_export_dict() |
|
166 |
if self.comment: |
|
167 |
data['comment'] = self.comment |
|
168 |
parts = [] |
|
169 |
for part in self.parts or []: |
|
170 |
if hasattr(part, 'get_json_export_dict'): |
|
171 |
parts.append(part.get_json_export_dict()) |
|
172 |
if parts: |
|
173 |
data['parts'] = parts |
|
174 |
return data |
|
175 | ||
153 | 176 | |
154 | 177 |
class FormData(StorableObject): |
155 | 178 |
_names = 'XX' |
... | ... | |
699 | 722 |
user = None |
700 | 723 |
break |
701 | 724 |
if user: |
702 |
data['user'] = {'id': user.id, 'name': user.display_name} |
|
703 |
if user.email: |
|
704 |
data['user']['email'] = user.email |
|
705 |
if user.name_identifiers: |
|
706 |
data['user']['NameID'] = user.name_identifiers |
|
725 |
data['user'] = user.get_json_export_dict() |
|
707 | 726 | |
708 | 727 |
data['fields'] = get_json_dict(self.formdef.fields, self.data, |
709 | 728 |
include_files=include_files) |
... | ... | |
742 | 761 |
'channel': self.get_submission_channel_label(), |
743 | 762 |
} |
744 | 763 | |
764 |
if self.evolution: |
|
765 |
data['evolution'] = [evo.get_json_export_dict(user) for evo in self.evolution] |
|
766 | ||
745 | 767 |
return data |
746 | 768 | |
747 | 769 |
def export_to_json(self, include_files=True): |
wcs/users.py | ||
---|---|---|
188 | 188 |
return self.__dict__['form_data'].get(attr[1:]) |
189 | 189 |
raise AttributeError() |
190 | 190 | |
191 |
def get_json_export_dict(self): |
|
192 |
data = { |
|
193 |
'id': self.id, |
|
194 |
'name': self.display_name, |
|
195 |
} |
|
196 |
if self.email: |
|
197 |
data['email'] = self.email |
|
198 |
if self.name_identifiers: |
|
199 |
data['NameID'] = self.name_identifiers |
|
200 |
return data |
|
201 | ||
191 | 202 | |
192 | 203 |
Substitutions.register('session_user', category=N_('User'), comment=N_('Session User')) |
193 | 204 |
Substitutions.register('session_user_display_name', category=N_('User'), comment=N_('Session User Display Name')) |
wcs/wf/register_comment.py | ||
---|---|---|
51 | 51 |
[(x or htmltext('</p><p>')) for x in self.content.splitlines()]) + \ |
52 | 52 |
htmltext('</p>') |
53 | 53 | |
54 |
def get_json_export_dict(self): |
|
55 |
return { |
|
56 |
'type': 'journal-evolution', |
|
57 |
'content': self.content, |
|
58 |
} |
|
59 | ||
54 | 60 | |
55 | 61 |
class RegisterCommenterWorkflowStatusItem(WorkflowStatusItem): |
56 | 62 |
description = N_('Record in Log') |
wcs/wf/wscall.py | ||
---|---|---|
79 | 79 |
r += htmltext('</div>') |
80 | 80 |
return r.getvalue() |
81 | 81 | |
82 |
def get_json_export_dict(self): |
|
83 |
return { |
|
84 |
'type': 'wscall-error', |
|
85 |
'summary': self.summary, |
|
86 |
'label': self.label, |
|
87 |
'data': self.data, |
|
88 |
} |
|
89 | ||
82 | 90 | |
83 | 91 |
class WebserviceCallStatusItem(WorkflowStatusItem): |
84 | 92 |
description = N_('Webservice Call') |
85 |
- |