general: make it possible to exclude a page from navigation
This commit is contained in:
parent
3ed5b2c4eb
commit
8e86134677
|
@ -40,6 +40,7 @@ class Page(models.Model):
|
|||
template_name = models.CharField(max_length=50)
|
||||
parent = models.ForeignKey('self', null=True, blank=True)
|
||||
order = models.PositiveIntegerField()
|
||||
exclude_from_navigation = models.BooleanField(_('Exclude from navigation'), default=False)
|
||||
|
||||
public = models.BooleanField(_('Public'), default=True)
|
||||
groups = models.ManyToManyField(Group, blank=True)
|
||||
|
|
|
@ -22,7 +22,7 @@ from combo.data.models import Page
|
|||
class PageForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Page
|
||||
exclude = ('order', 'public', 'groups')
|
||||
fields = ('title', 'slug', 'template_name')
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PageForm, self).__init__(*args, **kwargs)
|
||||
|
@ -30,6 +30,10 @@ class PageForm(forms.ModelForm):
|
|||
templates.sort(lambda x, y: cmp(x[1], y[1]))
|
||||
self.fields['template_name'].widget = forms.Select(choices=templates)
|
||||
|
||||
class PageEditForm(PageForm):
|
||||
class Meta:
|
||||
model = Page
|
||||
exclude = ('order', 'public', 'groups')
|
||||
|
||||
class PageVisibilityForm(forms.ModelForm):
|
||||
class Meta:
|
||||
|
|
|
@ -30,7 +30,7 @@ from django.views.generic import (TemplateView, RedirectView, DetailView,
|
|||
|
||||
from combo.data.models import Page, CellBase, UnlockMarkerCell
|
||||
|
||||
from .forms import PageForm, PageVisibilityForm
|
||||
from .forms import PageForm, PageEditForm, PageVisibilityForm
|
||||
|
||||
|
||||
class HomepageView(TemplateView):
|
||||
|
@ -66,7 +66,7 @@ page_add = PageAddView.as_view()
|
|||
class PageEditView(UpdateView):
|
||||
model = Page
|
||||
template_name = 'combo/page_add.html'
|
||||
form_class = PageForm
|
||||
form_class = PageEditForm
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('combo-manager-page-view', kwargs={'pk': self.object.id})
|
||||
|
@ -74,13 +74,8 @@ class PageEditView(UpdateView):
|
|||
page_edit = PageEditView.as_view()
|
||||
|
||||
class PageVisibilityView(PageEditView):
|
||||
model = Page
|
||||
template_name = 'combo/page_add.html'
|
||||
form_class = PageVisibilityForm
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse('combo-manager-page-view', kwargs={'pk': self.object.id})
|
||||
|
||||
page_visibility = PageVisibilityView.as_view()
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ def show_menu(context, level=0):
|
|||
for sibling in page_of_level.get_siblings():
|
||||
if not sibling.is_visible(context['request'].user):
|
||||
continue
|
||||
if sibling.exclude_from_navigation:
|
||||
continue
|
||||
menuitem = {'page': sibling}
|
||||
if sibling == page_of_level:
|
||||
menuitem['selected'] = True
|
||||
|
|
Loading…
Reference in New Issue