Sha256: 20e999aabc4d054896d1407c51907ae8eb844ea8650011d1cb6a112f0186dc59
Contents?: true
Size: 1.33 KB
Versions: 7
Compression:
Stored size: 1.33 KB
Contents
module Adminpanel class Permission < ActiveRecord::Base include Adminpanel::Base include ApplicationHelper enum action: [ :to_read, :to_publish, :to_create, :to_update, :to_destroy, :to_manage ] belongs_to :role, touch: true # validates_presence_of :action validates_presence_of :role_id validates_presence_of :resource def name "#{self.role.name}: #{I18n.t("#{self.class.name.demodulize.downcase}.#{self.action}")} #{symbol_class(self['resource']).display_name}" end def self.form_attributes [ { 'role_id' => { 'type' => 'belongs_to', 'label' => I18n.t('permission.role'), 'model' => 'Adminpanel::Role', # 'remote_resource' => false } }, { 'action' => { 'type' => 'enum_field', 'label' => I18n.t('permission.action'), } }, { 'resource' => { 'type' => 'resource_select', 'label' => I18n.t('permission.resource'), } }, ] end def self.display_name I18n.t('model.Permission') # singular end def self.icon 'gavel' # fa-{icon} end end end
Version data entries
7 entries across 7 versions & 1 rubygems