0002-api-check-status-visibility-with-get_user_from_api_q.patch
wcs/api.py | ||
---|---|---|
102 | 102 | |
103 | 103 |
d.update(formdata.get_static_substitution_variables(minimal=True)) |
104 | 104 |
if get_request().form.get('full') == 'on': |
105 |
d.update(formdata.get_json_export_dict(include_files=False)) |
|
105 |
d.update(formdata.get_json_export_dict(include_files=False, user=user))
|
|
106 | 106 |
return d |
107 | 107 | |
108 | 108 |
wcs/backoffice/management.py | ||
---|---|---|
1627 | 1627 |
if get_publisher().is_using_postgresql(): |
1628 | 1628 |
self.formdef.data_class().load_all_evolutions(items) |
1629 | 1629 |
if get_request().form.get('full') == 'on': |
1630 |
output = [filled.get_json_export_dict(include_files=False, anonymise=anonymise) |
|
1630 |
output = [filled.get_json_export_dict(include_files=False, anonymise=anonymise, user=user)
|
|
1631 | 1631 |
for filled in items] |
1632 | 1632 |
else: |
1633 | 1633 |
output = [{'id': filled.id, |
wcs/formdata.py | ||
---|---|---|
230 | 230 |
status = self.get_status() |
231 | 231 |
return status.name if status else _('Unknown') |
232 | 232 | |
233 |
def is_hidden(self): |
|
233 |
def is_hidden(self, user=None):
|
|
234 | 234 |
status = self.get_status() |
235 | 235 |
if status: |
236 |
return not status.is_visible(self.formdata, get_request().user) |
|
236 |
return not status.is_visible(self.formdata, user or get_request().user)
|
|
237 | 237 |
return True |
238 | 238 | |
239 | 239 | |
... | ... | |
509 | 509 |
return wf_status |
510 | 510 |
return None |
511 | 511 | |
512 |
def get_visible_evolution_parts(self): |
|
512 |
def get_visible_evolution_parts(self, user=None):
|
|
513 | 513 |
last_seen_status = None |
514 | 514 |
last_seen_author = None |
515 | 515 |
for evolution_part in self.evolution or []: |
516 |
if evolution_part.is_hidden(): |
|
516 |
if evolution_part.is_hidden(user=user):
|
|
517 | 517 |
continue |
518 | 518 |
if (evolution_part.status is None or last_seen_status == evolution_part.status) and ( |
519 | 519 |
evolution_part.who is None or last_seen_author == evolution_part.who): |
... | ... | |
944 | 944 |
'name': self.formdef.name, |
945 | 945 |
'id': self.get_display_id()} |
946 | 946 | |
947 |
def get_json_export_dict(self, include_files=True, anonymise=False): |
|
947 |
def get_json_export_dict(self, include_files=True, anonymise=False, user=None):
|
|
948 | 948 |
data = {} |
949 | 949 |
data['id'] = str(self.id) |
950 | 950 |
data['display_id'] = self.get_display_id() |
... | ... | |
966 | 966 |
include_files=include_files, anonymise=anonymise) |
967 | 967 | |
968 | 968 |
data['workflow'] = {} |
969 |
wf_status = self.get_visible_status() |
|
969 |
wf_status = self.get_visible_status(user)
|
|
970 | 970 |
if wf_status: |
971 | 971 |
data['workflow']['status'] = {'id': wf_status.id, 'name': wf_status.name} |
972 | 972 |
# Workflow data have unknown purpose, do not store them in anonymised export |
973 |
- |