forked from rc/aircox
make menu work
This commit is contained in:
38
cms/views.py
38
cms/views.py
@ -176,41 +176,3 @@ class PostDetailView(DetailView, PostBaseView):
|
||||
return self.get(request, *args, **kwargs)
|
||||
|
||||
|
||||
class Menu(View):
|
||||
template_name = 'aircox/cms/section.html'
|
||||
tag = 'nav'
|
||||
classes = ''
|
||||
attrs = ''
|
||||
name = ''
|
||||
enabled = True
|
||||
position = '' # top, left, bottom, right, header, footer, page_top, page_bottom
|
||||
sections = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.classes += ' menu menu_{}'.format(self.name or self.position)
|
||||
if not self.attrs:
|
||||
self.attrs = {}
|
||||
if self.name:
|
||||
self.attrs['name'] = self.name
|
||||
self.attrs['id'] = self.name
|
||||
|
||||
def get_context_data(self, request, object = None, **kwargs):
|
||||
kwargs['object'] = object
|
||||
|
||||
return {
|
||||
'tag': self.tag,
|
||||
'classes': self.classes,
|
||||
'attrs': self.attrs,
|
||||
'content': ''.join([
|
||||
section.get(request, **kwargs)
|
||||
for section in self.sections
|
||||
])
|
||||
}
|
||||
|
||||
def get(self, request, object = None, **kwargs):
|
||||
self.request = request
|
||||
context = self.get_context_data(request, object, **kwargs)
|
||||
return render_to_string(self.template_name, context)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user