def make_overview(module, urls, namespace):
"""Given the URLs for a bunch of views and the module they came from this
generates an overview page with a title, description and a list of links
to execute the views.
"""
title = get_module_name(module).title()
description = module.__doc__
class OverView(TemplateView):
template_name = 'auto_task_overview.html'
def get_context_data(self, **kwargs):
ctx = super(OverView, self).get_context_data(**kwargs)
ctx.update({'title': title, 'description': description})
view_links = []
for url in urls:
view = url.callback
view_links.append({
'url_name': '%s:%s' % (
namespace, url.name
) if namespace else url.name,
'view_name': funcname(view, rep=' '),
'view_description': view.__doc__ or '',
})
ctx['view_links'] = sorted(
view_links, key=lambda d: d['view_name'])
return ctx
return OverView.as_view()
评论列表
文章目录