Newer
Older
dmpopidor / app / models / perm.rb
@Gavin Morrice Gavin Morrice on 19 Jul 2018 775 bytes Remove Rails 3 attr accessible from models (#1691)
class Perm < ActiveRecord::Base
  ##
  # Associations
  has_and_belongs_to_many :users, :join_table => :users_perms

  validates :name, presence: {message: _("can't be blank")}, uniqueness: {message: _("must be unique")}

  scope :add_orgs, -> {Perm.find_by(name: 'add_organisations')}
  scope :change_affiliation, -> {Perm.find_by(name: 'change_org_affiliation')}
  scope :grant_permissions, -> {Perm.find_by(name: 'grant_permissions')}
  scope :modify_templates, -> {Perm.find_by(name: 'modify_templates')}
  scope :modify_guidance, -> {Perm.find_by(name: 'modify_guidance')}
  scope :use_api, -> {Perm.find_by(name: 'use_api')}
  scope :change_org_details, -> {Perm.find_by(name: 'change_org_details')}
  scope :grant_api, -> {Perm.find_by(name: 'grant_api_to_orgs')}
end