mirror of
https://github.com/jazzband/django-constance.git
synced 2026-03-16 22:40:24 +00:00
Fix *Reset to default* to work with boolean/checkboxes (#191)
* Fix *Reset to default* to work with boolean/checkboxes * Add field name to each config value * Check field name and use *checked* for checkbox and *value* otherwise Fix #189 * Add and use raw_default and is_checkbox
This commit is contained in:
parent
81b723c91b
commit
bddb6cd2ac
2 changed files with 7 additions and 1 deletions
|
|
@ -173,10 +173,13 @@ class ConstanceAdmin(admin.ModelAdmin):
|
|||
config_value = {
|
||||
'name': name,
|
||||
'default': localize(default),
|
||||
'raw_default': default,
|
||||
'help_text': _(help_text),
|
||||
'value': localize(value),
|
||||
'modified': localize(value) != localize(default),
|
||||
'form_field': form[name],
|
||||
'is_checkbox': isinstance(
|
||||
form[name].field.widget, forms.CheckboxInput),
|
||||
}
|
||||
|
||||
return config_value
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@
|
|||
{{ item.form_field.errors }}
|
||||
{{ item.form_field }}
|
||||
<br>
|
||||
<a href="#" onClick="document.getElementById('{{ item.form_field.auto_id }}').value = '{{ item.default|escapejs }}'; return false;">Reset to default</a>
|
||||
<a href="#" onClick="
|
||||
document.getElementById('{{ item.form_field.auto_id }}').{% if item.is_checkbox %}checked =
|
||||
{% if item.raw_default %} true {% else %} false {% endif %}
|
||||
{% else %}value = '{{ item.default|escapejs }}'{% endif %}; return false;">Reset to default</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if item.modified %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue