Merge branch 'master' into feature-file-templates
Conflicts: app/views/application/_navigation.html.slim config/locales/de.yml config/locales/en.yml db/schema.rb
This commit is contained in:
@@ -13,24 +13,19 @@ class ExercisePolicy < AdminOrAuthorPolicy
|
||||
end
|
||||
|
||||
[:clone?, :destroy?, :edit?, :statistics?, :update?].each do |action|
|
||||
define_method(action) { admin? || author? || team_member? }
|
||||
define_method(action) { admin? || author?}
|
||||
end
|
||||
|
||||
[:implement?, :submit?, :reload?].each do |action|
|
||||
define_method(action) { everyone }
|
||||
end
|
||||
|
||||
def team_member?
|
||||
@record.team.try(:members, []).include?(@user) if @record.team
|
||||
end
|
||||
private :team_member?
|
||||
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
if @user.admin?
|
||||
@scope.all
|
||||
elsif @user.internal_user?
|
||||
@scope.where('user_id = ? OR public = TRUE OR (team_id IS NOT NULL AND team_id IN (SELECT t.id FROM teams t JOIN internal_users_teams iut ON t.id = iut.team_id WHERE iut.internal_user_id = ?))', @user.id, @user.id)
|
||||
@scope.where('user_id = ? OR public = TRUE', @user.id)
|
||||
else
|
||||
@scope.none
|
||||
end
|
||||
|
@@ -1,5 +1,8 @@
|
||||
class RequestForCommentPolicy < ApplicationPolicy
|
||||
|
||||
def author?
|
||||
@user == @record.author
|
||||
end
|
||||
private :author?
|
||||
|
||||
def create?
|
||||
everyone
|
||||
@@ -13,6 +16,10 @@ class RequestForCommentPolicy < ApplicationPolicy
|
||||
define_method(action) { admin? }
|
||||
end
|
||||
|
||||
def mark_as_solved?
|
||||
admin? || author?
|
||||
end
|
||||
|
||||
def edit?
|
||||
admin?
|
||||
end
|
||||
|
@@ -8,7 +8,7 @@ class SubmissionPolicy < ApplicationPolicy
|
||||
everyone
|
||||
end
|
||||
|
||||
[:download_file?, :render_file?, :run?, :score?, :show?, :statistics?, :stop?, :test?].each do |action|
|
||||
[:download?, :download_file?, :render_file?, :run?, :score?, :show?, :statistics?, :stop?, :test?].each do |action|
|
||||
define_method(action) { admin? || author? }
|
||||
end
|
||||
|
||||
|
@@ -1,14 +0,0 @@
|
||||
class TeamPolicy < ApplicationPolicy
|
||||
[:create?, :index?, :new?].each do |action|
|
||||
define_method(action) { admin? }
|
||||
end
|
||||
|
||||
[:destroy?, :edit?, :show?, :update?].each do |action|
|
||||
define_method(action) { admin? || member? }
|
||||
end
|
||||
|
||||
def member?
|
||||
@record.members.include?(@user)
|
||||
end
|
||||
private :member?
|
||||
end
|
Reference in New Issue
Block a user