django-orchestra-test/orchestra/contrib/orchestration/forms.py
2015-06-09 11:16:36 +00:00

15 lines
641 B
Python

from django import forms
from orchestra.forms.widgets import SpanWidget
from orchestra.forms.widgets import paddingCheckboxSelectMultiple
class RouteForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(RouteForm, self).__init__(*args, **kwargs)
if self.instance:
self.fields['backend'].widget = SpanWidget()
self.fields['backend'].required = False
self.fields['async_actions'].widget = paddingCheckboxSelectMultiple(45)
actions = self.instance.backend_class.actions
self.fields['async_actions'].choices = ((action, action) for action in actions)