Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

newforms-admin: Fixed #6604 - removed useless code. Thanks Petr Marho…

…un, programmerq

git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7736 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 56584a66523b6811c03eb47d26389746965b2535 1 parent cf43828
@spookylukey spookylukey authored
View
1  django/contrib/admin/templates/widget/default.html
@@ -1 +0,0 @@
-{% load admin_modify %}{% output_all bound_field.form_fields %}
View
4 django/contrib/admin/templates/widget/file.html
@@ -1,4 +0,0 @@
-{% load admin_modify i18n %}{% if bound_field.original_value %}
-{% trans "Currently:" %} <a href="{{ bound_field.original_url }}" > {{ bound_field.original_value|escape }} </a><br />
-{% trans "Change:" %}{% output_all bound_field.form_fields %}
-{% else %} {% output_all bound_field.form_fields %} {% endif %}
View
10 django/contrib/admin/templates/widget/foreign.html
@@ -1,10 +0,0 @@
-{% load admin_modify adminmedia %}
-{% output_all bound_field.form_fields %}
-{% if change %}
- {% if bound_field.field.primary_key %}
- {{ bound_field.original_value }}
- {% endif %}
- {% if bound_field.raw_id_admin %}
- {% if bound_field.existing_display %}&nbsp;<strong>{{ bound_field.existing_display|truncatewords:"14"|escape }}</strong>{% endif %}
- {% endif %}
-{% endif %}
View
85 django/contrib/admin/templatetags/admin_modify.py
@@ -1,21 +1,7 @@
from django import template
-from django.contrib.admin.views.main import AdminBoundField
-from django.template import loader
-from django.utils.text import capfirst
-from django.utils.encoding import force_unicode
-from django.db import models
-from django.db.models.fields import Field
-from django.db.models.related import BoundRelatedObject
-from django.conf import settings
-import re
register = template.Library()
-word_re = re.compile('[A-Z][a-z]+')
-
-def class_name_to_underscored(name):
- return u'_'.join([s.lower() for s in word_re.findall(name)[:-1]])
-
def submit_row(context):
opts = context['opts']
change = context['change']
@@ -33,74 +19,3 @@ def submit_row(context):
'show_save': True
}
submit_row = register.inclusion_tag('admin/submit_line.html', takes_context=True)(submit_row)
-
-class FieldWidgetNode(template.Node):
- nodelists = {}
- default = None
-
- def __init__(self, bound_field_var):
- self.bound_field_var = template.Variable(bound_field_var)
-
- def get_nodelist(cls, klass):
- if klass not in cls.nodelists:
- try:
- field_class_name = klass.__name__
- template_name = u"widget/%s.html" % class_name_to_underscored(field_class_name)
- nodelist = loader.get_template(template_name).nodelist
- except template.TemplateDoesNotExist:
- super_klass = bool(klass.__bases__) and klass.__bases__[0] or None
- if super_klass and super_klass != Field:
- nodelist = cls.get_nodelist(super_klass)
- else:
- if not cls.default:
- cls.default = loader.get_template("widget/default.html").nodelist
- nodelist = cls.default
-
- cls.nodelists[klass] = nodelist
- return nodelist
- else:
- return cls.nodelists[klass]
- get_nodelist = classmethod(get_nodelist)
-
- def render(self, context):
- bound_field = self.bound_field_var.resolve(context)
-
- context.push()
- context['bound_field'] = bound_field
-
- output = self.get_nodelist(bound_field.field.__class__).render(context)
- context.pop()
- return output
-
-class FieldWrapper(object):
- def __init__(self, field ):
- self.field = field
-
- def needs_header(self):
- return not isinstance(self.field, models.AutoField)
-
- def header_class_attribute(self):
- return self.field.blank and mark_safe(' class="optional"') or ''
-
- def use_raw_id_admin(self):
- return isinstance(self.field.rel, (models.ManyToOneRel, models.ManyToManyRel)) \
- and self.field.rel.raw_id_admin
-
-class FormFieldCollectionWrapper(object):
- def __init__(self, field_mapping, fields, index):
- self.field_mapping = field_mapping
- self.fields = fields
- self.bound_fields = [AdminBoundField(field, self.field_mapping, field_mapping['original'])
- for field in self.fields]
- self.index = index
-
-def output_all(form_fields):
- return u''.join([force_unicode(f) for f in form_fields])
-output_all = register.simple_tag(output_all)
-
-def field_widget(parser, token):
- bits = token.contents.split()
- if len(bits) != 2:
- raise template.TemplateSyntaxError, "%s takes 1 argument" % bits[0]
- return FieldWidgetNode(bits[1])
-field_widget = register.tag(field_widget)
View
22 django/contrib/admin/urls.py
@@ -1,22 +0,0 @@
-from django.conf.urls.defaults import *
-
-# This file is NO LONGER USED in newforms-admin. See AdminSite.root() and
-# django.contrib.auth.admin instead.
-
-urlpatterns = patterns('',
- #('^$', 'django.contrib.admin.views.main.index'),
- ('^r/', include('django.conf.urls.shortcut')),
- #('^jsi18n/$', i18n_view, {'packages': 'django.conf'}),
- #('^logout/$', 'django.contrib.auth.views.logout'),
- #('^password_change/$', 'django.contrib.auth.views.password_change'),
- #('^password_change/done/$', 'django.contrib.auth.views.password_change_done'),
- ('^template_validator/$', 'django.contrib.admin.views.template.template_validator'),
-
- # "Add user" -- a special-case view
- ('^auth/user/add/$', 'django.contrib.admin.views.auth.user_add_stage'),
- # "Change user password" -- another special-case view
- ('^auth/user/(\d+)/password/$', 'django.contrib.admin.views.auth.user_change_password'),
-
- # Model-specific admin pages.
- ('^([^/]+)/([^/]+)/(?:(.+)/)?$', 'django.contrib.admin.views.main.model_admin_view'),
-)
View
70 django/contrib/admin/views/main.py
@@ -1,13 +1,8 @@
-from django import template
from django.contrib.admin.filterspecs import FilterSpec
from django.contrib.admin.options import IncorrectLookupParameters
-from django.contrib.admin.views.decorators import staff_member_required
-from django.views.decorators.cache import never_cache
from django.core.paginator import QuerySetPaginator, InvalidPage
-from django.shortcuts import render_to_response
from django.db import models
from django.db.models.query import QuerySet
-from django.http import Http404
from django.utils.encoding import force_unicode, smart_str
from django.utils.translation import ugettext
from django.utils.safestring import mark_safe
@@ -34,8 +29,6 @@
# Text to display within change-list table cells if the value is blank.
EMPTY_CHANGELIST_VALUE = '(None)'
-use_raw_id_admin = lambda field: isinstance(field.rel, (models.ManyToOneRel, models.ManyToManyRel)) and field.rel.raw_id_admin
-
def quote(s):
"""
Ensure that primary key values do not confuse the admin URLs by escaping
@@ -52,69 +45,6 @@ def quote(s):
res[i] = '_%02X' % ord(c)
return ''.join(res)
-def model_admin_view(request, app_label, model_name, rest_of_url):
- model = models.get_model(app_label, model_name)
- if model is None:
- raise Http404("App %r, model %r, not found" % (app_label, model_name))
- if not model._meta.admin:
- raise Http404("This object has no admin interface.")
- mav = model._meta.admin(model)
- return mav(request, rest_of_url)
-model_admin_view = staff_member_required(never_cache(model_admin_view))
-
-class AdminBoundField(object):
- def __init__(self, field, field_mapping, original):
- self.field = field
- self.original = original
- self.form_fields = [field_mapping[name] for name in self.field.get_manipulator_field_names('')]
- self.has_label_first = not isinstance(self.field, models.BooleanField)
- self.raw_id_admin = use_raw_id_admin(field)
- self.is_date_time = isinstance(field, models.DateTimeField)
- self.is_file_field = isinstance(field, models.FileField)
- self.hidden = isinstance(self.field, models.AutoField)
- self.first = False
-
- classes = []
- if self.raw_id_admin:
- classes.append(u'nowrap')
- if max([bool(f.errors()) for f in self.form_fields]):
- classes.append(u'error')
- if classes:
- self.cell_class_attribute = u' class="%s" ' % ' '.join(classes)
- self._repr_filled = False
-
- def original_value(self):
- if self.original:
- return self.original.__dict__[self.field.attname]
-
- def existing_display(self):
- try:
- return self._display
- except AttributeError:
- if isinstance(self.field.rel, models.ManyToOneRel):
- self._display = force_unicode(getattr(self.original, self.field.name), strings_only=True)
- elif isinstance(self.field.rel, models.ManyToManyRel):
- self._display = u", ".join([force_unicode(obj) for obj in getattr(self.original, self.field.name).all()])
- return self._display
-
- def __repr__(self):
- return repr(self.__dict__)
-
- def html_error_list(self):
- return mark_safe(" ".join([form_field.html_error_list() for form_field in self.form_fields if form_field.errors]))
-
- def original_url(self):
- if self.is_file_field and self.original and self.field.attname:
- url_method = getattr(self.original, 'get_%s_url' % self.field.attname)
- if callable(url_method):
- return url_method()
- return ''
-
-def index(request):
- return render_to_response('admin/index.html', {'title': ugettext('Site administration')}, context_instance=template.RequestContext(request))
-index = staff_member_required(never_cache(index))
-
-
class ChangeList(object):
def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields, list_select_related, list_per_page, model_admin):
self.model = model
Please sign in to comment.
Something went wrong with that request. Please try again.