mirror of
https://github.com/django/django.git
synced 2025-07-05 10:19:20 +00:00
Merged trunk changes, and converted submit lines to use a template
git-svn-id: http://code.djangoproject.com/svn/django/branches/new-admin@741 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d0ba57ee90
commit
eb07d93938
4
django/conf/admin_media/css/changelists.css
vendored
4
django/conf/admin_media/css/changelists.css
vendored
@ -18,10 +18,10 @@
|
|||||||
|
|
||||||
#changelist {position:relative; width:100%;}
|
#changelist {position:relative; width:100%;}
|
||||||
#changelist table {width:100%;}
|
#changelist table {width:100%;}
|
||||||
.change-list .filtered table { border-right:1px solid #ddd; }
|
.change-list .filtered table { border-right:1px solid #ddd, width:100%; }
|
||||||
.change-list .filtered {min-height:400px; _height:400px;}
|
.change-list .filtered {min-height:400px; _height:400px;}
|
||||||
.change-list .filtered {background:white url(../img/admin/changelist-bg.gif) top right repeat-y !important;}
|
.change-list .filtered {background:white url(../img/admin/changelist-bg.gif) top right repeat-y !important;}
|
||||||
.change-list .filtered table, .filtered .paginator, .filtered #toolbar, .filtered div.xfull {margin-right:160px !important; width:auto !important; }
|
.change-list .filtered .paginator, .filtered #toolbar, .filtered div.xfull {margin-right:160px !important; width:auto !important; }
|
||||||
.change-list .filtered table tbody th {padding-right:10px;}
|
.change-list .filtered table tbody th {padding-right:10px;}
|
||||||
#changelist .toplinks {border-bottom:1px solid #ccc !important;}
|
#changelist .toplinks {border-bottom:1px solid #ccc !important;}
|
||||||
#changelist .paginator { color:#666; border-top:1px solid #eee; border-bottom:1px solid #eee; background:white url(../img/admin/nav-bg.gif) 0 180% repeat-x; overflow:hidden;}
|
#changelist .paginator { color:#666; border-top:1px solid #eee; border-bottom:1px solid #eee; background:white url(../img/admin/nav-bg.gif) 0 180% repeat-x; overflow:hidden;}
|
||||||
|
7
django/conf/admin_templates/admin_submit_line.html
Normal file
7
django/conf/admin_templates/admin_submit_line.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<div class="submit-row">
|
||||||
|
{% if show_delete_link %}<p class="float-left"><a href="delete/" class="deletelink">Delete</a></p>{% endif %}
|
||||||
|
{% if show_save_as_new %}<input type="submit" value="Save as new" name="_saveasnew" {{onclick_attrib}}/>{%endif%}
|
||||||
|
{% if show_save_and_add_another %}<input type="submit" value="Save and add another" name="_addanother" {{onclick_attrib}} />{% endif %}
|
||||||
|
{% if show_save_and_continue %}<input type="submit" value="Save and continue editing" name="_continue" {{onclick_attrib}}/>{% endif %}
|
||||||
|
{% if show_save %}<input type="submit" value="Save" class="default" {{onclick_attrib}}/>{% endif %}
|
||||||
|
</div>
|
@ -98,6 +98,9 @@ class ForNode(template.Node):
|
|||||||
# shortcuts for current loop iteration number
|
# shortcuts for current loop iteration number
|
||||||
'counter0': i,
|
'counter0': i,
|
||||||
'counter': i+1,
|
'counter': i+1,
|
||||||
|
# reverse counter iteration numbers
|
||||||
|
'revcounter': len_values - i,
|
||||||
|
'revcounter0': len_values - i - 1,
|
||||||
# boolean values designating first and last times through loop
|
# boolean values designating first and last times through loop
|
||||||
'first': (i == 0),
|
'first': (i == 0),
|
||||||
'last': (i == len_values - 1),
|
'last': (i == len_values - 1),
|
||||||
@ -445,6 +448,10 @@ def do_for(parser, token):
|
|||||||
========================== ================================================
|
========================== ================================================
|
||||||
``forloop.counter`` The current iteration of the loop (1-indexed)
|
``forloop.counter`` The current iteration of the loop (1-indexed)
|
||||||
``forloop.counter0`` The current iteration of the loop (0-indexed)
|
``forloop.counter0`` The current iteration of the loop (0-indexed)
|
||||||
|
``forloop.revcounter`` The number of iterations from the end of the
|
||||||
|
loop (1-indexed)
|
||||||
|
``forloop.revcounter0`` The number of iterations from the end of the
|
||||||
|
loop (0-indexed)
|
||||||
``forloop.first`` True if this is the first time through the loop
|
``forloop.first`` True if this is the first time through the loop
|
||||||
``forloop.last`` True if this is the last time through the loop
|
``forloop.last`` True if this is the last time through the loop
|
||||||
``forloop.parentloop`` For nested loops, this is the loop "above" the
|
``forloop.parentloop`` For nested loops, this is the loop "above" the
|
||||||
|
@ -156,18 +156,23 @@ get_sql_reset.args = APP_ARGS
|
|||||||
|
|
||||||
def get_sql_initial_data(mod):
|
def get_sql_initial_data(mod):
|
||||||
"Returns a list of the initial INSERT SQL statements for the given module."
|
"Returns a list of the initial INSERT SQL statements for the given module."
|
||||||
|
from django.core import db
|
||||||
output = []
|
output = []
|
||||||
app_label = mod._MODELS[0]._meta.app_label
|
app_label = mod._MODELS[0]._meta.app_label
|
||||||
output.append(_get_packages_insert(app_label))
|
output.append(_get_packages_insert(app_label))
|
||||||
app_dir = os.path.normpath(os.path.join(os.path.dirname(mod.__file__), '../sql'))
|
app_dir = os.path.normpath(os.path.join(os.path.dirname(mod.__file__), '../sql'))
|
||||||
for klass in mod._MODELS:
|
for klass in mod._MODELS:
|
||||||
opts = klass._meta
|
opts = klass._meta
|
||||||
|
|
||||||
# Add custom SQL, if it's available.
|
# Add custom SQL, if it's available.
|
||||||
sql_file_name = os.path.join(app_dir, opts.module_name + '.sql')
|
sql_files = [os.path.join(app_dir, opts.module_name + '.' + db.DATABASE_ENGINE + '.sql'),
|
||||||
if os.path.exists(sql_file_name):
|
os.path.join(app_dir, opts.module_name + '.sql')]
|
||||||
fp = open(sql_file_name, 'r')
|
for sql_file in sql_files:
|
||||||
|
if os.path.exists(sql_file):
|
||||||
|
fp = open(sql_file)
|
||||||
output.append(fp.read())
|
output.append(fp.read())
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
# Content types.
|
# Content types.
|
||||||
output.append(_get_contenttype_insert(opts))
|
output.append(_get_contenttype_insert(opts))
|
||||||
# Permissions.
|
# Permissions.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from django.core import template, template_loader, meta
|
from django.core import template, template_loader, meta
|
||||||
|
from django.core.template_loader import render_to_string
|
||||||
from django.conf.settings import ADMIN_MEDIA_PREFIX
|
from django.conf.settings import ADMIN_MEDIA_PREFIX
|
||||||
from django.utils.text import capfirst
|
from django.utils.text import capfirst
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
@ -29,21 +30,33 @@ class SubmitRowNode(template.Node):
|
|||||||
has_delete_permission = context['has_delete_permission']
|
has_delete_permission = context['has_delete_permission']
|
||||||
is_popup = context['is_popup']
|
is_popup = context['is_popup']
|
||||||
|
|
||||||
t = ['<div class="submit-row">']
|
|
||||||
onclick_attrib = ordered_objects and change and 'onclick="submitOrderForm();"' or ''
|
|
||||||
|
|
||||||
if not is_popup:
|
output = render_to_string('admin_submit_line', {
|
||||||
if has_delete_permission and (change or show_delete):
|
'onclick_attrib' : (ordered_objects and change
|
||||||
t.append('<p class="float-left"><a href="delete/" class="deletelink">Delete</a></p>')
|
and 'onclick="submitOrderForm();"' or ''),
|
||||||
if change and save_as:
|
'show_delete_link' : (not is_popup and has_delete_permission
|
||||||
t.append('<input type="submit" value="Save as new" name="_saveasnew" %s/>' % onclick_attrib)
|
and (change or show_delete)),
|
||||||
if (not save_as or add):
|
'show_save_as_new' : not is_popup and change and save_as,
|
||||||
t.append('<input type="submit" value="Save and add another" name="_addanother" %s/>' % onclick_attrib)
|
'show_save_and_add_another': not is_popup and (not save_as or add),
|
||||||
t.append('<input type="submit" value="Save and continue editing" name="_continue" %s/>' % onclick_attrib )
|
'show_save_and_continue': not is_popup,
|
||||||
t.append('<input type="submit" value="Save" class="default" %s/>' % onclick_attrib)
|
'show_save': True
|
||||||
t.append('</div>\n')
|
}, context);
|
||||||
|
context.pop()
|
||||||
|
return output;
|
||||||
|
# t = ['<div class="submit-row">']
|
||||||
|
|
||||||
return ''.join(t)
|
# if not is_popup:
|
||||||
|
# if has_delete_permission and (change or show_delete):
|
||||||
|
# t.append('<p class="float-left"><a href="delete/" class="deletelink">Delete</a></p>')
|
||||||
|
# if change and save_as:
|
||||||
|
# t.append('<input type="submit" value="Save as new" name="_saveasnew" %s/>' % onclick_attrib)
|
||||||
|
# if (not save_as or add):
|
||||||
|
# t.append('<input type="submit" value="Save and add another" name="_addanother" %s/>' % onclick_attrib)
|
||||||
|
# t.append('<input type="submit" value="Save and continue editing" name="_continue" %s/>' % onclick_attrib )
|
||||||
|
# t.append('<input type="submit" value="Save" class="default" %s/>' % onclick_attrib)
|
||||||
|
# t.append('</div>\n')
|
||||||
|
|
||||||
|
# return ''.join(t)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -506,7 +506,7 @@ def _get_submit_row_template(opts, app_label, add, change, show_delete, ordered_
|
|||||||
if not opts.admin.save_as or add:
|
if not opts.admin.save_as or add:
|
||||||
t.append('{%% if not is_popup %%}<input type="submit" value="Save and add another" name="_addanother" %s/>{%% endif %%}' % \
|
t.append('{%% if not is_popup %%}<input type="submit" value="Save and add another" name="_addanother" %s/>{%% endif %%}' % \
|
||||||
(ordered_objects and change and 'onclick="submitOrderForm();"' or ''))
|
(ordered_objects and change and 'onclick="submitOrderForm();"' or ''))
|
||||||
t.append('<input type="submit" value="Save and continue editing" name="_continue" %s/>' % \
|
t.append('{%% if not is_popup %%}<input type="submit" value="Save and continue editing" name="_continue" %s/>{%% endif %%}' % \
|
||||||
(ordered_objects and change and 'onclick="submitOrderForm();"' or ''))
|
(ordered_objects and change and 'onclick="submitOrderForm();"' or ''))
|
||||||
t.append('<input type="submit" value="Save" class="default" %s/>' % \
|
t.append('<input type="submit" value="Save" class="default" %s/>' % \
|
||||||
(ordered_objects and change and 'onclick="submitOrderForm();"' or ''))
|
(ordered_objects and change and 'onclick="submitOrderForm();"' or ''))
|
||||||
|
@ -8,7 +8,8 @@ from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
|
|||||||
from django.core.exceptions import Http404, ObjectDoesNotExist, ImproperlyConfigured
|
from django.core.exceptions import Http404, ObjectDoesNotExist, ImproperlyConfigured
|
||||||
|
|
||||||
def create_object(request, app_label, module_name, template_name=None,
|
def create_object(request, app_label, module_name, template_name=None,
|
||||||
extra_context={}, post_save_redirect=None, login_required=False):
|
template_loader=template_loader, extra_context={},
|
||||||
|
post_save_redirect=None, login_required=False):
|
||||||
"""
|
"""
|
||||||
Generic object-creation function.
|
Generic object-creation function.
|
||||||
|
|
||||||
@ -65,8 +66,9 @@ def create_object(request, app_label, module_name, template_name=None,
|
|||||||
return HttpResponse(t.render(c))
|
return HttpResponse(t.render(c))
|
||||||
|
|
||||||
def update_object(request, app_label, module_name, object_id=None, slug=None,
|
def update_object(request, app_label, module_name, object_id=None, slug=None,
|
||||||
slug_field=None, template_name=None, extra_lookup_kwargs={},
|
slug_field=None, template_name=None, template_loader=template_loader,
|
||||||
extra_context={}, post_save_redirect=None, login_required=False):
|
extra_lookup_kwargs={}, extra_context={}, post_save_redirect=None,
|
||||||
|
login_required=False):
|
||||||
"""
|
"""
|
||||||
Generic object-update function.
|
Generic object-update function.
|
||||||
|
|
||||||
@ -139,7 +141,8 @@ def update_object(request, app_label, module_name, object_id=None, slug=None,
|
|||||||
|
|
||||||
def delete_object(request, app_label, module_name, post_delete_redirect,
|
def delete_object(request, app_label, module_name, post_delete_redirect,
|
||||||
object_id=None, slug=None, slug_field=None, template_name=None,
|
object_id=None, slug=None, slug_field=None, template_name=None,
|
||||||
extra_lookup_kwargs={}, extra_context={}, login_required=False):
|
template_loader=template_loader, extra_lookup_kwargs={},
|
||||||
|
extra_context={}, login_required=False):
|
||||||
"""
|
"""
|
||||||
Generic object-delete function.
|
Generic object-delete function.
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ from django.utils.httpwrappers import HttpResponse
|
|||||||
import datetime, time
|
import datetime, time
|
||||||
|
|
||||||
def archive_index(request, app_label, module_name, date_field, num_latest=15,
|
def archive_index(request, app_label, module_name, date_field, num_latest=15,
|
||||||
template_name=None, extra_lookup_kwargs={}, extra_context={}):
|
template_name=None, template_loader=template_loader,
|
||||||
|
extra_lookup_kwargs={}, extra_context={}):
|
||||||
"""
|
"""
|
||||||
Generic top-level archive of date-based objects.
|
Generic top-level archive of date-based objects.
|
||||||
|
|
||||||
@ -49,7 +50,8 @@ def archive_index(request, app_label, module_name, date_field, num_latest=15,
|
|||||||
return HttpResponse(t.render(c))
|
return HttpResponse(t.render(c))
|
||||||
|
|
||||||
def archive_year(request, year, app_label, module_name, date_field,
|
def archive_year(request, year, app_label, module_name, date_field,
|
||||||
template_name=None, extra_lookup_kwargs={}, extra_context={}):
|
template_name=None, template_loader=template_loader,
|
||||||
|
extra_lookup_kwargs={}, extra_context={}):
|
||||||
"""
|
"""
|
||||||
Generic yearly archive view.
|
Generic yearly archive view.
|
||||||
|
|
||||||
@ -85,8 +87,8 @@ def archive_year(request, year, app_label, module_name, date_field,
|
|||||||
return HttpResponse(t.render(c))
|
return HttpResponse(t.render(c))
|
||||||
|
|
||||||
def archive_month(request, year, month, app_label, module_name, date_field,
|
def archive_month(request, year, month, app_label, module_name, date_field,
|
||||||
month_format='%b', template_name=None, extra_lookup_kwargs={},
|
month_format='%b', template_name=None, template_loader=template_loader,
|
||||||
extra_context={}):
|
extra_lookup_kwargs={}, extra_context={}):
|
||||||
"""
|
"""
|
||||||
Generic monthly archive view.
|
Generic monthly archive view.
|
||||||
|
|
||||||
@ -138,7 +140,8 @@ def archive_month(request, year, month, app_label, module_name, date_field,
|
|||||||
|
|
||||||
def archive_day(request, year, month, day, app_label, module_name, date_field,
|
def archive_day(request, year, month, day, app_label, module_name, date_field,
|
||||||
month_format='%b', day_format='%d', template_name=None,
|
month_format='%b', day_format='%d', template_name=None,
|
||||||
extra_lookup_kwargs={}, extra_context={}, allow_empty=False):
|
template_loader=template_loader, extra_lookup_kwargs={},
|
||||||
|
extra_context={}, allow_empty=False):
|
||||||
"""
|
"""
|
||||||
Generic daily archive view.
|
Generic daily archive view.
|
||||||
|
|
||||||
@ -201,7 +204,8 @@ def archive_today(request, **kwargs):
|
|||||||
def object_detail(request, year, month, day, app_label, module_name, date_field,
|
def object_detail(request, year, month, day, app_label, module_name, date_field,
|
||||||
month_format='%b', day_format='%d', object_id=None, slug=None,
|
month_format='%b', day_format='%d', object_id=None, slug=None,
|
||||||
slug_field=None, template_name=None, template_name_field=None,
|
slug_field=None, template_name=None, template_name_field=None,
|
||||||
extra_lookup_kwargs={}, extra_context={}):
|
template_loader=template_loader, extra_lookup_kwargs={},
|
||||||
|
extra_context={}):
|
||||||
"""
|
"""
|
||||||
Generic detail view from year/month/day/slug or year/month/day/id structure.
|
Generic detail view from year/month/day/slug or year/month/day/id structure.
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ from django.core.paginator import ObjectPaginator, InvalidPage
|
|||||||
from django.core.exceptions import Http404, ObjectDoesNotExist
|
from django.core.exceptions import Http404, ObjectDoesNotExist
|
||||||
|
|
||||||
def object_list(request, app_label, module_name, paginate_by=None, allow_empty=False,
|
def object_list(request, app_label, module_name, paginate_by=None, allow_empty=False,
|
||||||
template_name=None, extra_lookup_kwargs={}, extra_context={}):
|
template_name=None, template_loader=template_loader,
|
||||||
|
extra_lookup_kwargs={}, extra_context={}):
|
||||||
"""
|
"""
|
||||||
Generic list of objects.
|
Generic list of objects.
|
||||||
|
|
||||||
@ -76,7 +77,8 @@ def object_list(request, app_label, module_name, paginate_by=None, allow_empty=F
|
|||||||
|
|
||||||
def object_detail(request, app_label, module_name, object_id=None, slug=None,
|
def object_detail(request, app_label, module_name, object_id=None, slug=None,
|
||||||
slug_field=None, template_name=None, template_name_field=None,
|
slug_field=None, template_name=None, template_name_field=None,
|
||||||
extra_lookup_kwargs={}, extra_context={}):
|
template_loader=template_loader, extra_lookup_kwargs={},
|
||||||
|
extra_context={}):
|
||||||
"""
|
"""
|
||||||
Generic list of objects.
|
Generic list of objects.
|
||||||
|
|
||||||
|
@ -376,6 +376,10 @@ Built-in tag reference
|
|||||||
========================== ================================================
|
========================== ================================================
|
||||||
``forloop.counter`` The current iteration of the loop (1-indexed)
|
``forloop.counter`` The current iteration of the loop (1-indexed)
|
||||||
``forloop.counter0`` The current iteration of the loop (0-indexed)
|
``forloop.counter0`` The current iteration of the loop (0-indexed)
|
||||||
|
``forloop.revcounter`` The number of iterations from the end of the
|
||||||
|
loop (1-indexed)
|
||||||
|
``forloop.revcounter0`` The number of iterations from the end of the
|
||||||
|
loop (0-indexed)
|
||||||
``forloop.first`` True if this is the first time through the loop
|
``forloop.first`` True if this is the first time through the loop
|
||||||
``forloop.last`` True if this is the last time through the loop
|
``forloop.last`` True if this is the last time through the loop
|
||||||
``forloop.parentloop`` For nested loops, this is the loop "above" the
|
``forloop.parentloop`` For nested loops, this is the loop "above" the
|
||||||
|
@ -107,6 +107,10 @@ TEMPLATE_TESTS = {
|
|||||||
### FOR TAG ###############################################################
|
### FOR TAG ###############################################################
|
||||||
'for-tag01': ("{% for val in values %}{{ val }}{% endfor %}", {"values": [1, 2, 3]}, "123"),
|
'for-tag01': ("{% for val in values %}{{ val }}{% endfor %}", {"values": [1, 2, 3]}, "123"),
|
||||||
'for-tag02': ("{% for val in values reversed %}{{ val }}{% endfor %}", {"values": [1, 2, 3]}, "321"),
|
'for-tag02': ("{% for val in values reversed %}{{ val }}{% endfor %}", {"values": [1, 2, 3]}, "321"),
|
||||||
|
'for-tag-vars01': ("{% for val in values %}{{ forloop.counter }}{% endfor %}", {"values": [6, 6, 6]}, "123"),
|
||||||
|
'for-tag-vars02': ("{% for val in values %}{{ forloop.counter0 }}{% endfor %}", {"values": [6, 6, 6]}, "012"),
|
||||||
|
'for-tag-vars03': ("{% for val in values %}{{ forloop.revcounter }}{% endfor %}", {"values": [6, 6, 6]}, "321"),
|
||||||
|
'for-tag-vars04': ("{% for val in values %}{{ forloop.revcounter0 }}{% endfor %}", {"values": [6, 6, 6]}, "210"),
|
||||||
|
|
||||||
### IFEQUAL TAG ###########################################################
|
### IFEQUAL TAG ###########################################################
|
||||||
'ifequal01': ("{% ifequal a b %}yes{% endifequal %}", {"a": 1, "b": 2}, ""),
|
'ifequal01': ("{% ifequal a b %}yes{% endifequal %}", {"a": 1, "b": 2}, ""),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user