@@ -127,12 +127,9 @@ class Meta:
127127
128128
129129class EthogramImportForm (forms .Form ):
130-
131130 file = forms .FileField (
132131 label = _ ('File' ),
133- help_text = _ (
134- 'JSON export from PyBehaviorLog 0.9.1 or BORIS-compatible JSON.'
135- ),
132+ help_text = _ ('JSON export from PyBehaviorLog 0.9.1 or BORIS-compatible JSON.' ),
136133 )
137134 replace_existing = forms .BooleanField (
138135 required = False ,
@@ -164,7 +161,12 @@ class ProjectBORISImportForm(forms.Form):
164161
165162
166163class SessionImportForm (forms .Form ):
167- file = forms .FileField (label = _ ('File' ), help_text = _ ('PyBehaviorLog 0.9.1 JSON, BORIS observation JSON, spreadsheet-like session tables, or CowLog plain-text coding results.' ))
164+ file = forms .FileField (
165+ label = _ ('File' ),
166+ help_text = _ (
167+ 'PyBehaviorLog 0.9.1 JSON, BORIS observation JSON, spreadsheet-like session tables, or CowLog plain-text coding results.'
168+ ),
169+ )
168170 clear_existing = forms .BooleanField (
169171 required = False ,
170172 label = _ ('Delete existing events and annotations before import' ),
@@ -187,7 +189,12 @@ class Meta:
187189 'description' : forms .TextInput (),
188190 'key_binding' : forms .TextInput (attrs = {'maxlength' : 1 }),
189191 }
190- labels = {'name' : _ ('Name' ), 'description' : _ ('Description' ), 'key_binding' : _ ('Key binding' ), 'sort_order' : _ ('Sort order' )}
192+ labels = {
193+ 'name' : _ ('Name' ),
194+ 'description' : _ ('Description' ),
195+ 'key_binding' : _ ('Key binding' ),
196+ 'sort_order' : _ ('Sort order' ),
197+ }
191198
192199 def clean_key_binding (self ):
193200 return self .cleaned_data ['key_binding' ].upper ()
@@ -201,7 +208,12 @@ class Meta:
201208 'description' : forms .TextInput (),
202209 'color' : forms .TextInput (attrs = {'type' : 'color' }),
203210 }
204- labels = {'name' : _ ('Name' ), 'description' : _ ('Description' ), 'color' : _ ('Color' ), 'sort_order' : _ ('Sort order' )}
211+ labels = {
212+ 'name' : _ ('Name' ),
213+ 'description' : _ ('Description' ),
214+ 'color' : _ ('Color' ),
215+ 'sort_order' : _ ('Sort order' ),
216+ }
205217
206218
207219class SubjectForm (forms .ModelForm ):
@@ -214,7 +226,14 @@ class Meta:
214226 'color' : forms .TextInput (attrs = {'type' : 'color' }),
215227 'groups' : forms .CheckboxSelectMultiple (),
216228 }
217- labels = {'name' : _ ('Name' ), 'description' : _ ('Description' ), 'groups' : _ ('Groups' ), 'key_binding' : _ ('Key binding' ), 'color' : _ ('Color' ), 'sort_order' : _ ('Sort order' )}
229+ labels = {
230+ 'name' : _ ('Name' ),
231+ 'description' : _ ('Description' ),
232+ 'groups' : _ ('Groups' ),
233+ 'key_binding' : _ ('Key binding' ),
234+ 'color' : _ ('Color' ),
235+ 'sort_order' : _ ('Sort order' ),
236+ }
218237
219238 def __init__ (self , * args , project = None , ** kwargs ):
220239 super ().__init__ (* args , ** kwargs )
@@ -236,7 +255,14 @@ class Meta:
236255 'set_values' : forms .Textarea (attrs = {'rows' : 3 }),
237256 'default_value' : forms .TextInput (),
238257 }
239- labels = {'label' : _ ('Label' ), 'description' : _ ('Description' ), 'value_type' : _ ('Value type' ), 'set_values' : _ ('Allowed values' ), 'default_value' : _ ('Default value' ), 'sort_order' : _ ('Sort order' )}
258+ labels = {
259+ 'label' : _ ('Label' ),
260+ 'description' : _ ('Description' ),
261+ 'value_type' : _ ('Value type' ),
262+ 'set_values' : _ ('Allowed values' ),
263+ 'default_value' : _ ('Default value' ),
264+ 'sort_order' : _ ('Sort order' ),
265+ }
240266
241267
242268class BehaviorForm (forms .ModelForm ):
@@ -248,7 +274,15 @@ class Meta:
248274 'key_binding' : forms .TextInput (attrs = {'maxlength' : 1 }),
249275 'color' : forms .TextInput (attrs = {'type' : 'color' }),
250276 }
251- labels = {'category' : _ ('Category' ), 'name' : _ ('Name' ), 'description' : _ ('Description' ), 'key_binding' : _ ('Key binding' ), 'color' : _ ('Color' ), 'mode' : _ ('Mode' ), 'sort_order' : _ ('Sort order' )}
277+ labels = {
278+ 'category' : _ ('Category' ),
279+ 'name' : _ ('Name' ),
280+ 'description' : _ ('Description' ),
281+ 'key_binding' : _ ('Key binding' ),
282+ 'color' : _ ('Color' ),
283+ 'mode' : _ ('Mode' ),
284+ 'sort_order' : _ ('Sort order' ),
285+ }
252286
253287 def __init__ (self , * args , project = None , ** kwargs ):
254288 super ().__init__ (* args , ** kwargs )
@@ -279,7 +313,15 @@ class Meta:
279313 'subjects' : forms .CheckboxSelectMultiple (),
280314 'variable_definitions' : forms .CheckboxSelectMultiple (),
281315 }
282- labels = {'name' : _ ('Name' ), 'description' : _ ('Description' ), 'default_session_kind' : _ ('Default session kind' ), 'behaviors' : _ ('Behaviors' ), 'modifiers' : _ ('Modifiers' ), 'subjects' : _ ('Subjects' ), 'variable_definitions' : _ ('Independent variables' )}
316+ labels = {
317+ 'name' : _ ('Name' ),
318+ 'description' : _ ('Description' ),
319+ 'default_session_kind' : _ ('Default session kind' ),
320+ 'behaviors' : _ ('Behaviors' ),
321+ 'modifiers' : _ ('Modifiers' ),
322+ 'subjects' : _ ('Subjects' ),
323+ 'variable_definitions' : _ ('Independent variables' ),
324+ }
283325
284326 def __init__ (self , * args , project = None , ** kwargs ):
285327 super ().__init__ (* args , ** kwargs )
@@ -308,11 +350,18 @@ def __init__(self, *args, **kwargs):
308350 self .fields ['file' ].required = False
309351
310352
311-
312353class ObservationSegmentForm (forms .ModelForm ):
313354 class Meta :
314355 model = ObservationSegment
315- fields = ['title' , 'start_seconds' , 'end_seconds' , 'status' , 'assignee' , 'reviewer' , 'notes' ]
356+ fields = [
357+ 'title' ,
358+ 'start_seconds' ,
359+ 'end_seconds' ,
360+ 'status' ,
361+ 'assignee' ,
362+ 'reviewer' ,
363+ 'notes' ,
364+ ]
316365 widgets = {'notes' : forms .Textarea (attrs = {'rows' : 3 })}
317366 labels = {
318367 'title' : _ ('Title' ),
@@ -328,7 +377,9 @@ def __init__(self, *args, project=None, **kwargs):
328377 super ().__init__ (* args , ** kwargs )
329378 queryset = User .objects .order_by ('username' )
330379 if project is not None :
331- member_ids = list (project .memberships .values_list ('user_id' , flat = True )) + [project .owner_id ]
380+ member_ids = list (project .memberships .values_list ('user_id' , flat = True )) + [
381+ project .owner_id
382+ ]
332383 queryset = queryset .filter (pk__in = member_ids ).distinct ()
333384 self .fields ['assignee' ].queryset = queryset
334385 self .fields ['reviewer' ].queryset = queryset
@@ -338,7 +389,9 @@ def clean(self):
338389 start = cleaned .get ('start_seconds' )
339390 end = cleaned .get ('end_seconds' )
340391 if start is not None and end is not None and end < start :
341- self .add_error ('end_seconds' , _ ('End time must be greater than or equal to start time.' ))
392+ self .add_error (
393+ 'end_seconds' , _ ('End time must be greater than or equal to start time.' )
394+ )
342395 return cleaned
343396
344397
@@ -438,9 +491,9 @@ def __init__(self, *args, project=None, **kwargs):
438491 definition .value_type == IndependentVariableDefinition .TYPE_SET
439492 and definition .set_values
440493 ):
441- help_text = (
442- help_text + ' ' if help_text else ' '
443- ) + _ ( 'Allowed values: %(values)s' ) % {'values' : definition .set_values }
494+ help_text = (help_text + ' ' if help_text else '' ) + _ (
495+ 'Allowed values: %(values)s '
496+ ) % {'values' : definition .set_values }
444497 field .help_text = help_text
445498 self .fields [field_name ] = field
446499 initial_value = definition .default_value
0 commit comments