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 #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
Luke Plant authored June 24, 2008
1  django/contrib/admin/templates/widget/default.html
... ...
@@ -1 +0,0 @@
1  
-{% load admin_modify %}{% output_all bound_field.form_fields %}
4  django/contrib/admin/templates/widget/file.html
... ...
@@ -1,4 +0,0 @@
1  
-{% load admin_modify i18n %}{% if bound_field.original_value %}
2  
-{% trans "Currently:" %} <a href="{{ bound_field.original_url }}" > {{ bound_field.original_value|escape }} </a><br />
3  
-{% trans "Change:" %}{% output_all bound_field.form_fields %}
4  
-{% else %} {% output_all bound_field.form_fields %} {% endif %}
10  django/contrib/admin/templates/widget/foreign.html
... ...
@@ -1,10 +0,0 @@
1  
-{% load admin_modify adminmedia %}
2  
-{% output_all bound_field.form_fields %}
3  
-{% if change %}
4  
-    {% if bound_field.field.primary_key %}
5  
-        {{ bound_field.original_value }}
6  
-    {% endif %}
7  
-    {% if bound_field.raw_id_admin %}
8  
-        {% if bound_field.existing_display %}&nbsp;<strong>{{ bound_field.existing_display|truncatewords:"14"|escape }}</strong>{% endif %}
9  
-    {% endif %}
10  
-{% endif %}
85  django/contrib/admin/templatetags/admin_modify.py
... ...
@@ -1,21 +1,7 @@
1 1
 from django import template
2  
-from django.contrib.admin.views.main import AdminBoundField
3  
-from django.template import loader
4  
-from django.utils.text import capfirst
5  
-from django.utils.encoding import force_unicode
6  
-from django.db import models
7  
-from django.db.models.fields import Field
8  
-from django.db.models.related import BoundRelatedObject
9  
-from django.conf import settings
10  
-import re
11 2
 
12 3
 register = template.Library()
13 4
 
14  
-word_re = re.compile('[A-Z][a-z]+')
15  
-
16  
-def class_name_to_underscored(name):
17  
-    return u'_'.join([s.lower() for s in word_re.findall(name)[:-1]])
18  
-
19 5
 def submit_row(context):
20 6
     opts = context['opts']
21 7
     change = context['change']
@@ -33,74 +19,3 @@ def submit_row(context):
33 19
         'show_save': True
34 20
     }
35 21
 submit_row = register.inclusion_tag('admin/submit_line.html', takes_context=True)(submit_row)
36  
-
37  
-class FieldWidgetNode(template.Node):
38  
-    nodelists = {}
39  
-    default = None
40  
-
41  
-    def __init__(self, bound_field_var):
42  
-        self.bound_field_var = template.Variable(bound_field_var)
43  
-
44  
-    def get_nodelist(cls, klass):
45  
-        if klass not in cls.nodelists:
46  
-            try:
47  
-                field_class_name = klass.__name__
48  
-                template_name = u"widget/%s.html" % class_name_to_underscored(field_class_name)
49  
-                nodelist = loader.get_template(template_name).nodelist
50  
-            except template.TemplateDoesNotExist:
51  
-                super_klass = bool(klass.__bases__) and klass.__bases__[0] or None
52  
-                if super_klass and super_klass != Field:
53  
-                    nodelist = cls.get_nodelist(super_klass)
54  
-                else:
55  
-                    if not cls.default:
56  
-                        cls.default = loader.get_template("widget/default.html").nodelist
57  
-                    nodelist = cls.default
58  
-
59  
-            cls.nodelists[klass] = nodelist
60  
-            return nodelist
61  
-        else:
62  
-            return cls.nodelists[klass]
63  
-    get_nodelist = classmethod(get_nodelist)
64  
-
65  
-    def render(self, context):
66  
-        bound_field = self.bound_field_var.resolve(context)
67  
-
68  
-        context.push()
69  
-        context['bound_field'] = bound_field
70  
-
71  
-        output = self.get_nodelist(bound_field.field.__class__).render(context)
72  
-        context.pop()
73  
-        return output
74  
-
75  
-class FieldWrapper(object):
76  
-    def __init__(self, field ):
77  
-        self.field = field
78  
-
79  
-    def needs_header(self):
80  
-        return not isinstance(self.field, models.AutoField)
81  
-
82  
-    def header_class_attribute(self):
83  
-        return self.field.blank and mark_safe(' class="optional"') or ''
84  
-
85  
-    def use_raw_id_admin(self):
86  
-        return isinstance(self.field.rel, (models.ManyToOneRel, models.ManyToManyRel)) \
87  
-            and self.field.rel.raw_id_admin
88  
-
89  
-class FormFieldCollectionWrapper(object):
90  
-    def __init__(self, field_mapping, fields, index):
91  
-        self.field_mapping = field_mapping
92  
-        self.fields = fields
93  
-        self.bound_fields = [AdminBoundField(field, self.field_mapping, field_mapping['original'])
94  
-                             for field in self.fields]
95  
-        self.index = index
96  
-
97  
-def output_all(form_fields):
98  
-    return u''.join([force_unicode(f) for f in form_fields])
99  
-output_all = register.simple_tag(output_all)
100  
-
101  
-def field_widget(parser, token):
102  
-    bits = token.contents.split()
103  
-    if len(bits) != 2:
104  
-        raise template.TemplateSyntaxError, "%s takes 1 argument" % bits[0]
105  
-    return FieldWidgetNode(bits[1])
106  
-field_widget = register.tag(field_widget)
22  django/contrib/admin/urls.py
... ...
@@ -1,22 +0,0 @@
1  
-from django.conf.urls.defaults import *
2  
-
3  
-# This file is NO LONGER USED in newforms-admin. See AdminSite.root() and 
4  
-# django.contrib.auth.admin instead.
5  
-
6  
-urlpatterns = patterns('',
7  
-    #('^$', 'django.contrib.admin.views.main.index'),
8  
-    ('^r/', include('django.conf.urls.shortcut')),
9  
-    #('^jsi18n/$', i18n_view, {'packages': 'django.conf'}),
10  
-    #('^logout/$', 'django.contrib.auth.views.logout'),
11  
-    #('^password_change/$', 'django.contrib.auth.views.password_change'),
12  
-    #('^password_change/done/$', 'django.contrib.auth.views.password_change_done'),
13  
-    ('^template_validator/$', 'django.contrib.admin.views.template.template_validator'),
14  
-
15  
-    # "Add user" -- a special-case view
16  
-    ('^auth/user/add/$', 'django.contrib.admin.views.auth.user_add_stage'),
17  
-    # "Change user password" -- another special-case view
18  
-    ('^auth/user/(\d+)/password/$', 'django.contrib.admin.views.auth.user_change_password'),
19  
-
20  
-    # Model-specific admin pages.
21  
-    ('^([^/]+)/([^/]+)/(?:(.+)/)?$', 'django.contrib.admin.views.main.model_admin_view'),
22  
-)
70  django/contrib/admin/views/main.py
... ...
@@ -1,13 +1,8 @@
1  
-from django import template
2 1
 from django.contrib.admin.filterspecs import FilterSpec
3 2
 from django.contrib.admin.options import IncorrectLookupParameters
4  
-from django.contrib.admin.views.decorators import staff_member_required
5  
-from django.views.decorators.cache import never_cache
6 3
 from django.core.paginator import QuerySetPaginator, InvalidPage
7  
-from django.shortcuts import render_to_response
8 4
 from django.db import models
9 5
 from django.db.models.query import QuerySet
10  
-from django.http import Http404
11 6
 from django.utils.encoding import force_unicode, smart_str
12 7
 from django.utils.translation import ugettext
13 8
 from django.utils.safestring import mark_safe
@@ -34,8 +29,6 @@
34 29
 # Text to display within change-list table cells if the value is blank.
35 30
 EMPTY_CHANGELIST_VALUE = '(None)'
36 31
 
37  
-use_raw_id_admin = lambda field: isinstance(field.rel, (models.ManyToOneRel, models.ManyToManyRel)) and field.rel.raw_id_admin
38  
-
39 32
 def quote(s):
40 33
     """
41 34
     Ensure that primary key values do not confuse the admin URLs by escaping
@@ -52,69 +45,6 @@ def quote(s):
52 45
             res[i] = '_%02X' % ord(c)
53 46
     return ''.join(res)
54 47
 
55  
-def model_admin_view(request, app_label, model_name, rest_of_url):
56  
-    model = models.get_model(app_label, model_name)
57  
-    if model is None:
58  
-        raise Http404("App %r, model %r, not found" % (app_label, model_name))
59  
-    if not model._meta.admin:
60  
-        raise Http404("This object has no admin interface.")
61  
-    mav = model._meta.admin(model)
62  
-    return mav(request, rest_of_url)
63  
-model_admin_view = staff_member_required(never_cache(model_admin_view))
64  
-
65  
-class AdminBoundField(object):
66  
-    def __init__(self, field, field_mapping, original):
67  
-        self.field = field
68  
-        self.original = original
69  
-        self.form_fields = [field_mapping[name] for name in self.field.get_manipulator_field_names('')]
70  
-        self.has_label_first = not isinstance(self.field, models.BooleanField)
71  
-        self.raw_id_admin = use_raw_id_admin(field)
72  
-        self.is_date_time = isinstance(field, models.DateTimeField)
73  
-        self.is_file_field = isinstance(field, models.FileField)
74  
-        self.hidden = isinstance(self.field, models.AutoField)
75  
-        self.first = False
76  
-
77  
-        classes = []
78  
-        if self.raw_id_admin:
79  
-            classes.append(u'nowrap')
80  
-        if max([bool(f.errors()) for f in self.form_fields]):
81  
-            classes.append(u'error')
82  
-        if classes:
83  
-            self.cell_class_attribute = u' class="%s" ' % ' '.join(classes)
84  
-        self._repr_filled = False
85  
-
86  
-    def original_value(self):
87  
-        if self.original:
88  
-            return self.original.__dict__[self.field.attname]
89  
-
90  
-    def existing_display(self):
91  
-        try:
92  
-            return self._display
93  
-        except AttributeError:
94  
-            if isinstance(self.field.rel, models.ManyToOneRel):
95  
-                self._display = force_unicode(getattr(self.original, self.field.name), strings_only=True)
96  
-            elif isinstance(self.field.rel, models.ManyToManyRel):
97  
-                self._display = u", ".join([force_unicode(obj) for obj in getattr(self.original, self.field.name).all()])
98  
-            return self._display
99  
-
100  
-    def __repr__(self):
101  
-        return repr(self.__dict__)
102  
-
103  
-    def html_error_list(self):
104  
-        return mark_safe(" ".join([form_field.html_error_list() for form_field in self.form_fields if form_field.errors]))
105  
-
106  
-    def original_url(self):
107  
-        if self.is_file_field and self.original and self.field.attname:
108  
-            url_method = getattr(self.original, 'get_%s_url' % self.field.attname)
109  
-            if callable(url_method):
110  
-                return url_method()
111  
-        return ''
112  
-
113  
-def index(request):
114  
-    return render_to_response('admin/index.html', {'title': ugettext('Site administration')}, context_instance=template.RequestContext(request))
115  
-index = staff_member_required(never_cache(index))
116  
-
117  
-
118 48
 class ChangeList(object):
119 49
     def __init__(self, request, model, list_display, list_display_links, list_filter, date_hierarchy, search_fields, list_select_related, list_per_page, model_admin):
120 50
         self.model = model

0 notes on commit 56584a6

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