0001-manager-show-apply_to_subpages-only-if-page-has-chid.patch
combo/manager/forms.py | ||
---|---|---|
238 | 238 |
initial = kwargs.pop('initial', {}) |
239 | 239 |
initial['include_in_navigation'] = not instance.exclude_from_navigation |
240 | 240 |
super().__init__(initial=initial, *args, **kwargs) |
241 |
if initial['include_in_navigation']: |
|
241 |
if initial['include_in_navigation'] or not instance.has_children():
|
|
242 | 242 |
del self.fields['apply_to_subpages'] |
243 | 243 | |
244 | 244 |
def save(self, *args, **kwargs): |
tests/test_manager.py | ||
---|---|---|
286 | 286 |
resp = resp.form.submit() |
287 | 287 |
assert 'syntax error:' in resp.text |
288 | 288 |
resp = resp.click('Cancel') |
289 |
# include from nav |
|
289 |
# include from nav, no apply_to_subpages field if page doesn't have children |
|
290 |
resp = resp.click(href='.*/include-in-navigation') |
|
291 |
assert 'apply_to_subpages' not in resp.form.fields |
|
292 |
resp = resp.click('Cancel') |
|
293 |
# include from nav not including subpages |
|
290 | 294 |
page2 = Page.objects.create(title='Two', parent=Page.objects.get(), exclude_from_navigation=True) |
291 | 295 |
resp = resp.click(href='.*/include-in-navigation') |
292 | 296 |
resp.form['include_in_navigation'].checked = True |
297 |
assert 'apply_to_subpages' in resp.form.fields |
|
293 | 298 |
resp = resp.form.submit() |
294 | 299 |
resp = resp.follow() |
295 | 300 |
assert Page.objects.all()[0].exclude_from_navigation is False |
296 |
- |