api: add a "redirection" boolean attribute to formdef json api (#6568)
This commit is contained in:
parent
939e59adfc
commit
64c16c1a5a
|
@ -43,12 +43,14 @@ est transmis, ou à une URL <code>/json</code> autrement.
|
|||
"slug": "newsletter",
|
||||
"count": 17,
|
||||
"authentication_required": false,
|
||||
"redirection": false,
|
||||
"category": "Inscriptions"},
|
||||
{"url": "https://www.example.net/inscriptions/piscine",
|
||||
"title": "Piscine",
|
||||
"slug": "piscine",
|
||||
"count": 6,
|
||||
"authentication_required": true,
|
||||
"redirection": false,
|
||||
"category": "Inscriptions"}
|
||||
]
|
||||
</output>
|
||||
|
|
|
@ -131,6 +131,22 @@ def test_formdef_list():
|
|||
assert resp1.json[0]['title'] == 'test'
|
||||
assert resp1.json[0]['url'] == 'http://example.net/test/'
|
||||
assert resp1.json[0]['count'] == 0
|
||||
assert resp1.json[0]['redirection'] == False
|
||||
|
||||
def test_formdef_list_redirection():
|
||||
FormDef.wipe()
|
||||
formdef = FormDef()
|
||||
formdef.name = 'test'
|
||||
formdef.disabled = True
|
||||
formdef.disabled_redirection = 'http://example.net'
|
||||
formdef.fields = []
|
||||
formdef.store()
|
||||
|
||||
resp1 = get_app(pub).get('/json')
|
||||
assert resp1.json[0]['title'] == 'test'
|
||||
assert resp1.json[0]['url'] == 'http://example.net/test/'
|
||||
assert resp1.json[0]['count'] == 0
|
||||
assert resp1.json[0]['redirection'] == True
|
||||
|
||||
def test_formdef_schema():
|
||||
FormDef.wipe()
|
||||
|
|
|
@ -1008,6 +1008,9 @@ class RootDirectory(AccessControlled, Directory):
|
|||
'url': formdef.get_url(),
|
||||
'authentication_required': authentication_required}
|
||||
|
||||
formdict['redirection'] = bool(formdef.is_disabled() and
|
||||
formdef.disabled_redirection)
|
||||
|
||||
# we include the count of submitted forms so it's possible to sort
|
||||
# them by popularity
|
||||
formdict['count'] = formdef.data_class().count()
|
||||
|
|
Loading…
Reference in New Issue