1
0
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:
Robert Wittams 2005-10-16 02:00:24 +00:00
parent afda16b5ab
commit 27d4bb9460
4 changed files with 19 additions and 25 deletions

View File

@ -23,8 +23,6 @@
{% if is_popup %}<input type="hidden" name="_popup" value="1">{% 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 %}
<b>
</b>
{% for bound_field_set in bound_field_sets %}
<fieldset class="module aligned {{ bound_field_set.classes }}">
{% if bound_field_set.name %}<h2>{{bound_field_set.name }}</h2>{% endif %}
@ -46,19 +44,15 @@
{% endif %}
{% endif %}
{% for related_object in inline_related_objects %}{% edit_inline related_object %}{% endfor %}
{% submit_row %}
{% if add %}
<script type="text/javascript">document.getElementById("{{first_form_field_id}}").focus();</script>
{% endif %}
{% if auto_populated_fields %}
<script type="text/javascript">
{% auto_populated_field_script auto_populated_fields change %}
</script>
{% endif %}
{% if change %}
{% if ordered_objects %}
{% if form.order_objects %}<ul id="orderthese">
@ -70,6 +64,5 @@
{% endif %}
{% endif %}
{% endif %}
</form>
</form></div>
{% endblock %}

View File

@ -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:
param = f.get_manipulator_new_data(new_data)
else:
if change:
param = getattr(self.original_object, f.column)
else:
param = f.get_default()
params[f.column] = param
# Fields with auto_now_add are another special case; they should keep

View File

@ -247,7 +247,6 @@ class DebugLexer(Lexer):
next_linebreak = linebreaks.next()
line += 1
except StopIteration:
next_linebreak = len(self.template_string)
break
token_tups.append( (self.template_string[start:end], line) )
@ -258,7 +257,6 @@ class DebugLexer(Lexer):
next_linebreak = linebreaks.next()
line += 1
except StopIteration:
next_linebreak = len(self.template_string)
break
last_bit = self.template_string[upto:]

View File

@ -1,5 +1,5 @@
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.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)
else:
message = "%s takes between %s and %s arguments" % (name, bmin, bmax)
raise template.TemplateSyntaxError(message)
raise TemplateSyntaxError(message)
return node_class(bits)
def simple_tag(func):
(params,_, _, defaults) = getargspec(func)
class TNode(template.Node):
class SimpleNode(Node):
def __init__(self, vars_to_resolve):
#get the vars to resolve
self.vars_to_resolve = vars_to_resolve
def render(self, context):
resolved_vars = [template.resolve_variable(var, context)
resolved_vars = [resolve_variable(var, context)
for var in self.vars_to_resolve]
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__
template.register_tag(func.__name__, compile_func)
register_tag(func.__name__, compile_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):
(params,_, _, defaults) = getargspec(func)
if takes_context:
if params[0] == 'context':
params = params[1:]
else:
raise template.TemplateSyntaxError("Any tag function decorated with takes_context=True must have a first argument of 'context'" )
class TNode(template.Node):
raise TemplateSyntaxError("Any tag function decorated with takes_context=True must have a first argument of 'context'" )
class InclusionNode(Node):
def __init__(self, vars_to_resolve):
self.vars_to_resolve = vars_to_resolve
def render(self, context):
resolved_vars = [template.resolve_variable(var, context)
resolved_vars = [resolve_variable(var, context)
for var in self.vars_to_resolve]
if takes_context:
args = [context] + resolved_vars
@ -62,9 +62,9 @@ def inclusion_tag(file_name, context_class=template.Context, takes_context=False
self.nodelist = t.nodelist
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__
template.register_tag(func.__name__, compile_func)
register_tag(func.__name__, compile_func)
return func
return dec