api: add api & backoffice URLs to formdata endpoint response (#64861)
This commit is contained in:
parent
7e0f782776
commit
8ca17f4147
|
@ -245,6 +245,10 @@ def test_formdata(pub, local_user):
|
|||
assert {x.get('id') for x in resp.json['roles']['concerned']} == {str(role.id), str(another_role.id)}
|
||||
assert [x.get('id') for x in resp.json['roles']['actions']] == [str(role.id)]
|
||||
|
||||
assert resp.json['url'] == 'http://example.net/test/%s/' % formdata.id
|
||||
assert resp.json['backoffice_url'] == 'http://example.net/backoffice/management/test/%s/' % formdata.id
|
||||
assert resp.json['api_url'] == 'http://example.net/api/forms/test/%s/' % formdata.id
|
||||
|
||||
# check the ?format=json endpoint returns 403
|
||||
get_app(pub).get('/test/%s/?format=json' % formdata.id, status=403)
|
||||
get_app(pub).get(sign_uri('/test/%s/' % formdata.id, user=local_user), status=403)
|
||||
|
|
|
@ -1318,6 +1318,8 @@ class FormData(StorableObject):
|
|||
data['last_update_time'] = datetime.datetime(*self.last_update_time[:6])
|
||||
data['criticality_level'] = self.criticality_level
|
||||
data['url'] = self.get_url()
|
||||
data['api_url'] = self.get_api_url()
|
||||
data['backoffice_url'] = self.get_backoffice_url()
|
||||
|
||||
try:
|
||||
user = get_publisher().user_class.get(self.user_id)
|
||||
|
|
Loading…
Reference in New Issue