
Tags can be added to exercises in the edit view. Tags can monitored under /tags. Added the concept of ProxyExercises which are a collection of Exercises. They can be found under /proxy_exercises Added Interventions as prework to show interventions later to the user. Added exercise/[:id]/working_time to return the working time of the user in this exercise and the average working time of all users in this exercise
35 lines
669 B
Ruby
35 lines
669 B
Ruby
class ExercisePolicy < AdminOrAuthorPolicy
|
|
def author?
|
|
@user == @record.author
|
|
end
|
|
private :author?
|
|
|
|
def batch_update?
|
|
admin?
|
|
end
|
|
|
|
def show?
|
|
@user.internal_user?
|
|
end
|
|
|
|
[:clone?, :destroy?, :edit?, :statistics?, :update?].each do |action|
|
|
define_method(action) { admin? || author?}
|
|
end
|
|
|
|
[:implement?, :working_times?, :submit?, :reload?].each do |action|
|
|
define_method(action) { everyone }
|
|
end
|
|
|
|
class Scope < Scope
|
|
def resolve
|
|
if @user.admin?
|
|
@scope.all
|
|
elsif @user.internal_user?
|
|
@scope.where('user_id = ? OR public = TRUE', @user.id)
|
|
else
|
|
@scope.none
|
|
end
|
|
end
|
|
end
|
|
end
|