Add protection for important groups

This commit is contained in:
Ari Timonen 2020-04-07 00:12:51 +03:00
parent 8b2ce91625
commit dd0e3c2c38

View file

@ -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