Révision 7c109c30
Ajouté par Frédéric Péters il y a plus de 4 ans
auquotidien/modules/root.py | ||
---|---|---|
280 | 280 |
return FormsRootDirectory(f.category)._q_traverse(path[1:]) |
281 | 281 |
return redirect('%s%s/%s' % (base_url, f.category.url_name, uri_rest)) |
282 | 282 |
|
283 |
try: |
|
284 |
cat = Category.get_by_urlname(path[0]) |
|
285 |
except KeyError: |
|
286 |
pass |
|
287 |
else: |
|
288 |
return FormsRootDirectory(cat)._q_traverse(path[1:]) |
|
289 |
|
|
283 | 290 |
raise e |
284 | 291 |
|
285 | 292 |
|
tests/test_user_pages.py | ||
---|---|---|
153 | 153 |
# check we get to the form, not the category |
154 | 154 |
resp = get_app(pub).get('/foobar/') |
155 | 155 |
assert resp.form |
156 |
|
|
157 |
|
|
158 |
def test_form_and_category_same_slug2(): |
|
159 |
Category.wipe() |
|
160 |
cat = Category(name='test') |
|
161 |
cat.store() |
|
162 |
|
|
163 |
FormDef.wipe() |
|
164 |
formdef = FormDef() |
|
165 |
formdef.name = 'foobar' |
|
166 |
formdef.category_id = cat.id |
|
167 |
formdef.fields = [] |
|
168 |
formdef.store() |
|
169 |
|
|
170 |
formdef = FormDef() |
|
171 |
formdef.name = 'test' |
|
172 |
formdef.fields = [] |
|
173 |
formdef.store() |
|
174 |
|
|
175 |
# check we get to the foobar form |
|
176 |
resp = get_app(pub).get('/foobar/') |
|
177 |
assert resp.location == 'http://example.net/test/foobar/' |
|
178 |
resp = resp.follow() |
|
179 |
assert resp.form |
|
180 |
assert '<h3>foobar</h3>' in resp |
|
181 |
|
|
182 |
# check we get to the test form |
|
183 |
resp = get_app(pub).get('/test/') |
|
184 |
assert resp.form |
|
185 |
assert '<h3>test</h3>' in resp |
Formats disponibles : Unified diff
misc: display formdef when slug is shared by category and formdef (#39155)