From dd0e3c2c38ebf22f26a3d9d2c71c8931aa15e7c3 Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Tue, 7 Apr 2020 00:12:51 +0300 Subject: [PATCH] Add protection for important groups --- app/models/group.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/group.rb b/app/models/group.rb index 8218d08..3795bcc 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -49,7 +49,11 @@ class Group < ActiveRecord::Base end def can_destroy? cuser - cuser and cuser.admin? and id != Group::ADMINS + cuser and cuser.admin? and id != Group::ADMINS and !Group.protected_groups.include?(id) + end + + def self.protected_groups + Group.constants(false).map {|n| Group.const_get(n)} end def self.staff @@ -124,6 +128,6 @@ class Group < ActiveRecord::Base end def self.params(params, cuser) - params.require(:gather).permit(:task) + params.require(:group).permit(:name) end end