Changeset 8718
- Timestamp:
- 08/29/08 14:29:16 (3 months ago)
- Files:
-
- django/trunk/django/contrib/admindocs/views.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/contrib/admindocs/views.py
r8046 r8718 21 21 name = 'my site' 22 22 23 def get_root_path(): 24 from django.contrib import admin 25 try: 26 return urlresolvers.reverse(admin.site.root, args=['']) 27 except urlresolvers.NoReverseMatch: 28 return getattr(settings, "ADMIN_SITE_ROOT_URL", "/admin/") 29 23 30 def doc_index(request): 24 31 if not utils.docutils_is_available: 25 32 return missing_docutils_page(request) 26 root_path = re.sub(re.escape('doc/') + '$', '', request.path)27 33 return render_to_response('admin_doc/index.html', { 28 'root_path': root_path,34 'root_path': get_root_path(), 29 35 }, context_instance=RequestContext(request)) 30 36 doc_index = staff_member_required(doc_index) 31 37 32 38 def bookmarklets(request): 33 # Hack! This couples this view to the URL it lives at. 34 admin_root = request.path[:-len('doc/bookmarklets/')] 35 root_path = re.sub(re.escape('doc/bookmarklets/') + '$', '', request.path) 39 admin_root = get_root_path() 36 40 return render_to_response('admin_doc/bookmarklets.html', { 37 'root_path': root_path,41 'root_path': admin_root, 38 42 'admin_url': mark_safe("%s://%s%s" % (request.is_secure() and 'https' or 'http', request.get_host(), admin_root)), 39 43 }, context_instance=RequestContext(request)) … … 67 71 'library': tag_library, 68 72 }) 69 root_path = re.sub(re.escape('doc/tags/') + '$', '', request.path)70 73 return render_to_response('admin_doc/template_tag_index.html', { 71 'root_path': root_path,74 'root_path': get_root_path(), 72 75 'tags': tags 73 76 }, context_instance=RequestContext(request)) … … 101 104 'library': tag_library, 102 105 }) 103 root_path = re.sub(re.escape('doc/filters/') + '$', '', request.path)104 106 return render_to_response('admin_doc/template_filter_index.html', { 105 'root_path': root_path,107 'root_path': get_root_path(), 106 108 'filters': filters 107 109 }, context_instance=RequestContext(request)) … … 133 135 'url': simplify_regex(regex), 134 136 }) 135 root_path = re.sub(re.escape('doc/views/') + '$', '', request.path)136 137 return render_to_response('admin_doc/view_index.html', { 137 'root_path': root_path,138 'root_path': get_root_path(), 138 139 'views': views 139 140 }, context_instance=RequestContext(request)) … … 156 157 for key in metadata: 157 158 metadata[key] = utils.parse_rst(metadata[key], 'model', _('view:') + view) 158 root_path = re.sub(re.escape('doc/views/%s/' % view) + '$', '', request.path)159 159 return render_to_response('admin_doc/view_detail.html', { 160 'root_path': root_path,160 'root_path': get_root_path(), 161 161 'name': view, 162 162 'summary': title, … … 170 170 return missing_docutils_page(request) 171 171 m_list = [m._meta for m in models.get_models()] 172 root_path = re.sub(re.escape('doc/models/') + '$', '', request.path)173 172 return render_to_response('admin_doc/model_index.html', { 174 'root_path': root_path,173 'root_path': get_root_path(), 175 174 'models': m_list 176 175 }, context_instance=RequestContext(request)) … … 247 246 'verbose' : utils.parse_rst(_("number of %s") % verbose , 'model', _('model:') + opts.module_name), 248 247 }) 249 root_path = re.sub(re.escape('doc/models/%s.%s/' % (app_label, model_name)) + '$', '', request.path)250 248 return render_to_response('admin_doc/model_detail.html', { 251 'root_path': root_path,249 'root_path': get_root_path(), 252 250 'name': '%s.%s' % (opts.app_label, opts.object_name), 253 251 'summary': _("Fields on %s objects") % opts.object_name, … … 275 273 'order': list(settings_mod.TEMPLATE_DIRS).index(dir), 276 274 }) 277 root_path = re.sub(re.escape('doc/templates/%s/' % template) + '$', '', request.path)278 275 return render_to_response('admin_doc/template_detail.html', { 279 'root_path': root_path,276 'root_path': get_root_path(), 280 277 'name': template, 281 278 'templates': templates,
