@@ -75,9 +75,7 @@ def schedule():
75
75
venues = VolunteerVenue .get_all ()
76
76
77
77
untrained_roles = [
78
- r
79
- for r in roles
80
- if r ["is_interested" ] and r ["requires_training" ] and not r ["is_trained" ]
78
+ r for r in roles if r ["is_interested" ] and r ["requires_training" ] and not r ["is_trained" ]
81
79
]
82
80
83
81
return render_template (
@@ -97,17 +95,15 @@ def shift(shift_id):
97
95
shift = Shift .query .get_or_404 (shift_id )
98
96
all_volunteers = Volunteer .query .order_by (Volunteer .nickname ).all ()
99
97
100
- return render_template (
101
- "volunteer/shift.html" , shift = shift , all_volunteers = all_volunteers
102
- )
98
+ return render_template ("volunteer/shift.html" , shift = shift , all_volunteers = all_volunteers )
103
99
104
100
105
101
@volunteer .route ("/shift/<shift_id>/sign-up" , methods = ["POST" ])
106
102
@feature_flag ("VOLUNTEERS_SCHEDULE" )
107
103
@v_user_required
108
104
def shift_sign_up (shift_id ):
109
105
shift = Shift .query .get_or_404 (shift_id )
110
- if current_user .has_permission ("volunteer:admin" ) and request . form [ "user_id" ] :
106
+ if current_user .has_permission ("volunteer:admin" ) and "user_id" in request . form :
111
107
user = User .query .get (request .form ["user_id" ])
112
108
else :
113
109
user = current_user
@@ -119,17 +115,10 @@ def shift_sign_up(shift_id):
119
115
return redirect_next_or_schedule (f"Signed up for { shift .role .name } shift" )
120
116
121
117
if shift .current_count >= shift .max_needed :
122
- return redirect_next_or_schedule (
123
- "This shift is already full. You have not been signed up."
124
- )
125
-
126
- if (
127
- shift .role .requires_training
128
- and shift .role not in Volunteer .get_for_user (current_user ).trained_roles
129
- ):
130
- return redirect_next_or_schedule (
131
- "You must complete training before you can sign up for this shift."
132
- )
118
+ return redirect_next_or_schedule ("This shift is already full. You have not been signed up." )
119
+
120
+ if shift .role .requires_training and shift .role not in Volunteer .get_for_user (current_user ).trained_roles :
121
+ return redirect_next_or_schedule ("You must complete training before you can sign up for this shift." )
133
122
134
123
for shift_entry in user .shift_entries :
135
124
if shift .is_clash (shift_entry .shift ):
0 commit comments