24 lines
800 B
Python
24 lines
800 B
Python
from django.conf import settings
|
|
from django.urls import reverse, NoReverseMatch
|
|
from django.views import generic
|
|
|
|
|
|
class RootView(generic.TemplateView):
|
|
template_name = 'dav_base/root.html'
|
|
|
|
def get_context_data(self, **kwargs):
|
|
c = super(RootView, self).get_context_data(**kwargs)
|
|
root_urls = []
|
|
for module_meta_obj in settings.MODULE_CONFIG.modules.values():
|
|
root_url_name = 'root'
|
|
if module_meta_obj.url_namespace:
|
|
root_url_name = '%s:%s' % (module_meta_obj.url_namespace, root_url_name)
|
|
try:
|
|
reverse(root_url_name)
|
|
root_urls.append((module_meta_obj.app, root_url_name))
|
|
except NoReverseMatch:
|
|
pass
|
|
|
|
c['root_urls'] = root_urls
|
|
return c
|