Skip to content

Commit

Permalink
Fixed when changing a field using BatchAction wasn't allowed when the…
Browse files Browse the repository at this point in the history
… value validated to False, even when the field allows it, e.g. BooleanField couldn't be set to False
  • Loading branch information
Javier Cordero committed Mar 5, 2014
1 parent c599f4c commit d5fca42
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions xadmin/plugins/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def render(self, name, value, attrs=None):
output = []
is_required = self.widget.is_required
output.append(u'<label class="btn btn-info btn-xs">'
'<input type="checkbox" class="batch-field-checkbox" name="%s" value="%s"%s/> %s</label>' %
'<input type="checkbox" class="batch-field-checkbox" name="%s" value="%s"%s/> %s</label>' %
(BATCH_CHECKBOX_NAME, name, (is_required and ' checked="checked"' or ''), _('Change this field')))
output.extend([('<div class="control-wrap" style="margin-top: 10px;%s" id="id_%s_wrap_container">' %
output.extend([('<div class="control-wrap" style="margin-top: 10px;%s" id="id_%s_wrap_container">' %
((not is_required and 'display: none;' or ''), name)),
self.widget.render(name, value, attrs), '</div>'])
return mark_safe(u''.join(output))
Expand Down Expand Up @@ -78,9 +78,7 @@ def change_models(self, queryset, cleaned_data):
if not f.editable or isinstance(f, models.AutoField) \
or not f.name in cleaned_data:
continue
value = cleaned_data[f.name]
if value:
data[f] = value
data[f] = cleaned_data[f.name]

if n:
for obj in queryset:
Expand Down Expand Up @@ -123,7 +121,7 @@ def do_action(self, queryset):

helper = FormHelper()
helper.form_tag = False
helper.add_layout(Layout(Container(Col('full',
helper.add_layout(Layout(Container(Col('full',
Fieldset("", *self.form_obj.fields.keys(), css_class="unsort no_title"), horizontal=True, span=12)
)))
self.form_obj.helper = helper
Expand Down

0 comments on commit d5fca42

Please sign in to comment.