api: include category_slug in formdefs API (#10366)
This commit is contained in:
parent
fd06ad762d
commit
5309b7af26
|
@ -45,7 +45,8 @@ l'URL <code>/api/formdefs/</code>.
|
|||
"redirection": false,
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"category": "Inscriptions"},
|
||||
"category": "Inscriptions",
|
||||
"category_slug": "inscriptions"},
|
||||
{"url": "https://www.example.net/inscriptions/piscine",
|
||||
"title": "Piscine",
|
||||
"slug": "piscine",
|
||||
|
@ -54,7 +55,8 @@ l'URL <code>/api/formdefs/</code>.
|
|||
"redirection": false,
|
||||
"description": "La piscine est ouverte du lundi au samedi.",
|
||||
"keywords": ["sport"],
|
||||
"category": "Inscriptions"}
|
||||
"category": "Inscriptions",
|
||||
"category_slug": "inscriptions"}
|
||||
]
|
||||
</output>
|
||||
</screen>
|
||||
|
|
|
@ -507,7 +507,7 @@ def test_categories(pub):
|
|||
FormDef.wipe()
|
||||
Category.wipe()
|
||||
category = Category()
|
||||
category.name = 'category'
|
||||
category.name = 'Category'
|
||||
category.description = 'hello world'
|
||||
category.store()
|
||||
|
||||
|
@ -533,7 +533,7 @@ def test_categories(pub):
|
|||
resp = get_app(pub).get('/api/categories/')
|
||||
resp2 = get_app(pub).get('/categories', headers={'Accept': 'application/json'})
|
||||
assert resp.json == resp2.json
|
||||
assert resp.json['data'][0]['title'] == 'category'
|
||||
assert resp.json['data'][0]['title'] == 'Category'
|
||||
assert resp.json['data'][0]['url'] == 'http://example.net/category/'
|
||||
assert resp.json['data'][0]['description'] == 'hello world'
|
||||
assert set(resp.json['data'][0]['keywords']) == set(['foobar', 'mobile', 'test'])
|
||||
|
@ -557,6 +557,8 @@ def test_categories_formdefs(pub):
|
|||
assert resp.json[0]['url'] == 'http://example.net/test/'
|
||||
assert resp.json[0]['count'] == 0
|
||||
assert resp.json[0]['redirection'] == False
|
||||
assert resp.json[0]['category'] == 'Category'
|
||||
assert resp.json[0]['category_slug'] == 'category'
|
||||
|
||||
def test_categories_full(pub):
|
||||
test_categories(pub)
|
||||
|
|
|
@ -342,6 +342,7 @@ class ApiFormdefsDirectory(Directory):
|
|||
|
||||
if formdef.category:
|
||||
formdict['category'] = unicode(formdef.category.name, charset)
|
||||
formdict['category_slug'] = unicode(formdef.category.url_name, charset)
|
||||
formdict['category_position'] = (formdef.category.position or 0)
|
||||
else:
|
||||
formdict['category_position'] = sys.maxint
|
||||
|
|
Loading…
Reference in New Issue