Class: Ccls::User
- Inherits:
-
Calnet::User
- Object
- Calnet::User
- Ccls::User
- Defined in:
- lib/ccls_engine/ccls_user.rb
Overview
requires
* uid (unique)
accessible attributes
* sn * displayname * mail * telephonenumber
Class Method Summary collapse
-
.inherited(subclass) ⇒ Object
defined in plugin/engine …
Class Method Details
.inherited(subclass) ⇒ Object
defined in plugin/engine …
def may_administrate?(*args) (self.role_names & [‘superuser’,‘administrator’]).length > 0 end
def may_read?(*args) (self.role_names & [‘superuser’,‘administrator’,‘editor’,‘interviewer’,‘reader’] ).length > 0 end
def may_edit?(*args) (self.role_names & [‘superuser’,‘administrator’,‘editor’] ).length > 0 end
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/ccls_engine/ccls_user.rb', line 82 def self.inherited(subclass) subclass.class_eval do # for some reason is nil which causes problems self.default_scoping = [] # I don't think that having this in a separate gem # is necessary anymore. This is the only place that # it is ever used. I'll import the calnet_authenticated # functionality later. # calnet_authenticated # validates_presence_of :uid # validates_uniqueness_of :uid # include the many may_*? for use in the controllers # I don't know why I need this in BOTH Calnet::User AND Ccls::User # It works without it in the console, but some random tests fail # should probably ensure that calling it twice doesn't do anything bad # alias_method :may_create?, :may_edit? # alias_method :may_update?, :may_edit? # alias_method :may_destroy?, :may_edit? # %w( people races languages refusal_reasons ineligible_reasons # ).each do |resource| # alias_method "may_create_#{resource}?".to_sym, :may_administrate? # alias_method "may_read_#{resource}?".to_sym, :may_administrate? # alias_method "may_edit_#{resource}?".to_sym, :may_administrate? # alias_method "may_update_#{resource}?".to_sym, :may_administrate? # alias_method "may_destroy_#{resource}?".to_sym, :may_administrate? # end end # class_eval end |