Simplified lists creation in three places.
This commit is contained in:
parent
02d974ceb5
commit
92eced62cd
|
@ -45,12 +45,15 @@ class FilteredSelectMultiple(forms.SelectMultiple):
|
|||
attrs['class'] = 'selectfilter'
|
||||
if self.is_stacked:
|
||||
attrs['class'] += 'stacked'
|
||||
output = [super(FilteredSelectMultiple, self).render(name, value, attrs, choices)]
|
||||
output.append('<script type="text/javascript">addEvent(window, "load", function(e) {')
|
||||
# TODO: "id_" is hard-coded here. This should instead use the correct
|
||||
# API to determine the ID dynamically.
|
||||
output.append('SelectFilter.init("id_%s", "%s", %s); });</script>\n'
|
||||
% (name, escapejs(self.verbose_name), int(self.is_stacked)))
|
||||
output = [
|
||||
super(FilteredSelectMultiple, self).render(name, value, attrs, choices),
|
||||
'<script type="text/javascript">addEvent(window, "load", function(e) {',
|
||||
# TODO: "id_" is hard-coded here. This should instead use the
|
||||
# correct API to determine the ID dynamically.
|
||||
'SelectFilter.init("id_%s", "%s", %s); });</script>\n' % (
|
||||
name, escapejs(self.verbose_name), int(self.is_stacked),
|
||||
),
|
||||
]
|
||||
return mark_safe(''.join(output))
|
||||
|
||||
|
||||
|
|
|
@ -61,8 +61,11 @@ class Command(BaseCommand):
|
|||
index_output = []
|
||||
qn = connection.ops.quote_name
|
||||
for f in fields:
|
||||
field_output = [qn(f.name), f.db_type(connection=connection)]
|
||||
field_output.append("%sNULL" % ("NOT " if not f.null else ""))
|
||||
field_output = [
|
||||
qn(f.name),
|
||||
f.db_type(connection=connection),
|
||||
'%sNULL' % ('NOT ' if not f.null else ''),
|
||||
]
|
||||
if f.primary_key:
|
||||
field_output.append("PRIMARY KEY")
|
||||
elif f.unique:
|
||||
|
|
|
@ -1082,10 +1082,7 @@ class SQLUpdateCompiler(SQLCompiler):
|
|||
self.pre_sql_setup()
|
||||
if not self.query.values:
|
||||
return '', ()
|
||||
table = self.query.tables[0]
|
||||
qn = self.quote_name_unless_alias
|
||||
result = ['UPDATE %s' % qn(table)]
|
||||
result.append('SET')
|
||||
values, update_params = [], []
|
||||
for field, model, val in self.query.values:
|
||||
if hasattr(val, 'resolve_expression'):
|
||||
|
@ -1124,7 +1121,11 @@ class SQLUpdateCompiler(SQLCompiler):
|
|||
values.append('%s = NULL' % qn(name))
|
||||
if not values:
|
||||
return '', ()
|
||||
result.append(', '.join(values))
|
||||
table = self.query.tables[0]
|
||||
result = [
|
||||
'UPDATE %s SET' % qn(table),
|
||||
', '.join(values),
|
||||
]
|
||||
where, params = self.compile(self.query.where)
|
||||
if where:
|
||||
result.append('WHERE %s' % where)
|
||||
|
|
Loading…
Reference in New Issue