Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

newforms-admin: Fixed #7466 -- Generate a root_path for admindocs vie…

…ws so the userlinks are properly linked. Thanks handelaar for the report.

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7934 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 584c41aff77bdee0d2e20c6741b7698d3be524f5 1 parent 885ade7
Brian Rosner authored July 16, 2008
1  django/contrib/admin/templates/admin_doc/bookmarklets.html
... ...
@@ -1,7 +1,6 @@
1 1
 {% extends "admin/base_site.html" %}
2 2
 
3 3
 {% block breadcrumbs %}{% load i18n %}<div class="breadcrumbs"><a href="../../">{% trans "Home" %}</a> &rsaquo; <a href="../">{% trans "Documentation" %}</a> &rsaquo; {% trans "Bookmarklets" %}</div>{% endblock %}
4  
-{% block userlinks %}<a href="../../password_change/">{% trans 'Change password' %}</a> / <a href="../../logout/">{% trans 'Log out' %}</a>{% endblock %}
5 4
 {% block title %}{% trans "Documentation bookmarklets" %}{% endblock %}
6 5
 
7 6
 {% block content %}
1  django/contrib/admin/templates/admin_doc/missing_docutils.html
... ...
@@ -1,7 +1,6 @@
1 1
 {% extends "admin/base_site.html" %}
2 2
 {% load i18n %}
3 3
 {% block breadcrumbs %}<div class="breadcrumbs"><a href="../">Home</a> &rsaquo; Documentation</div>{% endblock %}
4  
-{% block userlinks %}<a href="../password_change/">{% trans 'Change password' %}</a> / <a href="../logout/">{% trans 'Log out' %}</a>{% endblock %}
5 4
 {% block title %}Please install docutils{% endblock %}
6 5
 
7 6
 {% block content %}
1  django/contrib/admin/templates/admin_doc/model_detail.html
... ...
@@ -1,6 +1,5 @@
1 1
 {% extends "admin/base_site.html" %}
2 2
 {% load i18n %}
3  
-{% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %}
4 3
 {% block extrahead %}
5 4
 {{ block.super }}
6 5
 <style type="text/css">
1  django/contrib/admin/templates/admin_doc/model_index.html
@@ -2,7 +2,6 @@
2 2
 {% load i18n %}
3 3
 {% block coltype %}colSM{% endblock %}
4 4
 {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; Models</div>{% endblock %}
5  
-{% block userlinks %}<a href="../../password_change/">{% trans 'Change password' %}</a> / <a href="../../logout/">{% trans 'Log out' %}</a>{% endblock %}
6 5
 
7 6
 {% block title %}Models{% endblock %}
8 7
 
1  django/contrib/admin/templates/admin_doc/template_detail.html
... ...
@@ -1,7 +1,6 @@
1 1
 {% extends "admin/base_site.html" %}
2 2
 {% load i18n %}
3 3
 {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> &rsaquo; <a href="../../">Documentation</a> &rsaquo; Templates &rsaquo; {{ name|escape }}</div>{% endblock %}
4  
-{% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %}
5 4
 
6 5
 {% block title %}Template: {{ name|escape }}{% endblock %}
7 6
 
1  django/contrib/admin/templates/admin_doc/template_filter_index.html
@@ -2,7 +2,6 @@
2 2
 {% load i18n %}
3 3
 {% block coltype %}colSM{% endblock %}
4 4
 {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; filters</div>{% endblock %}
5  
-{% block userlinks %}<a href="../../password_change/">{% trans 'Change password' %}</a> / <a href="../../logout/">{% trans 'Log out' %}</a>{% endblock %}
6 5
 {% block title %}Template filters{% endblock %}
7 6
 
8 7
 {% block content %}
1  django/contrib/admin/templates/admin_doc/template_tag_index.html
@@ -2,7 +2,6 @@
2 2
 {% load i18n %}
3 3
 {% block coltype %}colSM{% endblock %}
4 4
 {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">Home</a> &rsaquo; <a href="../">Documentation</a> &rsaquo; Tags</div>{% endblock %}
5  
-{% block userlinks %}<a href="../../password_change/">{% trans 'Change password' %}</a> / <a href="../../logout/">{% trans 'Log out' %}</a>{% endblock %}
6 5
 {% block title %}Template tags{% endblock %}
7 6
 
8 7
 {% block content %}
1  django/contrib/admin/templates/admin_doc/view_detail.html
... ...
@@ -1,7 +1,6 @@
1 1
 {% extends "admin/base_site.html" %}
2 2
 {% load i18n %}
3 3
 {% block breadcrumbs %}<div class="breadcrumbs"><a href="../../../">Home</a> &rsaquo; <a href="../../">Documentation</a> &rsaquo; <a href="../">Views</a> &rsaquo; {{ name }}</div>{% endblock %}
4  
-{% block userlinks %}<a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %}
5 4
 {% block title %}View: {{ name }}{% endblock %}
6 5
 
7 6
 {% block content %}
42  django/contrib/admindocs/views.py
@@ -23,13 +23,18 @@ class GenericSite(object):
23 23
 def doc_index(request):
24 24
     if not utils.docutils_is_available:
25 25
         return missing_docutils_page(request)
26  
-    return render_to_response('admin_doc/index.html', context_instance=RequestContext(request))
  26
+    root_path = re.sub(re.escape('doc/') + '$', '', request.path)
  27
+    return render_to_response('admin_doc/index.html', {
  28
+        'root_path': root_path,
  29
+    }, context_instance=RequestContext(request))
27 30
 doc_index = staff_member_required(doc_index)
28 31
 
29 32
 def bookmarklets(request):
30 33
     # Hack! This couples this view to the URL it lives at.
31 34
     admin_root = request.path[:-len('doc/bookmarklets/')]
  35
+    root_path = re.sub(re.escape('doc/bookmarklets/') + '$', '', request.path)
32 36
     return render_to_response('admin_doc/bookmarklets.html', {
  37
+        'root_path': root_path,
33 38
         'admin_url': mark_safe("%s://%s%s" % (request.is_secure() and 'https' or 'http', request.get_host(), admin_root)),
34 39
     }, context_instance=RequestContext(request))
35 40
 bookmarklets = staff_member_required(bookmarklets)
@@ -61,8 +66,11 @@ def template_tag_index(request):
61 66
                 'meta': metadata,
62 67
                 'library': tag_library,
63 68
             })
64  
-
65  
-    return render_to_response('admin_doc/template_tag_index.html', {'tags': tags}, context_instance=RequestContext(request))
  69
+    root_path = re.sub(re.escape('doc/tags/') + '$', '', request.path)
  70
+    return render_to_response('admin_doc/template_tag_index.html', {
  71
+        'root_path': root_path,
  72
+        'tags': tags
  73
+    }, context_instance=RequestContext(request))
66 74
 template_tag_index = staff_member_required(template_tag_index)
67 75
 
68 76
 def template_filter_index(request):
@@ -92,7 +100,11 @@ def template_filter_index(request):
92 100
                 'meta': metadata,
93 101
                 'library': tag_library,
94 102
             })
95  
-    return render_to_response('admin_doc/template_filter_index.html', {'filters': filters}, context_instance=RequestContext(request))
  103
+    root_path = re.sub(re.escape('doc/filters/') + '$', '', request.path)
  104
+    return render_to_response('admin_doc/template_filter_index.html', {
  105
+        'root_path': root_path,
  106
+        'filters': filters
  107
+    }, context_instance=RequestContext(request))
96 108
 template_filter_index = staff_member_required(template_filter_index)
97 109
 
98 110
 def view_index(request):
@@ -120,7 +132,11 @@ def view_index(request):
120 132
                 'site': site_obj,
121 133
                 'url': simplify_regex(regex),
122 134
             })
123  
-    return render_to_response('admin_doc/view_index.html', {'views': views}, context_instance=RequestContext(request))
  135
+    root_path = re.sub(re.escape('doc/views/') + '$', '', request.path)
  136
+    return render_to_response('admin_doc/view_index.html', {
  137
+        'root_path': root_path,
  138
+        'views': views
  139
+    }, context_instance=RequestContext(request))
124 140
 view_index = staff_member_required(view_index)
125 141
 
126 142
 def view_detail(request, view):
@@ -139,7 +155,9 @@ def view_detail(request, view):
139 155
         body = utils.parse_rst(body, 'view', _('view:') + view)
140 156
     for key in metadata:
141 157
         metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view)
  158
+    root_path = re.sub(re.escape('doc/views/%s/' % view) + '$', '', request.path)
142 159
     return render_to_response('admin_doc/view_detail.html', {
  160
+        'root_path': root_path,
143 161
         'name': view,
144 162
         'summary': title,
145 163
         'body': body,
@@ -150,15 +168,18 @@ def view_detail(request, view):
150 168
 def model_index(request):
151 169
     if not utils.docutils_is_available:
152 170
         return missing_docutils_page(request)
153  
-
154 171
     m_list = [m._meta for m in models.get_models()]
155  
-    return render_to_response('admin_doc/model_index.html', {'models': m_list}, context_instance=RequestContext(request))
  172
+    root_path = re.sub(re.escape('doc/models/') + '$', '', request.path)
  173
+    return render_to_response('admin_doc/model_index.html', {
  174
+        'root_path': root_path,
  175
+        'models': m_list
  176
+    }, context_instance=RequestContext(request))
156 177
 model_index = staff_member_required(model_index)
157 178
 
158 179
 def model_detail(request, app_label, model_name):
159 180
     if not utils.docutils_is_available:
160 181
         return missing_docutils_page(request)
161  
-
  182
+        
162 183
     # Get the model class.
163 184
     try:
164 185
         app_mod = models.get_app(app_label)
@@ -225,8 +246,9 @@ def model_detail(request, app_label, model_name):
225 246
             'data_type' : 'Integer',
226 247
             'verbose'   : utils.parse_rst(_("number of %s") % verbose , 'model', _('model:') + opts.module_name),
227 248
         })
228  
-
  249
+    root_path = re.sub(re.escape('doc/models/%s.%s/' % (app_label, model_name)) + '$', '', request.path)
229 250
     return render_to_response('admin_doc/model_detail.html', {
  251
+        'root_path': root_path,
230 252
         'name': '%s.%s' % (opts.app_label, opts.object_name),
231 253
         'summary': _("Fields on %s objects") % opts.object_name,
232 254
         'description': model.__doc__,
@@ -252,7 +274,9 @@ def template_detail(request, template):
252 274
                 'site': site_obj,
253 275
                 'order': list(settings_mod.TEMPLATE_DIRS).index(dir),
254 276
             })
  277
+    root_path = re.sub(re.escape('doc/templates/%s/' % template) + '$', '', request.path)
255 278
     return render_to_response('admin_doc/template_detail.html', {
  279
+        'root_path': root_path,
256 280
         'name': template,
257 281
         'templates': templates,
258 282
     }, context_instance=RequestContext(request))

0 notes on commit 584c41a

Please sign in to comment.
Something went wrong with that request. Please try again.