enju_library 0.1.0.pre36 → 0.1.0.pre37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/accepts_controller.rb +3 -3
  3. data/app/controllers/libraries_controller.rb +5 -4
  4. data/app/controllers/library_groups_controller.rb +0 -1
  5. data/app/controllers/shelves_controller.rb +4 -4
  6. data/app/helpers/shelves_helper.rb +3 -4
  7. data/app/models/accept.rb +1 -1
  8. data/app/models/basket.rb +2 -2
  9. data/app/models/bookstore.rb +2 -2
  10. data/app/models/budget_type.rb +7 -1
  11. data/app/models/color.rb +22 -0
  12. data/app/models/enju_library/ability.rb +3 -3
  13. data/app/models/library.rb +20 -17
  14. data/app/models/library_group.rb +10 -4
  15. data/app/models/request_status_type.rb +7 -1
  16. data/app/models/request_type.rb +7 -1
  17. data/app/models/search_engine.rb +7 -7
  18. data/app/models/shelf.rb +5 -5
  19. data/app/models/subscription.rb +1 -1
  20. data/app/views/baskets/show.html.erb +2 -2
  21. data/app/views/libraries/_calendar.html.erb +6 -2
  22. data/app/views/libraries/show.html.erb +4 -4
  23. data/app/views/libraries/show.js.erb +1 -0
  24. data/app/views/library_groups/_form.html.erb +14 -5
  25. data/app/views/library_groups/show.html.erb +13 -0
  26. data/app/views/search_engines/index.html.erb +0 -1
  27. data/config/locales/translation_en.yml +1 -0
  28. data/config/locales/translation_ja.yml +1 -0
  29. data/db/migrate/20140821151023_create_colors.rb +14 -0
  30. data/lib/enju_library.rb +1 -1
  31. data/lib/enju_library/engine.rb +1 -0
  32. data/lib/enju_library/item.rb +3 -3
  33. data/lib/enju_library/version.rb +1 -1
  34. data/lib/generators/enju_library/setup/setup_generator.rb +2 -0
  35. data/lib/generators/enju_library/setup/templates/db/fixtures/colors.yml +25 -0
  36. data/lib/generators/enju_library/setup/templates/db/fixtures/request_types.yml +2 -0
  37. data/lib/tasks/color.rb +12 -0
  38. data/lib/tasks/enju_library_tasks.rake +10 -0
  39. data/spec/controllers/search_engines_controller_spec.rb +2 -2
  40. data/spec/controllers/subscribes_controller_spec.rb +2 -2
  41. data/spec/dummy/config/boot.rb +2 -2
  42. data/spec/dummy/config/initializers/friendly_id.rb +90 -0
  43. data/spec/dummy/db/development.sqlite3 +0 -0
  44. data/spec/dummy/db/migrate/005_create_manifestations.rb +0 -1
  45. data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +1 -1
  46. data/spec/dummy/db/migrate/20140813182425_add_publication_place_to_manifestation.rb +5 -0
  47. data/spec/dummy/db/migrate/20140822114527_add_error_message_to_resource_import_result.rb +5 -0
  48. data/spec/dummy/db/migrate/20140823083524_add_extent_to_manifestation.rb +5 -0
  49. data/spec/dummy/db/migrate/20140823094847_add_dimensions_to_manifestation.rb +5 -0
  50. data/spec/dummy/db/migrate/20140823095740_rename_manifestation_periodical_to_serial.rb +9 -0
  51. data/spec/dummy/db/schema.rb +18 -4
  52. data/spec/dummy/db/test.sqlite3 +0 -0
  53. data/spec/dummy/solr/default/data/index/_21e.fdt +0 -0
  54. data/spec/dummy/solr/default/data/index/{_1we.fdx → _21e.fdx} +0 -0
  55. data/spec/dummy/solr/default/data/index/{_1we.fnm → _21e.fnm} +0 -0
  56. data/spec/dummy/solr/default/data/index/{_1we.nvd → _21e.nvd} +0 -0
  57. data/spec/dummy/solr/default/data/index/{_1we.nvm → _21e.nvm} +0 -0
  58. data/spec/dummy/solr/default/data/index/{_1we.si → _21e.si} +0 -0
  59. data/spec/dummy/solr/default/data/index/{_1we_Lucene41_0.doc → _21e_Lucene41_0.doc} +0 -0
  60. data/spec/dummy/solr/default/data/index/{_1we_Lucene41_0.pos → _21e_Lucene41_0.pos} +0 -0
  61. data/spec/dummy/solr/default/data/index/_21e_Lucene41_0.tim +0 -0
  62. data/spec/dummy/solr/default/data/index/{_1we_Lucene41_0.tip → _21e_Lucene41_0.tip} +0 -0
  63. data/spec/dummy/solr/default/data/index/segments.gen +0 -0
  64. data/spec/dummy/solr/default/data/index/segments_3j2 +0 -0
  65. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004563 +0 -0
  66. data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000004156 → tlog.0000000000000004564} +0 -0
  67. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004565 +0 -0
  68. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004566 +0 -0
  69. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004567 +0 -0
  70. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004568 +0 -0
  71. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004569 +0 -0
  72. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004570 +0 -0
  73. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004571 +0 -0
  74. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004572 +0 -0
  75. data/spec/dummy/tmp/cache/assets/test/sprockets/116f3db2d9d60864a0e9bf0e9eea12c1 +0 -0
  76. data/spec/dummy/tmp/cache/assets/test/sprockets/1f84f73be56154eba5c29f8ef2ac2177 +0 -0
  77. data/spec/dummy/tmp/cache/assets/test/sprockets/9858160e3e612357dced457d860640d7 +0 -0
  78. data/spec/dummy/tmp/cache/assets/test/sprockets/b561c7bed91703077a14b29a73432edc +0 -0
  79. data/spec/dummy/tmp/cache/assets/test/sprockets/ebc83b1f2325c61a70d933aa7a17df5a +0 -0
  80. data/spec/dummy/tmp/cache/assets/test/sprockets/f10609df7ed708c7c5c0efb7f12402f8 +0 -0
  81. data/spec/fixtures/colors.yml +38 -0
  82. data/spec/fixtures/manifestations.yml +0 -1
  83. data/spec/fixtures/users.yml +1 -1
  84. data/spec/support/vcr.rb +3 -3
  85. metadata +90 -73
  86. data/spec/dummy/solr/default/data/index/_1we.fdt +0 -0
  87. data/spec/dummy/solr/default/data/index/_1we_Lucene41_0.tim +0 -0
  88. data/spec/dummy/solr/default/data/index/segments_37q +0 -0
  89. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004155 +0 -0
  90. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004157 +0 -0
  91. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004158 +0 -0
  92. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004159 +0 -0
  93. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004160 +0 -0
  94. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004161 +0 -0
  95. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004162 +0 -0
  96. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004163 +0 -0
  97. data/spec/dummy/solr/default/data/tlog/tlog.0000000000000004164 +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b94a2674d770a3478bbbff653c266530e3db08b
4
- data.tar.gz: c566bfd340977a3df85685428d38dccc75acab0e
3
+ metadata.gz: d3abe64373ec9eb8255947166b0601bd8bd27ed6
4
+ data.tar.gz: 9ed1ae62421c5cc69ce9bd9f1fa86e4075e154f0
5
5
  SHA512:
6
- metadata.gz: f7a081eff08d89d647199231ce7be31ee935a936b54d024e3d9e9286bc972b9d8f1c8bd7aa72520af223d29a9397e2fce865d81a287f10ceadeb40ae340095df
7
- data.tar.gz: 24db20754ef9360aa26a8438a72420396db9a1da7b393314d1c762ade2e0cdac9c58e500eda5ce99480f8f32b7ea9953c5fbcb5114b9afc1b8ed95e6fa0175ce
6
+ metadata.gz: 9feb46a901187ef69f835f5306e7c8aff4bb46e8b51a7b745ff7ec3bd8afe05a4341bab5869a9fd673196afa7a0f93a42ea018530d6af231628ecf71d5c21f65
7
+ data.tar.gz: 2c1ebb03bc329f2cf47339c276ef5effd56177757270cd1e9674445879677ac885a01c648f635d7aedc8a2987b7a2b9a21715a219acf7fcb2dad42d797c3fcc5
@@ -11,11 +11,11 @@ class AcceptsController < ApplicationController
11
11
  else
12
12
  if params[:accept]
13
13
  @query = params[:accept][:item_identifier].to_s.strip
14
- item = Item.where(:item_identifier => @query).first if @query.present?
14
+ item = Item.where(item_identifier: @query).first if @query.present?
15
15
  end
16
16
 
17
17
  if item
18
- @accepts = Accept.order('accepts.created_at DESC').where(:item_id => item.id).page(params[:page])
18
+ @accepts = Accept.order('accepts.created_at DESC').where(item_id: item.id).page(params[:page])
19
19
  else
20
20
  if @basket
21
21
  @accepts = @basket.accepts.page(params[:page])
@@ -75,7 +75,7 @@ class AcceptsController < ApplicationController
75
75
  if @accept.item_identifier.blank?
76
76
  flash[:message] << t('accept.enter_item_identifier') if @accept.item_identifier.blank?
77
77
  else
78
- item = Item.where(:item_identifier => @accept.item_identifier.to_s.strip).first
78
+ item = Item.where(item_identifier: @accept.item_identifier.to_s.strip).first
79
79
  end
80
80
  @accept.item = item
81
81
 
@@ -6,7 +6,7 @@ class LibrariesController < ApplicationController
6
6
  # GET /libraries
7
7
  # GET /libraries.json
8
8
  def index
9
- sort = {:sort_by => 'position', :order => 'asc'}
9
+ sort = {sort_by: 'position', order: 'asc'}
10
10
  case params[:sort_by]
11
11
  when 'name'
12
12
  sort[:sort_by] = 'name'
@@ -18,7 +18,7 @@ class LibrariesController < ApplicationController
18
18
 
19
19
  @libraries = Library.search(include: [:shelves]) do
20
20
  fulltext query if query.present?
21
- paginate :page => page.to_i, :per_page => Library.default_per_page
21
+ paginate page: page.to_i, per_page: Library.default_per_page
22
22
  order_by sort[:sort_by], sort[:order]
23
23
  end.results
24
24
 
@@ -33,9 +33,9 @@ class LibrariesController < ApplicationController
33
33
  def show
34
34
  if defined?(EnjuEvent)
35
35
  search = Sunspot.new_search(Event)
36
- library = @library.dup
36
+ library_id = @library.id
37
37
  search.build do
38
- with(:library_id).equal_to library.id
38
+ with(:library_id).equal_to library_id
39
39
  order_by(:start_at, :desc)
40
40
  end
41
41
  page = params[:event_page] || 1
@@ -117,6 +117,7 @@ class LibrariesController < ApplicationController
117
117
  end
118
118
 
119
119
  private
120
+
120
121
  def prepare_options
121
122
  @library_groups = LibraryGroup.all
122
123
  @countries = Country.all_cache
@@ -32,7 +32,6 @@ class LibraryGroupsController < ApplicationController
32
32
  def update
33
33
  respond_to do |format|
34
34
  if @library_group.update_attributes(params[:library_group])
35
- expire_page '/page/opensearch'
36
35
  format.html { redirect_to @library_group, notice: t('controller.successfully_updated', model: t('activerecord.models.library_group')) }
37
36
  format.json { head :no_content }
38
37
  else
@@ -15,7 +15,7 @@ class ShelvesController < ApplicationController
15
15
  render partial: 'select_form'
16
16
  return
17
17
  else
18
- sort = {:sort_by => 'name', :order => 'asc'}
18
+ sort = {sort_by: 'name', order: 'asc'}
19
19
  #case params[:sort_by]
20
20
  #when 'name'
21
21
  # sort[:sort_by] = 'name'
@@ -28,7 +28,7 @@ class ShelvesController < ApplicationController
28
28
 
29
29
  search = Shelf.search(include: [:library]) do
30
30
  fulltext query if query.present?
31
- paginate :page => page.to_i, :per_page => Shelf.default_per_page
31
+ paginate page: page.to_i, per_page: Shelf.default_per_page
32
32
  if library
33
33
  with(:library).equal_to library.name
34
34
  order_by :position, :asc
@@ -50,7 +50,7 @@ class ShelvesController < ApplicationController
50
50
  # GET /shelves/1
51
51
  # GET /shelves/1.json
52
52
  def show
53
- @shelf = Shelf.find(params[:id], include: :library)
53
+ @shelf = Shelf.includes(:library).find(params[:id])
54
54
 
55
55
  respond_to do |format|
56
56
  format.html # show.html.erb
@@ -75,7 +75,7 @@ class ShelvesController < ApplicationController
75
75
 
76
76
  # GET /shelves/1/edit
77
77
  def edit
78
- @shelf = Shelf.find(params[:id], include: :library)
78
+ @shelf = Shelf.includes(:library).find(params[:id])
79
79
  end
80
80
 
81
81
  # POST /shelves
@@ -1,16 +1,15 @@
1
1
  module ShelvesHelper
2
2
  def library_shelf_facet(current_library, facet)
3
- library = Library.where(:name => facet.value).select([:name, :display_name]).first
3
+ library = Library.where(name: facet.value).select([:name, :display_name]).first
4
4
  return nil unless library
5
- string = ''
6
5
  current = true if current_library.try(:name) == library.name
7
6
  content_tag :li do
8
7
  if current
9
8
  content_tag :strong do
10
- link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(params.merge(:page => nil, :library_id => library.name, :only_path => true)))
9
+ link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(params.merge(page: nil, library_id: library.name, only_path: true)))
11
10
  end
12
11
  else
13
- link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(params.merge(:page => nil, :library_id => library.name, :only_path => true)))
12
+ link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(params.merge(page: nil, library_id: library.name, only_path: true)))
14
13
  end
15
14
  end
16
15
  end
@@ -1,6 +1,6 @@
1
1
  class Accept < ActiveRecord::Base
2
2
  attr_accessible :item_identifier, :librarian_id, :item_id
3
- default_scope order: 'accepts.id DESC'
3
+ default_scope { order('accepts.id DESC') }
4
4
  belongs_to :basket
5
5
  belongs_to :item, touch: true
6
6
  belongs_to :librarian, class_name: 'User'
@@ -1,7 +1,7 @@
1
1
  class Basket < ActiveRecord::Base
2
2
  attr_accessible :note, :user_number
3
- default_scope order: 'baskets.id DESC'
4
- scope :will_expire, lambda {|date| {:conditions => ['created_at < ?', date]}}
3
+ default_scope { order('baskets.id DESC') }
4
+ scope :will_expire, lambda {|date| where('created_at < ?', date)}
5
5
  belongs_to :user, validate: true
6
6
  has_many :accepts
7
7
 
@@ -1,12 +1,12 @@
1
1
  class Bookstore < ActiveRecord::Base
2
2
  attr_accessible :name, :zip_code, :address, :note, :telephone_number,
3
3
  :fax_number, :url
4
- default_scope order: "bookstores.position"
4
+ default_scope { order('bookstores.position') }
5
5
  has_many :items
6
6
 
7
7
  acts_as_list
8
8
  validates_presence_of :name
9
- validates :url, url: true, allow_blank: true, length: {:maximum => 255}
9
+ validates :url, url: true, allow_blank: true, length: { maximum: 255 }
10
10
 
11
11
  paginates_per 10
12
12
 
@@ -1,8 +1,14 @@
1
1
  class BudgetType < ActiveRecord::Base
2
2
  attr_accessible :name, :display_name, :note, :position
3
3
  include MasterModel
4
- default_scope order: 'budget_types.position'
4
+ validates :name, presence: true, format: { with: /\A[0-9A-Za-z][0-9A-Za-z_\-\s,]*[0-9a-z]\Z/ }
5
+ default_scope { order('budget_types.position') }
5
6
  has_many :items
7
+
8
+ private
9
+ def valid_name?
10
+ true
11
+ end
6
12
  end
7
13
 
8
14
  # == Schema Information
@@ -0,0 +1,22 @@
1
+ class Color < ActiveRecord::Base
2
+ attr_accessible :code, :property
3
+
4
+ belongs_to :library_group
5
+ validates :code, presence: true, format: /\A[A-Fa-f0-9]{6}\Z/
6
+ validates :property, presence: true, uniqueness: true, format: /\A[a-z][0-9a-z_]*[0-9a-z]\Z/
7
+
8
+ acts_as_list
9
+ end
10
+
11
+ # == Schema Information
12
+ #
13
+ # Table name: colors
14
+ #
15
+ # id :integer not null, primary key
16
+ # library_group_id :integer
17
+ # property :string(255)
18
+ # code :string(255)
19
+ # position :integer
20
+ # created_at :datetime not null
21
+ # updated_at :datetime not null
22
+ #
@@ -11,11 +11,11 @@ module EnjuLibrary
11
11
  end
12
12
  can [:read, :create, :update], Library
13
13
  can [:delete, :destroy], Library do |library|
14
- library.shelves.empty? and !library.web?
14
+ library.shelves.empty? && !library.web?
15
15
  end
16
16
  can [:read, :create, :update], Shelf
17
17
  can [:delete, :destroy], Shelf do |shelf|
18
- shelf.items.empty? and !shelf.web_shelf?
18
+ shelf.items.empty? && !shelf.web_shelf?
19
19
  end
20
20
  can :manage, [
21
21
  Accept,
@@ -28,7 +28,7 @@ module EnjuLibrary
28
28
  LibraryGroup,
29
29
  RequestStatusType,
30
30
  RequestType
31
- ] if LibraryGroup.site_config.network_access_allowed?(ip_address, :network_type => :admin)
31
+ ] if LibraryGroup.site_config.network_access_allowed?(ip_address, network_type: :admin)
32
32
  can :read, [
33
33
  LibraryGroup,
34
34
  RequestStatusType,
@@ -6,11 +6,11 @@ class Library < ActiveRecord::Base
6
6
  :country_id, :opening_hour, :isil, :position
7
7
 
8
8
  include MasterModel
9
- default_scope order: 'libraries.position'
10
- scope :real, where('id != 1')
11
- has_many :shelves, order: 'shelves.position'
9
+ default_scope { order('libraries.position') }
10
+ scope :real, -> { where('id != 1') }
11
+ has_many :shelves
12
12
  belongs_to :library_group, validate: true
13
- has_many :users
13
+ has_many :profiles
14
14
  belongs_to :country
15
15
 
16
16
  extend FriendlyId
@@ -25,13 +25,14 @@ class Library < ActiveRecord::Base
25
25
  end
26
26
 
27
27
  validates_associated :library_group
28
- validates_presence_of :short_display_name, :library_group
29
- validates_uniqueness_of :short_display_name, :case_sensitive => false
28
+ validates :short_display_name, presence: true
29
+ validates :library_group, presence: true
30
+ validates_uniqueness_of :short_display_name, case_sensitive: false
30
31
  validates_uniqueness_of :isil, allow_blank: true
31
32
  validates :display_name, uniqueness: true
32
- validates :name, format: {with: /\A[a-z][0-9a-z\-_]{1,253}[0-9a-z]\Z/}
33
- validates :isil, format: {with: /\A[A-Za-z]{1,4}-[A-Za-z0-9\/:\-]{2,11}\z/}, allow_blank: true
34
- after_validation :geocode, :if => :address_changed?
33
+ validates :name, format: { with: /\A[a-z][0-9a-z\-_]{1,253}[0-9a-z]\Z/ }
34
+ validates :isil, format: { with: /\A[A-Za-z]{1,4}-[A-Za-z0-9\/:\-]{2,11}\z/ }, allow_blank: true
35
+ after_validation :geocode, if: :address_changed?
35
36
  after_create :create_shelf
36
37
  after_save :clear_all_cache
37
38
  after_destroy :clear_all_cache
@@ -40,7 +41,7 @@ class Library < ActiveRecord::Base
40
41
 
41
42
  def self.all_cache
42
43
  if Rails.env == 'production'
43
- Rails.cache.fetch('library_all'){Library.all}
44
+ Rails.cache.fetch('library_all'){ Library.all }
44
45
  else
45
46
  Library.all
46
47
  end
@@ -52,13 +53,13 @@ class Library < ActiveRecord::Base
52
53
 
53
54
  def create_shelf
54
55
  shelf = Shelf.new
55
- shelf.name = "#{self.name}_default"
56
+ shelf.name = "#{name}_default"
56
57
  shelf.library = self
57
58
  shelf.save!
58
59
  end
59
60
 
60
61
  def web?
61
- return true if self.id == 1
62
+ return true if id == 1
62
63
  false
63
64
  end
64
65
 
@@ -69,24 +70,26 @@ class Library < ActiveRecord::Base
69
70
  def address(locale = I18n.locale)
70
71
  case locale.to_sym
71
72
  when :ja
72
- "#{self.region.to_s.localize(locale)}#{self.locality.to_s.localize(locale)}#{self.street.to_s.localize(locale)}"
73
+ "#{region.to_s.localize(locale)}#{locality.to_s.localize(locale)}#{street.to_s.localize(locale)}"
73
74
  else
74
- "#{self.street.to_s.localize(locale)} #{self.locality.to_s.localize(locale)} #{self.region.to_s.localize(locale)}"
75
+ "#{street.to_s.localize(locale)} #{locality.to_s.localize(locale)} #{region.to_s.localize(locale)}"
75
76
  end
76
77
  rescue
77
78
  nil
78
79
  end
79
80
 
80
81
  def address_changed?
81
- return true if region_changed? or locality_changed? or street_changed?
82
+ return true if region_changed? || locality_changed? || street_changed?
82
83
  false
83
84
  end
84
85
 
85
86
  if defined?(EnjuEvent)
86
- has_many :events, :include => :event_category
87
+ has_many :events
87
88
 
88
89
  def closed?(date)
89
- events.closing_days.collect{|c| c.start_at.beginning_of_day}.include?(date.beginning_of_day)
90
+ events.closing_days.map{ |c|
91
+ c.start_at.beginning_of_day
92
+ }.include?(date.beginning_of_day)
90
93
  end
91
94
  end
92
95
 
@@ -1,15 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  class LibraryGroup < ActiveRecord::Base
3
3
  attr_accessible :name, :display_name, :short_name, :my_networks,
4
- :login_banner, :note, :country_id, :admin_networks, :url
4
+ :login_banner, :note, :country_id, :admin_networks, :url,
5
+ :colors_attributes
6
+ if defined?(EnjuBookmark)
7
+ attr_accessible :allow_bookmark_external_url
8
+ end
5
9
 
6
10
  #include Singleton
7
11
  include MasterModel
8
12
 
9
13
  has_many :libraries
14
+ has_many :colors
10
15
  belongs_to :country
11
16
 
12
17
  validates :url, presence: true, url: true
18
+ accepts_nested_attributes_for :colors, update_only: true
13
19
 
14
20
  def self.site_config
15
21
  LibraryGroup.find(1)
@@ -29,13 +35,13 @@ class LibraryGroup < ActiveRecord::Base
29
35
  end
30
36
 
31
37
  def network_access_allowed?(ip_address, options = {})
32
- options = {:network_type => :lan}.merge(options)
38
+ options = { network_type: :lan }.merge(options)
33
39
  client_ip = IPAddr.new(ip_address)
34
40
  case options[:network_type]
35
41
  when :admin
36
- allowed_networks = self.admin_networks.to_s.split
42
+ allowed_networks = admin_networks.to_s.split
37
43
  else
38
- allowed_networks = self.my_networks.to_s.split
44
+ allowed_networks = my_networks.to_s.split
39
45
  end
40
46
  allowed_networks.each do |allowed_network|
41
47
  begin
@@ -1,8 +1,14 @@
1
1
  class RequestStatusType < ActiveRecord::Base
2
2
  attr_accessible :name, :display_name, :note
3
3
  include MasterModel
4
- default_scope order: 'position'
4
+ validates :name, presence: true, format: { with: /\A[0-9A-Za-z][0-9A-Za-z_\-\s,]*[0-9a-z]\Z/ }
5
+ default_scope { order('request_status_types.position') }
5
6
  has_many :reserves
7
+
8
+ private
9
+ def valid_name?
10
+ true
11
+ end
6
12
  end
7
13
 
8
14
  # == Schema Information
@@ -1,7 +1,13 @@
1
1
  class RequestType < ActiveRecord::Base
2
2
  attr_accessible :name, :display_name, :note
3
3
  include MasterModel
4
- default_scope order: 'position'
4
+ validates :name, presence: true, format: { with: /\A[0-9A-Za-z][0-9A-Za-z_\-\s,]*[0-9a-z]\Z/ }
5
+ default_scope { order('request_types.position') }
6
+
7
+ private
8
+ def valid_name?
9
+ true
10
+ end
5
11
  end
6
12
 
7
13
  # == Schema Information
@@ -1,14 +1,14 @@
1
1
  class SearchEngine < ActiveRecord::Base
2
2
  attr_accessible :name, :display_name, :url, :base_url, :http_method,
3
3
  :query_param, :additional_param, :note
4
- default_scope order: "search_engines.position"
4
+ default_scope { order('search_engines.position') }
5
5
  acts_as_list
6
6
 
7
7
  validates :name, presence: true
8
8
  validates :query_param, presence: true
9
- validates :http_method, presence: true, :inclusion => %w(get post)
10
- validates :url, presence: true, url: true, length: {:maximum => 255}
11
- validates :base_url, presence: true, url: true, length: {:maximum => 255}
9
+ validates :http_method, presence: true, inclusion: %w(get post)
10
+ validates :url, presence: true, url: true, length: { maximum: 255 }
11
+ validates :base_url, presence: true, url: true, length: { maximum: 255 }
12
12
  after_save :clear_all_cache
13
13
  after_destroy :clear_all_cache
14
14
 
@@ -20,9 +20,9 @@ class SearchEngine < ActiveRecord::Base
20
20
 
21
21
  def search_params(query)
22
22
  params = {}
23
- if self.additional_param
24
- self.additional_param.gsub('{query}', query).to_s.split.each do |param|
25
- p = param.split("=")
23
+ if additional_param
24
+ additional_param.gsub('{query}', query).to_s.split.each do |param|
25
+ p = param.split('=')
26
26
  params[p[0].to_sym] = p[1]
27
27
  end
28
28
  return params
@@ -1,15 +1,15 @@
1
1
  class Shelf < ActiveRecord::Base
2
2
  attr_accessible :name, :display_name, :note, :library_id, :closed
3
3
  include MasterModel
4
- scope :real, where('library_id != 1')
4
+ scope :real, -> { where('library_id != 1') }
5
5
  belongs_to :library, validate: true
6
- has_many :items, :include => [:circulation_status]
6
+ has_many :items
7
7
  has_many :picture_files, as: :picture_attachable, dependent: :destroy
8
8
 
9
9
  validates_associated :library
10
- validates_presence_of :library
10
+ validates :library, presence: true
11
11
  validates_uniqueness_of :display_name, scope: :library_id
12
- validates :name, format: {with: /\A[a-z][0-9a-z\-_]{1,253}[0-9a-z]\Z/}
12
+ validates :name, format: { with: /\A[a-z][0-9a-z\-_]{1,253}[0-9a-z]\Z/ }
13
13
 
14
14
  acts_as_list scope: :library
15
15
 
@@ -27,7 +27,7 @@ class Shelf < ActiveRecord::Base
27
27
  paginates_per 10
28
28
 
29
29
  def web_shelf?
30
- return true if self.id == 1
30
+ return true if id == 1
31
31
  false
32
32
  end
33
33