Browse Source

Hotfix issue preventing non-admins from presenceing

Maarten van den Berg 7 years ago
parent
commit
2e4d2e0445

+ 10 - 3
app/assets/javascripts/buttonhandlers.jsx.js

41
 	req = $.ajax(`/groups/${group}/activities/${activity}/presence`,
41
 	req = $.ajax(`/groups/${group}/activities/${activity}/presence`,
42
 		{
42
 		{
43
 		  method: 'PUT',
43
 		  method: 'PUT',
44
-		  data: {person_id: person, attending: state}
44
+		  data: {person_id: person, attending: state},
45
+		  statusCode: {
46
+			423: function() {
47
+				alert( "De deadline is al verstreken! Vraag orgi of bestuur of het nog kan.");
48
+			},
49
+			403: function() {
50
+				alert( "Je hebt geen rechten om iemand anders aan te passen!");
51
+			}
52
+		  }
45
 		}
53
 		}
46
 	)
54
 	)
47
-	.done( activity_changed )
48
-	.fail( alert_failure );
55
+	.done( activity_changed );
49
 
56
 
50
 	// Pack data for success
57
 	// Pack data for success
51
 	req.aardbei_activity_data =
58
 	req.aardbei_activity_data =

+ 9 - 2
app/controllers/activities_controller.rb

124
       person_id: params[:person_id],
124
       person_id: params[:person_id],
125
       activity: @activity
125
       activity: @activity
126
     )
126
     )
127
-    if !@activity.may_change?(current_person)
128
-      render status: :forbidden
127
+    if params[:person_id].to_i != current_person.id && !@activity.may_change?(current_person)
128
+      head :forbidden
129
+      return
130
+    end
131
+
132
+    if @activity.deadline && @activity.deadline < Time.now && !@activity.may_change?(current_person)
133
+      head :locked
134
+      return
129
     end
135
     end
130
 
136
 
131
     if params[:participant]
137
     if params[:participant]
132
       params[:notes] = params[:participant][:notes]
138
       params[:notes] = params[:participant][:notes]
133
     end
139
     end
134
     participant.update_attributes(params.permit(:notes, :attending))
140
     participant.update_attributes(params.permit(:notes, :attending))
141
+    head :no_content
135
   end
142
   end
136
 
143
 
137
   def mass_new
144
   def mass_new