@@ -66,6 +66,9 @@ class BundleForm(forms.ModelForm):
66
66
max_length = 50 ,
67
67
required = False ,
68
68
error_messages = {'invalid' : "Bundle names can't contain slashes" },
69
+ widget = forms .TextInput (
70
+ attrs = {'class' : 'create-bundle' , 'placeholder' : 'Bundle name' }
71
+ ),
69
72
)
70
73
71
74
class Meta :
@@ -136,19 +139,29 @@ class PatchForm(forms.ModelForm):
136
139
def __init__ (self , instance = None , project = None , * args , ** kwargs ):
137
140
super (PatchForm , self ).__init__ (instance = instance , * args , ** kwargs )
138
141
self .fields ['delegate' ] = forms .ModelChoiceField (
139
- queryset = _get_delegate_qs (project , instance ), required = False
142
+ queryset = _get_delegate_qs (project , instance ),
143
+ widget = forms .Select (attrs = {'class' : 'change-property-delegate' }),
144
+ required = False ,
140
145
)
141
146
142
147
class Meta :
143
148
model = Patch
144
149
fields = ['state' , 'archived' , 'delegate' ]
150
+ widgets = {
151
+ 'state' : forms .Select (attrs = {'class' : 'change-property-state' }),
152
+ 'archived' : forms .CheckboxInput (
153
+ attrs = {'class' : 'archive-patch-check' }
154
+ ),
155
+ }
145
156
146
157
147
158
class OptionalModelChoiceField (forms .ModelChoiceField ):
148
- no_change_choice = ('*' , 'no change' )
159
+ no_change_choice = ('*' , 'No change' )
149
160
to_field_name = None
150
161
151
- def __init__ (self , * args , ** kwargs ):
162
+ def __init__ (self , * args , placeholder , className , ** kwargs ):
163
+ self .no_change_choice = ('*' , placeholder )
164
+ self .widget = forms .Select (attrs = {'class' : className })
152
165
super (OptionalModelChoiceField , self ).__init__ (
153
166
initial = self .no_change_choice [0 ], * args , ** kwargs
154
167
)
@@ -181,29 +194,42 @@ def clean(self, value):
181
194
182
195
183
196
class OptionalBooleanField (forms .TypedChoiceField ):
197
+ def __init__ (self , className , * args , ** kwargs ):
198
+ self .widget = forms .Select (attrs = {'class' : className })
199
+ super (OptionalBooleanField , self ).__init__ (* args , ** kwargs )
200
+
184
201
def is_no_change (self , value ):
185
202
return value == self .empty_value
186
203
187
204
188
205
class MultiplePatchForm (forms .Form ):
189
206
action = 'update'
190
207
archived = OptionalBooleanField (
208
+ className = 'archive-patch-select' ,
191
209
choices = [
192
- ('*' , 'no change' ),
193
- ('True' , 'Archived ' ),
194
- ('False' , 'Unarchived ' ),
210
+ ('*' , 'No change' ),
211
+ ('True' , 'Archive ' ),
212
+ ('False' , 'Unarchive ' ),
195
213
],
196
214
coerce = lambda x : x == 'True' ,
197
215
empty_value = '*' ,
216
+ label = 'Archived' ,
198
217
)
199
218
200
219
def __init__ (self , project , * args , ** kwargs ):
201
220
super (MultiplePatchForm , self ).__init__ (* args , ** kwargs )
202
221
self .fields ['delegate' ] = OptionalModelChoiceField (
203
- queryset = _get_delegate_qs (project = project ), required = False
222
+ queryset = _get_delegate_qs (project = project ),
223
+ placeholder = 'Delegate to' ,
224
+ className = 'change-property-delegate' ,
225
+ label = 'Delegate to' ,
226
+ required = False ,
204
227
)
205
228
self .fields ['state' ] = OptionalModelChoiceField (
206
- queryset = State .objects .all ()
229
+ queryset = State .objects .all (),
230
+ placeholder = 'Change state' ,
231
+ className = 'change-property-state' ,
232
+ label = 'Change state' ,
207
233
)
208
234
209
235
def save (self , instance , commit = True ):
0 commit comments