Refactor: split code into several django apps (we call them modules).
This commit is contained in:
23
dav_base/views.py
Normal file
23
dav_base/views.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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
|
||||
Reference in New Issue
Block a user