Skip to content
Snippets Groups Projects
Commit e19dd96e authored by Clarissa's avatar Clarissa
Browse files

#204: creating moderator role and adding to user

parent 25bcb9fb
No related branches found
No related tags found
No related merge requests found
......@@ -29,4 +29,8 @@ class Role < ApplicationRecord
def self.curator
find_by(name: 'curator') || create!(name: 'curator')
end
def self.moderator
find_by(name: 'moderator') || create!(name: 'moderator')
end
end
......@@ -100,6 +100,17 @@ class User < ApplicationRecord
false
end
def is_moderator?
roles.each do |role|
return true if role.name == 'moderator'
end
false
end
def can_moderate?
self.is_admin? || self.is_moderator?
end
def associated_collections
c = collections.blank? ? [] : collections.to_a
institutions.each { |i| c.push(*i.collections.to_a) }
......
......@@ -9,6 +9,7 @@ Role.create(name: 'teacher', description: 'This role represents a Teacher in Por
Role.create(name: 'student', description: 'This role represents a Student in Portal MEC.')
Role.create(name: 'admin', description: 'This role represents an MEC Admin, that can perform any action.')
Role.create(name: 'curator', description: 'This role represents a content Curator in Portal MEC.')
Role.create(name: 'moderator', description: 'This role represents a content Moderator in Portal MEC, with less privileges than admin.')
# create the default admin
User.create(
......
require 'active_support'
module Portalmec::SociableTests
extend ActiveSupport::Testing::Declarative
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment