pagetools.sections package¶
Subpackages¶
Submodules¶
pagetools.sections.admin module¶
pagetools.sections.dashboard_modules module¶
- class pagetools.sections.dashboard_modules.PageNodesModule(*args, **kwargs)[source]¶
Bases:
DashboardModuleA module that displays a page with nodes.
A “page” should be the root-pagenode model. Overwrite model = <YourModel>
Dashboard needs to include the static files, e.g:
from django import forms ... def _media(self): return forms.Media( js=[" "js/jquery-bonsai/jquery.bonsai.js", "js/nodetree.js" ], css = {'all': [ 'bower_components/jquery-bonsai/jquery.bonsai.css ']} ) media = property(_media) urls.py: url( r'^adminnodes/(?P<slug>[\w-]+)/$', admin_pagenodesview, name='admin_pagenodesview'),
- init_with_context(context)[source]¶
Like for the
Dashboardclass, dashboard modules have ainit_with_contextmethod that is called with adjango.template.RequestContextinstance as unique argument.This gives you enough flexibility to build complex modules, for example, let’s build a “history” dashboard module, that will list the last ten visited pages:
from grappelli.dashboard import modules class HistoryDashboardModule(modules.LinkList): title = 'History' def init_with_context(self, context): request = context['request'] # we use sessions to store the visited pages stack history = request.session.get('history', []) for item in history: self.children.append(item) # add the current page to the history history.insert(0, { 'title': context['title'], 'url': request.META['PATH_INFO'] }) if len(history) > 10: history = history[:10] request.session['history'] = history
- model = None¶
- template = 'admin/dashboard_pagenodes_module.html'¶