Sha256: 356a769ea6902bdcbf923488833ad344c718b323d8f598779e36d21e513d8189
Contents?: true
Size: 1.93 KB
Versions: 3
Compression:
Stored size: 1.93 KB
Contents
# -*- encoding: utf-8 -*- class LibraryGroup < ActiveRecord::Base attr_accessible :name, :display_name, :short_name, :my_networks, :login_banner, :note, :country_id, :admin_networks, :url, :colors_attributes if defined?(EnjuBookmark) attr_accessible :allow_bookmark_external_url end #include Singleton include MasterModel has_many :libraries has_many :colors belongs_to :country validates :url, presence: true, url: true accepts_nested_attributes_for :colors, update_only: true def self.site_config LibraryGroup.find(1) end def self.system_name(locale = I18n.locale) LibraryGroup.site_config.display_name.localize(locale) end def config? true if self == LibraryGroup.site_config end def real_libraries # 物理的な図書館 = IDが1以外 libraries.where('id != 1').all end def network_access_allowed?(ip_address, options = {}) options = { network_type: :lan }.merge(options) client_ip = IPAddr.new(ip_address) case options[:network_type] when :admin allowed_networks = admin_networks.to_s.split else allowed_networks = my_networks.to_s.split end allowed_networks.each do |allowed_network| begin network = IPAddr.new(allowed_network) return true if network.include?(client_ip) rescue ArgumentError nil end end return false end def user User.find(1) end end # == Schema Information # # Table name: library_groups # # id :integer not null, primary key # name :string(255) not null # display_name :text # short_name :string(255) not null # my_networks :text # login_banner :text # note :text # country_id :integer # position :integer # created_at :datetime not null # updated_at :datetime not null # admin_networks :text # url :string(255) default("http://localhost:3000/") #
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
enju_library-0.1.0.pre39 | app/models/library_group.rb |
enju_library-0.1.0.pre38 | app/models/library_group.rb |
enju_library-0.1.0.pre37 | app/models/library_group.rb |