Parcourir la Source

Hotfix issue preventing non-admins from presenceing

Maarten van den Berg il y a 7 ans
Parent
commit
2e4d2e0445

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

@@ -41,11 +41,18 @@ function change_presence(e)
41 41
 	req = $.ajax(`/groups/${group}/activities/${activity}/presence`,
42 42
 		{
43 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 57
 	// Pack data for success
51 58
 	req.aardbei_activity_data =

+ 9 - 2
app/controllers/activities_controller.rb

@@ -124,14 +124,21 @@ class ActivitiesController < ApplicationController
124 124
       person_id: params[:person_id],
125 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 135
     end
130 136
 
131 137
     if params[:participant]
132 138
       params[:notes] = params[:participant][:notes]
133 139
     end
134 140
     participant.update_attributes(params.permit(:notes, :attending))
141
+    head :no_content
135 142
   end
136 143
 
137 144
   def mass_new