Sha256: f01f83674162a7e54c9286e7137ca89fd5c3d558e91f684bdf24d98aface3abd
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
module MyAdmin class ModelConfiguration attr_accessor :collection, :member, :application, :list_display, :show_display, :export_display, :filters, :fieldsets, :fields, :permissions, :per_page def initialize(klass) begin @class = klass @application = "authentication" @permissions = [:list, :create, :update, :destroy, :export] if @class.table_exists? @list_display = (klass.columns.map{ |c| c.name } - ['id', 'created_at', 'updated_at']) #, 'created_at', 'updated_at']) @fieldsets = [{:fields => (klass.columns.map{ |c| c.name } - ['id', 'created_at', 'updated_at']) }] # , 'created_at', 'updated_at']) }] @show_display = nil #(klass.columns.map{ |c| c.name } - ['id']) @export_display = nil #(klass.columns.map{ |c| c.name }) @filters = nil end @collection = [] @member = [] @fields = {} @per_page = 10 rescue end end def application_url # I18n.t!("my_admin.urls.applications."+@application) rescue @application @application end def url # I18n.t!("my_admin.urls.models.#{@class.model_tableize}") rescue @class.model_tableize @class.model_tableize end def url_single self.url.singularize end def can?(permission, user) (@permissions.member? permission.to_sym and (user.superuser or not user.permissions.to_a.find { |p| p.name == permission.to_s and p.model == @class.to_s and p.application == @application }.blank?)) end def filters @filters || @list_display end def export_display @export_display || @show_display || @list_display end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
my_admin-0.0.3 | lib/my_admin/model_configuration.rb |
my_admin-0.0.2 | lib/my_admin/model_configuration.rb |