mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
new-admin: Negligible formatting changes to admin.templatetags.admin_list and admin.views.main -- and removed multi-line import in templatetags/admin_list, for Python 2.3 compatibility
git-svn-id: http://code.djangoproject.com/svn/django/branches/new-admin@1430 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
8be7d7e544
commit
12dec8023d
@ -1,18 +1,15 @@
|
||||
from django.core.template.decorators import simple_tag, inclusion_tag
|
||||
|
||||
from django.contrib.admin.views.main import MAX_SHOW_ALL_ALLOWED, DEFAULT_RESULTS_PER_PAGE, ALL_VAR, \
|
||||
ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR , SEARCH_VAR , IS_POPUP_VAR, EMPTY_CHANGELIST_VALUE, \
|
||||
MONTHS
|
||||
from django.utils.translation import get_date_formats
|
||||
|
||||
|
||||
from django.core import meta
|
||||
from django.utils.text import capfirst
|
||||
from django.utils.html import strip_tags, escape
|
||||
from django.contrib.admin.views.main import MAX_SHOW_ALL_ALLOWED, DEFAULT_RESULTS_PER_PAGE, ALL_VAR
|
||||
from django.contrib.admin.views.main import ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR, SEARCH_VAR
|
||||
from django.contrib.admin.views.main import IS_POPUP_VAR, EMPTY_CHANGELIST_VALUE, MONTHS
|
||||
from django.core import meta, template
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.conf.settings import ADMIN_MEDIA_PREFIX
|
||||
from django.core import template
|
||||
from django.core.template.decorators import simple_tag, inclusion_tag
|
||||
from django.utils import dateformat
|
||||
from django.utils.html import strip_tags, escape
|
||||
from django.utils.text import capfirst
|
||||
from django.utils.translation import get_date_formats
|
||||
from django.conf.settings import ADMIN_MEDIA_PREFIX
|
||||
|
||||
DOT = '.'
|
||||
|
||||
#@simple_tag
|
||||
@ -59,17 +56,16 @@ def pagination(cl):
|
||||
page_range.extend(range(page_num + 1, paginator.pages))
|
||||
|
||||
need_show_all_link = cl.can_show_all and not cl.show_all and cl.multi_page
|
||||
|
||||
return {'cl': cl,
|
||||
return {
|
||||
'cl': cl,
|
||||
'pagination_required': pagination_required,
|
||||
'show_all_url': need_show_all_link and cl.get_query_string({ALL_VAR: ''}),
|
||||
'page_range': page_range,
|
||||
'ALL_VAR': ALL_VAR,
|
||||
'1': 1
|
||||
'1': 1,
|
||||
}
|
||||
pagination = inclusion_tag('admin/pagination')(pagination)
|
||||
|
||||
|
||||
def result_headers(cl):
|
||||
lookup_opts = cl.lookup_opts
|
||||
|
||||
@ -186,10 +182,9 @@ def result_list(cl):
|
||||
res = list(results(cl))
|
||||
return {'cl': cl,
|
||||
'result_headers': list(result_headers(cl)),
|
||||
'results': list(results(cl)), }
|
||||
'results': list(results(cl))}
|
||||
result_list = inclusion_tag("admin/change_list_results")(result_list)
|
||||
|
||||
|
||||
#@inclusion_tag("admin/date_hierarchy")
|
||||
def date_hierarchy(cl):
|
||||
lookup_opts, params, lookup_params, lookup_mod = \
|
||||
@ -214,10 +209,11 @@ def date_hierarchy(cl):
|
||||
|
||||
if year_lookup and month_lookup and day_lookup:
|
||||
month_name = MONTHS[int(month_lookup)]
|
||||
return { 'show': True,
|
||||
'back':
|
||||
{ 'link' : link({year_field: year_lookup, month_field: month_lookup}),
|
||||
'title': "%s %s" % ( month_name, year_lookup),
|
||||
return {
|
||||
'show': True,
|
||||
'back': {
|
||||
'link': link({year_field: year_lookup, month_field: month_lookup}),
|
||||
'title': "%s %s" % (month_name, year_lookup)
|
||||
},
|
||||
'choices': [{'title': "%s %s" % (month_name, day_lookup)}]
|
||||
}
|
||||
@ -225,48 +221,55 @@ def date_hierarchy(cl):
|
||||
date_lookup_params = lookup_params.copy()
|
||||
date_lookup_params.update({year_field: year_lookup, month_field: month_lookup})
|
||||
days = get_dates('day', date_lookup_params)
|
||||
return { 'show': True,
|
||||
'back':
|
||||
{ 'link' : link({year_field: year_lookup}),
|
||||
return {
|
||||
'show': True,
|
||||
'back': {
|
||||
'link': link({year_field: year_lookup}),
|
||||
'title': year_lookup
|
||||
},
|
||||
'choices':
|
||||
[ { 'link' : link({year_field: year_lookup, month_field: month_lookup, day_field: day.day}),
|
||||
'title': day.strftime('%B %d') } for day in days ]
|
||||
'choices': [{
|
||||
'link': link({year_field: year_lookup, month_field: month_lookup, day_field: day.day}),
|
||||
'title': day.strftime('%B %d')
|
||||
} for day in days]
|
||||
}
|
||||
elif year_lookup:
|
||||
date_lookup_params = lookup_params.copy()
|
||||
date_lookup_params.update({year_field: year_lookup})
|
||||
months = get_dates('month', date_lookup_params)
|
||||
return { 'show' : True,
|
||||
'back':
|
||||
{ 'link' : link({}),
|
||||
return {
|
||||
'show' : True,
|
||||
'back': {
|
||||
'link' : link({}),
|
||||
'title': _('All dates')
|
||||
},
|
||||
'choices':
|
||||
[ { 'link': link( {year_field: year_lookup, month_field: month.month}),
|
||||
'title': "%s %s" % (month.strftime('%B') , month.year) } for month in months ]
|
||||
'choices': [{
|
||||
'link': link( {year_field: year_lookup, month_field: month.month}),
|
||||
'title': "%s %s" % (month.strftime('%B') , month.year)
|
||||
} for month in months]
|
||||
}
|
||||
else:
|
||||
years = get_dates('year', lookup_params)
|
||||
return { 'show': True,
|
||||
'choices':
|
||||
[ { 'link': link( {year_field: year.year}),
|
||||
'title': year.year } for year in years ]
|
||||
return {
|
||||
'show': True,
|
||||
'choices': [{
|
||||
'link': link({year_field: year.year}),
|
||||
'title': year.year
|
||||
} for year in years ]
|
||||
}
|
||||
date_hierarchy = inclusion_tag('admin/date_hierarchy')(date_hierarchy)
|
||||
|
||||
#@inclusion_tag('admin/search_form')
|
||||
def search_form(cl):
|
||||
return { 'cl': cl,
|
||||
return {
|
||||
'cl': cl,
|
||||
'show_result_count': cl.result_count != cl.full_result_count and not cl.opts.one_to_one_field,
|
||||
'search_var': SEARCH_VAR }
|
||||
'search_var': SEARCH_VAR
|
||||
}
|
||||
search_form = inclusion_tag('admin/search_form')(search_form)
|
||||
|
||||
#@inclusion_tag('admin/filter')
|
||||
def filter(cl, spec):
|
||||
return {'title': spec.title(),
|
||||
'choices' : list(spec.choices(cl))}
|
||||
return {'title': spec.title(), 'choices' : list(spec.choices(cl))}
|
||||
filter = inclusion_tag('admin/filter')(filter)
|
||||
|
||||
#@inclusion_tag('admin/filters')
|
||||
|
@ -45,7 +45,6 @@ def _get_mod_opts(app_label, module_name):
|
||||
raise Http404 # This object is valid but has no admin interface.
|
||||
return mod, opts
|
||||
|
||||
|
||||
def index(request):
|
||||
return render_to_response('admin/index', {'title': _('Site administration')}, context_instance=Context(request))
|
||||
index = staff_member_required(index)
|
||||
@ -69,7 +68,6 @@ class ChangeList(object):
|
||||
|
||||
def get_filters(self, request):
|
||||
self.filter_specs = []
|
||||
|
||||
if self.lookup_opts.admin.list_filter and not self.opts.one_to_one_field:
|
||||
filter_fields = [self.lookup_opts.get_field(field_name) \
|
||||
for field_name in self.lookup_opts.admin.list_filter]
|
||||
@ -77,7 +75,6 @@ class ChangeList(object):
|
||||
spec = FilterSpec.create(f, request, self.params)
|
||||
if spec.has_output():
|
||||
self.filter_specs.append(spec)
|
||||
|
||||
self.has_filters = bool(self.filter_specs)
|
||||
|
||||
def get_query_string(self, new_params={}, remove=[]):
|
||||
@ -93,7 +90,6 @@ class ChangeList(object):
|
||||
p[k] = v
|
||||
return '?' + '&'.join(['%s=%s' % (k, v) for k, v in p.items()]).replace(' ', '%20')
|
||||
|
||||
|
||||
def get_modules_and_options(self, app_label, module_name, request):
|
||||
self.mod, self.opts = _get_mod_opts(app_label, module_name)
|
||||
if not request.user.has_perm(app_label + '.' + self.opts.get_change_permission()):
|
||||
@ -331,7 +327,6 @@ class AdminBoundField(BoundField):
|
||||
def html_error_list(self):
|
||||
return " ".join([form_field.html_error_list() for form_field in self.form_fields if form_field.errors])
|
||||
|
||||
|
||||
class AdminBoundFieldLine(BoundFieldLine):
|
||||
def __init__(self, field_line, field_mapping, original):
|
||||
super(AdminBoundFieldLine, self).__init__(field_line, field_mapping, original, AdminBoundField)
|
||||
@ -382,7 +377,6 @@ class AdminBoundManipulator(BoundManipulator):
|
||||
return ""
|
||||
|
||||
def render_change_form(opts, manipulator, app_label, context, add=False, change=False, show_delete=False, form_url=''):
|
||||
|
||||
extra_context = {
|
||||
'add': add,
|
||||
'change': change,
|
||||
@ -391,13 +385,10 @@ def render_change_form(opts, manipulator, app_label, context, add=False, change=
|
||||
'form_url' : form_url,
|
||||
'app_label': app_label,
|
||||
}
|
||||
|
||||
context.update(extra_context)
|
||||
|
||||
return render_to_response(["admin/%s/%s/change_form" % (app_label, opts.object_name.lower() ),
|
||||
"admin/%s/change_form" % app_label ,
|
||||
"admin/change_form"],
|
||||
context_instance=context)
|
||||
"admin/change_form"], context_instance=context)
|
||||
|
||||
def log_add_message(user, opts,manipulator,new_object):
|
||||
pk_value = getattr(new_object, opts.pk.attname)
|
||||
@ -552,8 +543,6 @@ def change_stage(request, app_label, module_name, object_id):
|
||||
|
||||
return render_change_form(opts,manipulator, app_label, c, change=True)
|
||||
|
||||
|
||||
|
||||
def _nest_help(obj, depth, val):
|
||||
current = obj
|
||||
for i in range(depth):
|
||||
|
Loading…
x
Reference in New Issue
Block a user