Commit fea7117 1 parent fbc3e8a commit fea7117 Copy full SHA for fea7117
File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change
1
+ import datetime
1
2
from datetime import timedelta
2
3
3
4
from django import forms
@@ -397,6 +398,11 @@ class ConvertShiftExemptionToMembershipPauseForm(forms.Form):
397
398
)
398
399
399
400
401
+ class NotificationDurationField (forms .Field ):
402
+ def prepare_value (self , value : datetime .timedelta ) -> int :
403
+ return int (value .total_seconds () / 3600 )
404
+
405
+
400
406
class ShiftWatchForm (forms .ModelForm ):
401
407
def clean_notification_timedelta (self ):
402
408
time = self .data ["notification_timedelta" ]
@@ -405,6 +411,7 @@ def clean_notification_timedelta(self):
405
411
class Meta :
406
412
model = ShiftWatch
407
413
fields = ["notification_timedelta" ]
414
+ field_classes = {"notification_timedelta" : NotificationDurationField }
408
415
widgets = {
409
416
"notification_timedelta" : forms .NumberInput (
410
417
attrs = {
You can’t perform that action at this time.
0 commit comments