Fix not working widgetMedia in boolean fields.

Change-Id: I4fbffae6a136c617cad9d9aa76c69c4ecf4f0641
Fixes-bug: MRN-1247.
This commit is contained in:
Timur Sufiev 2013-10-24 15:12:53 +04:00
parent ae017ff035
commit 78eb046e14
6 changed files with 24 additions and 13 deletions

View File

@ -399,7 +399,13 @@ class AZoneChoiceField(ChoiceField):
class BooleanField(forms.BooleanField, CustomPropertiesField):
def __init__(self, *args, **kwargs):
kwargs['widget'] = forms.CheckboxInput(attrs={'class': 'checkbox'})
if 'widget' in kwargs:
widget = kwargs['widget']
if isinstance(widget, type):
widget = widget(attrs={'class': 'checkbox'})
else:
widget = forms.CheckboxInput(attrs={'class': 'checkbox'})
kwargs['widget'] = widget
super(BooleanField, self).__init__(*args, **kwargs)

View File

@ -126,6 +126,7 @@ class ServiceConfigurationForm(UpdatableFieldsForm):
js = media.get('js', ())
css = media.get('css', {})
widget = Widget
if 'widget_attrs' in kwargs:
widget = widget(attrs=kwargs['widget_attrs'])
del kwargs['widget_attrs']

View File

@ -17,8 +17,6 @@ forms:
hidden: true
attributeNames: false
description: Telnet service that can be installed at linux
widgetMedia:
css: {all: [muranodashboard/css/checkbox.css]}
- name: name
type: string
label: Service Name
@ -43,6 +41,8 @@ forms:
Indicates if the target machine has to get telnet deployed
initial: true
required: false
widgetMedia:
css: {all: [muranodashboard/css/checkbox.css]}
- name: unitNamingPattern
type: string
label: Hostname

View File

@ -25,10 +25,6 @@ forms:
hidden: true
attributeNames: false
description: MS SQL Failover Cluster
# temporaryHack
widgetMedia:
js: [muranodashboard/js/mixed-mode.js, muranodashboard/js/external-ad.js]
css: {all: [muranodashboard/css/checkbox.css]}
- name: name
type: string
label: Service Name
@ -55,6 +51,10 @@ forms:
label: Active Directory is configured by the System Administrator
widgetAttrs: # temporary hack
class: external-ad
# temporaryHack
widgetMedia:
js: [muranodashboard/js/external-ad.js]
css: {all: [muranodashboard/css/checkbox.css]}
required: false
- name: domainAdminUserName
type: string
@ -85,6 +85,10 @@ forms:
credentials but supplements them with local SQL Server user
accounts that the administrator may create and maintain within
SQL Server. If this mode is on SA password is required
# temporaryHack
widgetMedia:
js: [muranodashboard/js/mixed-mode.js]
css: {all: [muranodashboard/css/checkbox.css]}
- name: saPassword
type: password
label: SA Password

View File

@ -17,10 +17,6 @@ forms:
hidden: true
attributeNames: false
description: MS SQL Server
# temporaryHack
widgetMedia:
js: [muranodashboard/js/mixed-mode.js]
css: {all: [muranodashboard/css/checkbox.css]}
- name: name
type: string
label: Service Name
@ -65,6 +61,10 @@ forms:
credentials but supplements them with local SQL Server user
accounts that the administrator may create and maintain within
SQL Server. If this mode is on SA password is required
# temporaryHack
widgetMedia:
js: [muranodashboard/js/mixed-mode.js]
css: {all: [muranodashboard/css/checkbox.css]}
- name: saPassword
type: password
label: SA Password

View File

@ -1,9 +1,9 @@
from django import template
from django.forms import CheckboxInput
register = template.Library()
@register.filter(name='is_checkbox')
def is_checkbox(field):
return field.field.widget.__class__.__name__ == 'CheckboxInput'
return isinstance(field.field.widget, CheckboxInput)