diff --git a/app/models/admin.rb b/app/models/admin.rb index 9d84296..bfc8b82 100644 --- a/app/models/admin.rb +++ b/app/models/admin.rb @@ -9,31 +9,10 @@ class Admin < ActiveRecord::Base attr_accessor :login # Setup accessible (or protected) attributes for your model - attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :name, :firstname, :roles_mask, :roles, :super_admin + attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :name, :firstname # attr_accessible :title, :body - ROLES = %w[SuperAdmin] - - def super_admin? - true if self.is? :SuperAdmin - end - - - def roles=(roles) - self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum - end - - def roles - ROLES.reject do |r| - ((roles_mask || 0) & 2**ROLES.index(r)).zero? - end - end - - def is?(role) - roles.include?(role.to_s) - end - protected def self.find_for_database_authentication(warden_conditions) diff --git a/app/views/admin/admins/_form.html.haml b/app/views/admin/admins/_form.html.haml index 839757c..1e278cc 100644 --- a/app/views/admin/admins/_form.html.haml +++ b/app/views/admin/admins/_form.html.haml @@ -31,15 +31,7 @@ %td= f.text_field :password_confirmation, :class => "inputText" - %tr - %td{:style => "vertical-align:top;"} Roles : - %td - - for role in Admin::ROLES - = check_box_tag "admin[roles][]", role, @admin.roles.include?(role) - =h role.humanize - %br - = hidden_field_tag "admin[roles][]", "" - + .actions %button{:type => "submit"} Sauvegarder