summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2005-08-02 20:29:27 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2005-08-02 20:29:27 +0000
commit49c670871634e78d588cba21f84b094479f2aa4f (patch)
tree7e0af7cca014b482887cf81f26089225f94944a5
parentce0d0cd9e2cd5ac9850d825f28db39b1e123ac1e (diff)
Added doc view for templates that will show the search path for a given template on each site
git-svn-id: http://code.djangoproject.com/svn/django/trunk@392 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/conf/admin_templates/doc/template_detail.html21
-rw-r--r--django/conf/urls/admin.py2
-rw-r--r--django/views/admin/doc.py21
3 files changed, 44 insertions, 0 deletions
diff --git a/django/conf/admin_templates/doc/template_detail.html b/django/conf/admin_templates/doc/template_detail.html
new file mode 100644
index 0000000000..374b737022
--- /dev/null
+++ b/django/conf/admin_templates/doc/template_detail.html
@@ -0,0 +1,21 @@
+{% extends "base_site" %}
+
+{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> &rsaquo; <a href="../../">Documentation</a> &rsaquo; Templates &rsaquo; {{ name }}</div>{% endblock %}
+
+{% block title %}Template: {{ name }}{% endblock %}
+
+{% block content %}
+<h1>Template: "{{ name }}"</h1>
+
+{% regroup templates|dictsort:"site_id" by site as templates_by_site %}
+{% for group in templates_by_site %}
+ <h2>Search path for template "{{ name }}" on {{ group.grouper }}:</h2>
+ <ol>
+ {% for template in group.list|dictsort:"order" %}
+ <li><code>{{ template.file }}</code>{% if not template.exists %} <em>(does not exist)</em>{% endif %}</li>
+ {% endfor %}
+ </ol>
+{% endfor %}
+
+<p class="small"><a href="../../">&lsaquo; Back to Documentation</a></p>
+{% endblock %}
diff --git a/django/conf/urls/admin.py b/django/conf/urls/admin.py
index a55da5d366..89b7040472 100644
--- a/django/conf/urls/admin.py
+++ b/django/conf/urls/admin.py
@@ -18,6 +18,8 @@ urlpatterns = (
('^doc/views/(?P<view>[^/]+)/$', 'django.views.admin.doc.view_detail'),
('^doc/models/$', 'django.views.admin.doc.model_index'),
('^doc/models/(?P<model>[^/]+)/$', 'django.views.admin.doc.model_detail'),
+# ('^doc/templates/$', 'django.views.admin.doc.template_index'),
+ ('^doc/templates/(?P<template>.*)/$', 'django.views.admin.doc.template_detail'),
)
if 'ellington.events' in INSTALLED_APPS:
diff --git a/django/views/admin/doc.py b/django/views/admin/doc.py
index 99250333b8..1ebb6cee89 100644
--- a/django/views/admin/doc.py
+++ b/django/views/admin/doc.py
@@ -218,6 +218,27 @@ def model_detail(request, model):
})
return HttpResponse(t.render(c))
+def template_detail(request, template):
+ templates = []
+ for site_settings_module in settings.ADMIN_FOR:
+ settings_mod = __import__(site_settings_module, '', '', [''])
+ for dir in settings_mod.TEMPLATE_DIRS:
+ template_file = os.path.join(dir, "%s.html" % template)
+ templates.append({
+ 'file' : template_file,
+ 'exists' : os.path.exists(template_file),
+ 'contents' : lambda: os.path.exists(template_file) and open(template_file).read() or '',
+ 'site_id' : settings_mod.SITE_ID,
+ 'site' : sites.get_object(pk=settings_mod.SITE_ID),
+ 'order' : list(settings_mod.TEMPLATE_DIRS).index(dir),
+ })
+ t = template_loader.get_template('doc/template_detail')
+ c = Context(request, {
+ 'name' : template,
+ 'templates' : templates,
+ })
+ return HttpResponse(t.render(c))
+
####################
# Helper functions #
####################