mirror of
https://github.com/django/django.git
synced 2025-07-05 10:19:20 +00:00
Template fixes(unclosed div). Fix for manipulator save with add manipulators and follow arguments. Changed imports in template/decorators.py and removal of pointless code from DebugLexer
git-svn-id: http://code.djangoproject.com/svn/django/branches/new-admin@883 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
afda16b5ab
commit
27d4bb9460
@ -23,8 +23,6 @@
|
|||||||
{% if is_popup %}<input type="hidden" name="_popup" value="1">{% endif %}
|
{% if is_popup %}<input type="hidden" name="_popup" value="1">{% endif %}
|
||||||
{% if save_on_top %}{% submit_row %}{% endif %}
|
{% if save_on_top %}{% submit_row %}{% endif %}
|
||||||
{% if form.error_dict %}<p class="errornote">Please correct the error{{ form.error_dict.items|pluralize }} below.</p>{% endif %}
|
{% if form.error_dict %}<p class="errornote">Please correct the error{{ form.error_dict.items|pluralize }} below.</p>{% endif %}
|
||||||
<b>
|
|
||||||
</b>
|
|
||||||
{% for bound_field_set in bound_field_sets %}
|
{% for bound_field_set in bound_field_sets %}
|
||||||
<fieldset class="module aligned {{ bound_field_set.classes }}">
|
<fieldset class="module aligned {{ bound_field_set.classes }}">
|
||||||
{% if bound_field_set.name %}<h2>{{bound_field_set.name }}</h2>{% endif %}
|
{% if bound_field_set.name %}<h2>{{bound_field_set.name }}</h2>{% endif %}
|
||||||
@ -46,19 +44,15 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for related_object in inline_related_objects %}{% edit_inline related_object %}{% endfor %}
|
{% for related_object in inline_related_objects %}{% edit_inline related_object %}{% endfor %}
|
||||||
|
|
||||||
{% submit_row %}
|
{% submit_row %}
|
||||||
|
|
||||||
{% if add %}
|
{% if add %}
|
||||||
<script type="text/javascript">document.getElementById("{{first_form_field_id}}").focus();</script>
|
<script type="text/javascript">document.getElementById("{{first_form_field_id}}").focus();</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if auto_populated_fields %}
|
{% if auto_populated_fields %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
{% auto_populated_field_script auto_populated_fields change %}
|
{% auto_populated_field_script auto_populated_fields change %}
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if change %}
|
{% if change %}
|
||||||
{% if ordered_objects %}
|
{% if ordered_objects %}
|
||||||
{% if form.order_objects %}<ul id="orderthese">
|
{% if form.order_objects %}<ul id="orderthese">
|
||||||
@ -69,7 +63,6 @@
|
|||||||
{% endfor%}
|
{% endfor%}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif%}
|
{% endif %}
|
||||||
</form>
|
</form></div>
|
||||||
|
{% endblock %}
|
||||||
{% endblock %}
|
|
@ -1610,7 +1610,10 @@ def manipulator_save(opts, klass, add, change, self, new_data):
|
|||||||
if self.follow.get(f.name, None) and not auto_now_add:
|
if self.follow.get(f.name, None) and not auto_now_add:
|
||||||
param = f.get_manipulator_new_data(new_data)
|
param = f.get_manipulator_new_data(new_data)
|
||||||
else:
|
else:
|
||||||
param = getattr(self.original_object, f.column)
|
if change:
|
||||||
|
param = getattr(self.original_object, f.column)
|
||||||
|
else:
|
||||||
|
param = f.get_default()
|
||||||
params[f.column] = param
|
params[f.column] = param
|
||||||
|
|
||||||
# Fields with auto_now_add are another special case; they should keep
|
# Fields with auto_now_add are another special case; they should keep
|
||||||
|
@ -247,7 +247,6 @@ class DebugLexer(Lexer):
|
|||||||
next_linebreak = linebreaks.next()
|
next_linebreak = linebreaks.next()
|
||||||
line += 1
|
line += 1
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
next_linebreak = len(self.template_string)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
token_tups.append( (self.template_string[start:end], line) )
|
token_tups.append( (self.template_string[start:end], line) )
|
||||||
@ -258,7 +257,6 @@ class DebugLexer(Lexer):
|
|||||||
next_linebreak = linebreaks.next()
|
next_linebreak = linebreaks.next()
|
||||||
line += 1
|
line += 1
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
next_linebreak = len(self.template_string)
|
|
||||||
break
|
break
|
||||||
|
|
||||||
last_bit = self.template_string[upto:]
|
last_bit = self.template_string[upto:]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from inspect import getargspec
|
from inspect import getargspec
|
||||||
from django.core import template
|
from django.core.template import Context, Node, TemplateSyntaxError, register_tag, resolve_variable
|
||||||
from django.core.template_loader import render_to_string, get_template
|
from django.core.template_loader import render_to_string, get_template
|
||||||
from django.utils.functional import curry
|
from django.utils.functional import curry
|
||||||
|
|
||||||
@ -14,41 +14,41 @@ def gen_compile_func(params, defaults, name, node_class, parser, token):
|
|||||||
message = "%s takes %s arguments" % (name, bmin)
|
message = "%s takes %s arguments" % (name, bmin)
|
||||||
else:
|
else:
|
||||||
message = "%s takes between %s and %s arguments" % (name, bmin, bmax)
|
message = "%s takes between %s and %s arguments" % (name, bmin, bmax)
|
||||||
raise template.TemplateSyntaxError(message)
|
raise TemplateSyntaxError(message)
|
||||||
return node_class(bits)
|
return node_class(bits)
|
||||||
|
|
||||||
|
|
||||||
def simple_tag(func):
|
def simple_tag(func):
|
||||||
(params,_, _, defaults) = getargspec(func)
|
(params,_, _, defaults) = getargspec(func)
|
||||||
class TNode(template.Node):
|
class SimpleNode(Node):
|
||||||
def __init__(self, vars_to_resolve):
|
def __init__(self, vars_to_resolve):
|
||||||
#get the vars to resolve
|
#get the vars to resolve
|
||||||
self.vars_to_resolve = vars_to_resolve
|
self.vars_to_resolve = vars_to_resolve
|
||||||
|
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
resolved_vars = [template.resolve_variable(var, context)
|
resolved_vars = [resolve_variable(var, context)
|
||||||
for var in self.vars_to_resolve]
|
for var in self.vars_to_resolve]
|
||||||
return func(*resolved_vars)
|
return func(*resolved_vars)
|
||||||
compile_func = curry(gen_compile_func, params, defaults, func.__name__, TNode)
|
compile_func = curry(gen_compile_func, params, defaults, func.__name__, SimpleNode)
|
||||||
compile_func.__doc__ = func.__doc__
|
compile_func.__doc__ = func.__doc__
|
||||||
template.register_tag(func.__name__, compile_func)
|
register_tag(func.__name__, compile_func)
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
|
||||||
def inclusion_tag(file_name, context_class=template.Context, takes_context=False):
|
def inclusion_tag(file_name, context_class=Context, takes_context=False):
|
||||||
def dec(func):
|
def dec(func):
|
||||||
(params,_, _, defaults) = getargspec(func)
|
(params,_, _, defaults) = getargspec(func)
|
||||||
if takes_context:
|
if takes_context:
|
||||||
if params[0] == 'context':
|
if params[0] == 'context':
|
||||||
params = params[1:]
|
params = params[1:]
|
||||||
else:
|
else:
|
||||||
raise template.TemplateSyntaxError("Any tag function decorated with takes_context=True must have a first argument of 'context'" )
|
raise TemplateSyntaxError("Any tag function decorated with takes_context=True must have a first argument of 'context'" )
|
||||||
class TNode(template.Node):
|
class InclusionNode(Node):
|
||||||
def __init__(self, vars_to_resolve):
|
def __init__(self, vars_to_resolve):
|
||||||
self.vars_to_resolve = vars_to_resolve
|
self.vars_to_resolve = vars_to_resolve
|
||||||
|
|
||||||
def render(self, context):
|
def render(self, context):
|
||||||
resolved_vars = [template.resolve_variable(var, context)
|
resolved_vars = [resolve_variable(var, context)
|
||||||
for var in self.vars_to_resolve]
|
for var in self.vars_to_resolve]
|
||||||
if takes_context:
|
if takes_context:
|
||||||
args = [context] + resolved_vars
|
args = [context] + resolved_vars
|
||||||
@ -62,9 +62,9 @@ def inclusion_tag(file_name, context_class=template.Context, takes_context=False
|
|||||||
self.nodelist = t.nodelist
|
self.nodelist = t.nodelist
|
||||||
return self.nodelist.render(context_class(dict))
|
return self.nodelist.render(context_class(dict))
|
||||||
|
|
||||||
compile_func = curry(gen_compile_func, params, defaults, func.__name__, TNode)
|
compile_func = curry(gen_compile_func, params, defaults, func.__name__, InclusionNode)
|
||||||
compile_func.__doc__ = func.__doc__
|
compile_func.__doc__ = func.__doc__
|
||||||
template.register_tag(func.__name__, compile_func)
|
register_tag(func.__name__, compile_func)
|
||||||
return func
|
return func
|
||||||
return dec
|
return dec
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user