Class: Adminpanel::Permission

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ApplicationHelper, Base
Defined in:
app/models/adminpanel/permission.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ApplicationHelper

#adminpanel_form_for, #full_title, #is_current_section?, #link_to_add_fields, #main_root_path, #route_symbol, #symbol_class

Methods included from SharedPagesHelper

#active_tab, #belong_to_object_name, #class_name_downcase, #demodulize_class, #field_value, #get_oauth_link, #is_customized_field?, #pluralize_model, #relationship_ids, #table_type

Methods included from BreadcrumbsHelper

#breadcrumb_add, #render_breadcrumb

Methods included from SessionsHelper

#current_user, #current_user=, #sign_in, #sign_out, #signed_in?

Methods included from Base

#correlative_order_gallery, #destroy_unattached_images

Class Method Details

.display_nameObject



49
50
51
# File 'app/models/adminpanel/permission.rb', line 49

def self.display_name
  I18n.t('model.Permission') # singular
end

.form_attributesObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/adminpanel/permission.rb', line 25

def self.form_attributes
  [
    {
      'role_id' => {
        'type' => 'select',
        'label' => I18n.t('permission.role'),
        'options' => Proc.new {|object| Adminpanel::Role.all }
      }
    },
    {
      'action' => {
        'type' => 'enum_field',
        'label' => I18n.t('permission.action'),
      }
    },
    {
      'resource' => {
        'type' => 'resource_select',
        'label' => I18n.t('permission.resource'),
      }
    },
  ]
end

.iconObject



53
54
55
# File 'app/models/adminpanel/permission.rb', line 53

def self.icon
  'gavel' # fa-{icon}
end

Instance Method Details

#nameObject



21
22
23
# File 'app/models/adminpanel/permission.rb', line 21

def name
  "#{self.role.name}: #{I18n.t("#{self.class.name.demodulize.downcase}.#{self.action}")} #{self['resource']}"
end