Commit 045e118 1 parent bff53c3 commit 045e118 Copy full SHA for 045e118
File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -345,9 +345,11 @@ def form_valid(self, form):
345
345
shift_date = form .cleaned_data ['date' ]
346
346
shift_start_time = form .cleaned_data ['start_time' ]
347
347
shift_end_time = form .cleaned_data ['end_time' ]
348
+ max_vols = form .cleaned_data ['max_volunteers' ]
348
349
349
350
# save when all conditions satisfied
350
- if (shift_date >= start_date_job and shift_date <= end_date_job and shift_end_time > shift_start_time ):
351
+ if (shift_date >= start_date_job and shift_date <= end_date_job and shift_end_time > shift_start_time \
352
+ and max_vols >= len (shift .volunteers .all ())):
351
353
shift_to_edit = form .save (commit = False )
352
354
shift_to_edit .job = job
353
355
shift_to_edit .save ()
@@ -357,6 +359,9 @@ def form_valid(self, form):
357
359
messages .add_message (self .request , messages .INFO , 'Shift date should lie within Job dates' )
358
360
if shift_end_time <= shift_start_time :
359
361
messages .add_message (self .request , messages .INFO , 'Shift end time should be greater than start time' )
362
+ if max_vols < len (shift .volunteers .all ()):
363
+ messages .add_message (self .request , messages .INFO , 'Max volunteers should be greater than or equal to'
364
+ ' the already assigned volunteers.' )
360
365
return render (
361
366
self .request ,
362
367
'shift/edit.html' ,
You can’t perform that action at this time.
0 commit comments