magic-removal: Continued simplification of AdminBoundManipulator. Removed a few of its attributes

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2085 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-01-21 04:21:54 +00:00
parent cdb7a51098
commit 861960f311
3 changed files with 8 additions and 11 deletions

View File

@ -4,7 +4,7 @@
<script type="text/javascript" src="../../../jsi18n/"></script>
{% for js in bound_manipulator.javascript_imports %}{% include_admin_script js %}{% endfor %}
{% endblock %}
{% block coltype %}{{ bound_manipulator.coltype }}{% endblock %}
{% block coltype %}{% if opts.get_ordered_objects %}colMS{% else %}colM{% endif %}{% endblock %}
{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %}
{% block userlinks %}<a href="../../../doc/">{% trans 'Documentation' %}</a> / <a href="../../../password_change/">{% trans 'Change password' %}</a> / <a href="../../../logout/">{% trans 'Log out' %}</a>{% endblock %}
{% block breadcrumbs %}{% if not is_popup %}
@ -41,7 +41,7 @@
{% endfor %}
{% block after_field_sets %}{% endblock %}
{% if change %}
{% if bound_manipulator.ordered_objects %}
{% if opts.get_ordered_objects %}
<fieldset class="module"><h2>{% trans "Ordering" %}</h2>
<div class="form-row{% if form.order_.errors %} error{% endif %} ">
{% if form.order_.errors %}{{ form.order_.html_error_list }}{% endif %}
@ -61,7 +61,7 @@
</script>
{% endif %}
{% if change %}
{% if bound_manipulator.ordered_objects %}
{% if opts.get_ordered_objects %}
{% if form.order_objects %}<ul id="orderthese">
{% for object in form.order_objects %}
<li id="p{% object_pk bound_manipulator object %}">

View File

@ -23,15 +23,16 @@ def include_admin_script(script_path):
include_admin_script = register.simple_tag(include_admin_script)
def submit_row(context, bound_manipulator):
opts = context['opts']
change = context['change']
is_popup = context['is_popup']
return {
'onclick_attrib': (bound_manipulator.ordered_objects and change
'onclick_attrib': (opts.ordered_objects and change
and 'onclick="submitOrderForm();"' or ''),
'show_delete_link': (not is_popup and context['has_delete_permission']
and (change or context['show_delete'])),
'show_save_as_new': not is_popup and change and bound_manipulator.save_as,
'show_save_and_add_another': not is_popup and (not bound_manipulator.save_as or context['add']),
'show_save_as_new': not is_popup and change and opts.admin.save_as,
'show_save_and_add_another': not is_popup and (not opts.admin.save_as or context['add']),
'show_save_and_continue': not is_popup,
'show_save': True
}

View File

@ -144,7 +144,6 @@ class BoundManipulator(object):
self.original = getattr(manipulator, 'original_object', None)
self.bound_field_sets = [field_set.bind(field_mapping, self.original, AdminBoundFieldSet)
for field_set in self.opts.admin.get_field_sets(self.opts)]
self.ordered_objects = self.opts.get_ordered_objects()[:]
class AdminBoundManipulator(BoundManipulator):
def __init__(self, model, manipulator, field_mapping):
@ -153,13 +152,10 @@ class AdminBoundManipulator(BoundManipulator):
self.auto_populated_fields = [f for f in self.opts.fields if f.prepopulate_from]
self.javascript_imports = get_javascript_imports(self.opts, self.auto_populated_fields, field_sets);
self.coltype = self.ordered_objects and 'colMS' or 'colM'
self.has_absolute_url = hasattr(model, 'get_absolute_url')
self.form_enc_attrib = self.opts.has_field_type(models.FileField) and 'enctype="multipart/form-data" ' or ''
self.first_form_field_id = self.bound_field_sets[0].bound_field_lines[0].bound_fields[0].form_fields[0].get_id();
self.ordered_object_pk_names = [o.pk.name for o in self.ordered_objects]
self.save_as = self.opts.admin.save_as
self.verbose_name = self.opts.verbose_name
self.ordered_object_pk_names = [o.pk.name for o in self.opts.get_ordered_objects()]
def get_ordered_object_pk(self, ordered_obj):
for name in self.ordered_object_pk_names: