enju_leaf 1.1.0.rc17 → 1.1.0.rc18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/app/controllers/user_export_files_controller.rb +4 -3
  4. data/app/controllers/user_groups_controller.rb +5 -1
  5. data/app/controllers/user_import_files_controller.rb +2 -2
  6. data/app/models/profile.rb +10 -5
  7. data/app/models/role.rb +2 -2
  8. data/app/models/user_export_file.rb +16 -11
  9. data/app/models/user_export_file_transition.rb +4 -4
  10. data/app/models/user_group.rb +3 -3
  11. data/app/models/user_has_role.rb +2 -2
  12. data/app/models/user_import_file.rb +19 -10
  13. data/app/models/user_import_file_transition.rb +4 -4
  14. data/app/models/user_import_result.rb +3 -2
  15. data/app/views/layouts/application.html.erb +1 -1
  16. data/app/views/my_accounts/_edit_credential.html.erb +1 -1
  17. data/app/views/page/_menu.html.erb +2 -2
  18. data/app/views/page/advanced_search.html.erb +12 -0
  19. data/app/views/user_export_files/show.html.erb +5 -0
  20. data/app/workers/user_export_file_queue.rb +1 -1
  21. data/app/workers/user_import_file_queue.rb +1 -1
  22. data/config/initializers/redis.rb +3 -0
  23. data/config/locales/simple_form.ja.yml +1 -1
  24. data/db/migrate/20150506105356_add_error_message_to_user_import_result.rb +5 -0
  25. data/lib/enju_leaf.rb +5 -6
  26. data/lib/enju_leaf/calculate_stat.rb +2 -2
  27. data/lib/enju_leaf/engine.rb +1 -2
  28. data/lib/enju_leaf/export_file.rb +2 -2
  29. data/lib/enju_leaf/helper.rb +8 -9
  30. data/lib/enju_leaf/import_file.rb +8 -8
  31. data/lib/enju_leaf/user.rb +15 -15
  32. data/lib/enju_leaf/version.rb +1 -1
  33. data/lib/generators/enju_leaf/quick_install/quick_install_generator.rb +7 -14
  34. data/lib/generators/enju_leaf/setup/setup_generator.rb +23 -16
  35. data/spec/controllers/my_accounts_controller_spec.rb +7 -6
  36. data/spec/controllers/profiles_controller_spec.rb +12 -12
  37. data/spec/controllers/roles_controller_spec.rb +12 -12
  38. data/spec/controllers/user_export_files_controller_spec.rb +20 -20
  39. data/spec/controllers/user_groups_controller_spec.rb +47 -47
  40. data/spec/controllers/user_import_files_controller_spec.rb +20 -20
  41. data/spec/controllers/user_import_results_controller_spec.rb +12 -12
  42. data/spec/dummy/app/controllers/application_controller.rb +1 -1
  43. data/spec/dummy/config/initializers/devise.rb +1 -1
  44. data/spec/dummy/db/migrate/20150221063719_add_settings_to_library_group.rb +5 -0
  45. data/spec/dummy/db/schema.rb +3 -1
  46. data/spec/factories/user.rb +4 -4
  47. data/spec/fixtures/library_groups.yml +27 -22
  48. data/spec/fixtures/profiles.yml +10 -5
  49. data/spec/fixtures/roles.yml +2 -2
  50. data/spec/fixtures/user_export_files.yml +8 -9
  51. data/spec/fixtures/user_groups.yml +3 -3
  52. data/spec/fixtures/user_has_roles.yml +2 -2
  53. data/spec/fixtures/user_import_files.yml +10 -8
  54. data/spec/fixtures/user_import_results.yml +3 -2
  55. data/spec/models/profile_spec.rb +25 -0
  56. data/spec/models/role_spec.rb +2 -2
  57. data/spec/models/user_export_file_spec.rb +8 -9
  58. data/spec/models/user_group_spec.rb +3 -3
  59. data/spec/models/user_has_role_spec.rb +2 -2
  60. data/spec/models/user_import_file_spec.rb +19 -16
  61. data/spec/models/user_import_result_spec.rb +3 -2
  62. data/spec/routing/accounts_spec.rb +2 -2
  63. data/spec/routing/profiles_routing_spec.rb +7 -7
  64. data/spec/routing/resource_import_files_routing_spec.rb +4 -4
  65. data/spec/views/profiles/new.html.erb_spec.rb +2 -2
  66. metadata +33 -33
  67. data/app/models/setting.rb +0 -4
  68. data/lib/generators/enju_leaf/setup/templates/config/application.yml +0 -48
  69. data/spec/dummy/app/models/setting.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8d14bdad46e9c610c2389ca04b54bc526cd3877
4
- data.tar.gz: b6cd6d4d8be8126685adcd08586fb5830d621a77
3
+ metadata.gz: b485d724e7c536952e92b1ba09b5a00f14eb6bcd
4
+ data.tar.gz: 24d48f269fe8f063b37f92160029564002f7b9f0
5
5
  SHA512:
6
- metadata.gz: 4a40ca67ed8ac850e90aac0ba18e48b1b9985e47e4f65e453b8b794bd45a5b723e436e0da2d194863845a7bd66c0d48eedbd8e35f1321aedbb04c02faa20c46f
7
- data.tar.gz: 729bdbf4a9d147afa295ebac0abc997f7a129ebd7088c3681de30b9465481d65af9a126bdb3228d51216109651caae1c95e60455d7e8c5ab52f93593fca4e029
6
+ metadata.gz: d3c3596996704276665024e8f0a268a29a8d708fdc773bfe79128059b2b2d3b774d912c30ace4cbe23d3be8c5ccba73620e2e2d47acef8b78ed49a0d2f846b11
7
+ data.tar.gz: ec8ff2d3b703245113f7a8d0da04446bd52404a618948571001101775b54d42e8b2d11f4885fcf15e7ffd745cf8616bc4daecfcb15b00fa922f5dd742d43c249
data/Rakefile CHANGED
@@ -29,7 +29,7 @@ require 'rspec/core'
29
29
  require 'rspec/core/rake_task'
30
30
 
31
31
  RSpec::Core::RakeTask.new(:spec) do |spec|
32
- spec.pattern = FileList['spec/**/*_spec.rb']
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
33
  end
34
34
 
35
35
  task :default => :spec
@@ -16,7 +16,7 @@ class UserExportFilesController < ApplicationController
16
16
  # GET /user_export_files/1.json
17
17
  def show
18
18
  if @user_export_file.user_export.path
19
- unless Setting.uploaded_file.storage == :s3
19
+ unless ENV['ENJU_STORAGE'] == 's3'
20
20
  file = @user_export_file.user_export.path
21
21
  end
22
22
  end
@@ -25,8 +25,9 @@ class UserExportFilesController < ApplicationController
25
25
  format.html # show.html.erb
26
26
  format.json { render json: @user_export_file }
27
27
  format.download {
28
- if Setting.uploaded_file.storage == :s3
29
- redirect_to @user_export_file.user_export.expiring_url(10)
28
+ if ENV['ENJU_STORAGE'] == 's3'
29
+ send_data Faraday.get(@user_export_file.user_export.expiring_url).body.force_encoding('UTF-8'),
30
+ filename: File.basename(@user_export_file.user_export_file_name), type: 'application/octet-stream'
30
31
  else
31
32
  send_file file, filename: @user_export_file.user_export_file_name, type: 'application/octet-stream'
32
33
  end
@@ -93,7 +93,11 @@ class UserGroupsController < ApplicationController
93
93
  :number_of_day_to_notify_overdue,
94
94
  :number_of_day_to_notify_due_date,
95
95
  :number_of_time_to_notify_overdue,
96
- :user_group_has_checkout_types_attributes # EnjuCirculation
96
+ # EnjuCirculation
97
+ {:user_group_has_checkout_types_attributes => [
98
+ :id, :checkout_type_id, :checkout_limit, :checkout_period, :checkout_renewal_limit,
99
+ :reservation_limit, :reservation_expired_period, :set_due_date_before_closing_day,
100
+ ]},
97
101
  )
98
102
  end
99
103
 
@@ -17,7 +17,7 @@ class UserImportFilesController < ApplicationController
17
17
  # GET /user_import_files/1.json
18
18
  def show
19
19
  if @user_import_file.user_import.path
20
- unless Setting.uploaded_file.storage == :s3
20
+ unless ENV['ENJU_STORAGE'] == 's3'
21
21
  file = @user_import_file.user_import.path
22
22
  end
23
23
  end
@@ -26,7 +26,7 @@ class UserImportFilesController < ApplicationController
26
26
  format.html # show.html.erb
27
27
  format.json { render json: @user_import_file }
28
28
  format.download {
29
- if Setting.uploaded_file.storage == :s3
29
+ if ENV['ENJU_STORAGE'] == 's3'
30
30
  redirect_to @user_import_file.user_import.expiring_url(10)
31
31
  else
32
32
  send_file file, filename: @user_import_file.user_import_file_name, type: 'application/octet-stream'
@@ -71,14 +71,19 @@ end
71
71
  # user_id :integer
72
72
  # user_group_id :integer
73
73
  # library_id :integer
74
- # locale :string(255)
75
- # user_number :string(255)
74
+ # locale :string
75
+ # user_number :string
76
76
  # full_name :text
77
77
  # note :text
78
78
  # keyword_list :text
79
79
  # required_role_id :integer
80
- # created_at :datetime not null
81
- # updated_at :datetime not null
82
- # checkout_icalendar_token :string(255)
80
+ # created_at :datetime
81
+ # updated_at :datetime
82
+ # checkout_icalendar_token :string
83
83
  # save_checkout_history :boolean default(FALSE), not null
84
+ # expired_at :datetime
85
+ # save_search_history :boolean
86
+ # share_bookmarks :boolean
87
+ # full_name_transcription :text
88
+ # date_of_birth :datetime
84
89
  #
data/app/models/role.rb CHANGED
@@ -41,8 +41,8 @@ end
41
41
  # Table name: roles
42
42
  #
43
43
  # id :integer not null, primary key
44
- # name :string(255) not null
45
- # display_name :string(255)
44
+ # name :string not null
45
+ # display_name :string
46
46
  # note :text
47
47
  # created_at :datetime
48
48
  # updated_at :datetime
@@ -2,9 +2,15 @@ class UserExportFile < ActiveRecord::Base
2
2
  include Statesman::Adapters::ActiveRecordQueries
3
3
  include ExportFile
4
4
  enju_export_file_model
5
- if Setting.uploaded_file.storage == :s3
5
+
6
+ if ENV['ENJU_STORAGE'] == 's3'
6
7
  has_attached_file :user_export, storage: :s3,
7
- s3_credentials: Setting.amazon,
8
+ s3_credentials: {
9
+ access_key: ENV['AWS_ACCESS_KEY_ID'],
10
+ secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
11
+ bucket: ENV['S3_BUCKET_NAME'],
12
+ s3_host_name: ENV['S3_HOST_NAME']
13
+ },
8
14
  s3_permissions: :private
9
15
  else
10
16
  has_attached_file :user_export,
@@ -51,13 +57,12 @@ end
51
57
  #
52
58
  # Table name: user_export_files
53
59
  #
54
- # id :integer not null, primary key
55
- # user_id :integer
56
- # user_export_file_name :string(255)
57
- # user_export_content_type :string(255)
58
- # user_export_file_size :integer
59
- # user_export_updated_at :datetime
60
- # executed_at :datetime
61
- # created_at :datetime not null
62
- # updated_at :datetime not null
60
+ # id :integer not null, primary key
61
+ # user_id :integer
62
+ # executed_at :datetime
63
+ # created_at :datetime
64
+ # updated_at :datetime
65
+ # user_export_id :string
66
+ # user_export_size :integer
67
+ # user_import_filename :string
63
68
  #
@@ -11,10 +11,10 @@ end
11
11
  # Table name: user_export_file_transitions
12
12
  #
13
13
  # id :integer not null, primary key
14
- # to_state :string(255)
15
- # metadata :text default("{}")
14
+ # to_state :string
15
+ # metadata :text default({})
16
16
  # sort_key :integer
17
17
  # user_export_file_id :integer
18
- # created_at :datetime not null
19
- # updated_at :datetime not null
18
+ # created_at :datetime
19
+ # updated_at :datetime
20
20
  #
@@ -18,12 +18,12 @@ end
18
18
  # Table name: user_groups
19
19
  #
20
20
  # id :integer not null, primary key
21
- # name :string(255)
21
+ # name :string
22
22
  # display_name :text
23
23
  # note :text
24
24
  # position :integer
25
- # created_at :datetime not null
26
- # updated_at :datetime not null
25
+ # created_at :datetime
26
+ # updated_at :datetime
27
27
  # deleted_at :datetime
28
28
  # valid_period_for_new_user :integer default(0), not null
29
29
  # expired_at :datetime
@@ -14,6 +14,6 @@ end
14
14
  # id :integer not null, primary key
15
15
  # user_id :integer
16
16
  # role_id :integer
17
- # created_at :datetime not null
18
- # updated_at :datetime not null
17
+ # created_at :datetime
18
+ # updated_at :datetime
19
19
  #
@@ -5,9 +5,14 @@ class UserImportFile < ActiveRecord::Base
5
5
  scope :not_imported, -> { in_state(:pending) }
6
6
  scope :stucked, -> { in_state(:pending).where('user_import_files.created_at < ?', 1.hour.ago) }
7
7
 
8
- if Setting.uploaded_file.storage == :s3
8
+ if ENV['ENJU_STORAGE'] == 's3'
9
9
  has_attached_file :user_import, storage: :s3,
10
- s3_credentials: Setting.amazon,
10
+ s3_credentials: {
11
+ access_key: ENV['AWS_ACCESS_KEY_ID'],
12
+ secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
13
+ bucket: ENV['S3_BUCKET_NAME'],
14
+ s3_host_name: ENV['S3_HOST_NAME']
15
+ },
11
16
  s3_permissions: :private
12
17
  else
13
18
  has_attached_file :user_import,
@@ -92,6 +97,8 @@ class UserImportFile < ActiveRecord::Base
92
97
  num[:failed] += 1
93
98
  end
94
99
  else
100
+ import_result.error_message = new_user.errors.full_messages.join("\n")
101
+ import_result.save
95
102
  num[:failed] += 1
96
103
  end
97
104
  end
@@ -307,16 +314,18 @@ end
307
314
  # user_id :integer
308
315
  # note :text
309
316
  # executed_at :datetime
310
- # user_import_file_name :string(255)
311
- # user_import_content_type :string(255)
312
- # user_import_file_size :string(255)
317
+ # user_import_file_name :string
318
+ # user_import_content_type :string
319
+ # user_import_file_size :integer
313
320
  # user_import_updated_at :datetime
314
- # user_import_fingerprint :string(255)
315
- # edit_mode :string(255)
321
+ # user_import_fingerprint :string
322
+ # edit_mode :string
316
323
  # error_message :text
317
- # created_at :datetime not null
318
- # updated_at :datetime not null
319
- # user_encoding :string(255)
324
+ # created_at :datetime
325
+ # updated_at :datetime
326
+ # user_encoding :string
320
327
  # default_library_id :integer
321
328
  # default_user_group_id :integer
329
+ # user_import_id :string
330
+ # user_import_size :integer
322
331
  #
@@ -11,10 +11,10 @@ end
11
11
  # Table name: user_import_file_transitions
12
12
  #
13
13
  # id :integer not null, primary key
14
- # to_state :string(255)
15
- # metadata :text default("{}")
14
+ # to_state :string
15
+ # metadata :text default({})
16
16
  # sort_key :integer
17
17
  # user_import_file_id :integer
18
- # created_at :datetime not null
19
- # updated_at :datetime not null
18
+ # created_at :datetime
19
+ # updated_at :datetime
20
20
  #
@@ -15,6 +15,7 @@ end
15
15
  # user_import_file_id :integer
16
16
  # user_id :integer
17
17
  # body :text
18
- # created_at :datetime not null
19
- # updated_at :datetime not null
18
+ # created_at :datetime
19
+ # updated_at :datetime
20
+ # error_message :text
20
21
  #
@@ -12,7 +12,7 @@
12
12
  <%= auto_discovery_link_tag(:atom, news_posts_url(format: :atom, locale: @locale), title: (t('news_post.library_group_news_post', library_group_name: @library_group.display_name.localize) + " (Atom)")) %>
13
13
  <% end %>
14
14
  <% end %>
15
- <%= book_jacket_header(Setting.book_jacket.source) %>
15
+ <%= book_jacket_header(@library_group.settings[:book_jacket_source]) %>
16
16
  <% if controller.controller_name == 'page' %>
17
17
  <%= render 'page/portlets' %>
18
18
  <% end %>
@@ -44,7 +44,7 @@
44
44
 
45
45
  <div class="field">
46
46
  <%= user_form.label :locked -%>
47
- <%= user_form.check_box :locked -%>
47
+ <%= user_form.check_box :locked, disabled: 'disabled' -%>
48
48
  </div>
49
49
 
50
50
  <div class="field">
@@ -125,8 +125,8 @@
125
125
  <% if defined?(EnjuSearchLog) %>
126
126
  <li><%= link_to t('activerecord.models.search_history'), search_histories_path %></li>
127
127
  <% end %>
128
- <% if Setting.enju.erms_url %>
129
- <li><%= link_to t('page.electronic_resource_management'), Setting.enju.erms_url -%></li>
128
+ <% if @library_group.settings[:erms_url] %>
129
+ <li><%= link_to t('page.electronic_resource_management'), @library_group.settings[:erms_url] -%></li>
130
130
  <% end %>
131
131
  <li><%= link_to t('page.configuration'), page_configuration_path -%></li>
132
132
  <% else %>
@@ -4,6 +4,14 @@
4
4
 
5
5
  <%= form_tag({controller: 'manifestations'}, {method: 'get'}) do -%>
6
6
  <table style="width: 100%">
7
+ <tr>
8
+ <td><%= label_tag :library_adv, t('activerecord.models.library') %>:</td>
9
+ <td>
10
+ <% @libraries.sort_by{|l| l.position }.each do |library| %>
11
+ <label><%= check_box_tag "library_adv[]", library.name %><%= library.display_name.localize %></label>
12
+ <% end %>
13
+ </td>
14
+ </tr>
7
15
  <tr>
8
16
  <td><%= label_tag :query, t('page.search_term') -%>:</td>
9
17
  <td><%= search_field_tag 'query', nil, class: 'search_form_short', placeholder: t('page.search_term') -%></td>
@@ -34,6 +42,10 @@
34
42
  <td><label><%= t('activerecord.attributes.manifestation.issn') -%>:</label></td>
35
43
  <td><%= text_field_tag 'issn' -%></td>
36
44
  </tr>
45
+ <tr>
46
+ <td><label><%= t('activerecord.attributes.item.call_number') %>:</label></td>
47
+ <td><%= text_field_tag 'call_number' %></td>
48
+ </tr>
37
49
  <tr>
38
50
  <td><label><%= t('activerecord.attributes.item.item_identifier') -%>:</label></td>
39
51
  <td><%= text_field_tag 'item_identifier' -%></td>
@@ -18,6 +18,11 @@
18
18
  <%= localized_state(@user_export_file.current_state) -%>
19
19
  </p>
20
20
 
21
+ <p>
22
+ <strong><%= t('page.created_at') -%>:</strong>
23
+ <%= l(@user_export_file.created_at) if @user_export_file.created_at -%>
24
+ </p>
25
+
21
26
  </div>
22
27
  </div>
23
28
 
@@ -1,5 +1,5 @@
1
1
  class UserExportFileQueue
2
- @queue = :user_export_file
2
+ @queue = :enju_leaf
3
3
 
4
4
  def self.perform(user_export_id)
5
5
  UserExportFile.find(user_export_id).export!
@@ -1,5 +1,5 @@
1
1
  class UserImportFileQueue
2
- @queue = :user_import_file
2
+ @queue = :enju_leaf
3
3
 
4
4
  def self.perform(user_import_file_id)
5
5
  UserImportFile.find(user_import_file_id).import_start
@@ -0,0 +1,3 @@
1
+ if ENV["REDIS_URL"]
2
+ $redis = Redis.new(url: ENV["REDIS_URL"])
3
+ end
@@ -3,7 +3,7 @@ ja:
3
3
  "yes": 'はい'
4
4
  "no": 'いいえ'
5
5
  required:
6
- text: '必須'
6
+ text: 'required'
7
7
  mark: '*'
8
8
  message: '印のついている項目は入力が必須です。'
9
9
  # You can uncomment the line below if you need to overwrite the whole required html.
@@ -0,0 +1,5 @@
1
+ class AddErrorMessageToUserImportResult < ActiveRecord::Migration
2
+ def change
3
+ add_column :user_import_results, :error_message, :text
4
+ end
5
+ end
data/lib/enju_leaf.rb CHANGED
@@ -4,7 +4,6 @@ require "enju_leaf/controller"
4
4
  require "enju_leaf/user"
5
5
  require "enju_leaf/helper"
6
6
  require "enju_leaf/calculate_stat"
7
- require "enju_leaf/calculate_stat"
8
7
  require "enju_leaf/import_file"
9
8
  require "enju_leaf/export_file"
10
9
  require "enju_leaf/localized_name"
@@ -72,8 +71,8 @@ module EnjuLeaf
72
71
  return if performed?
73
72
  #flash[:notice] = t('page.connection_failed')
74
73
  respond_to do |format|
75
- format.html {render file: "#{Rails.root.to_s}/public/500", layout: false, status: 500}
76
- format.mobile {render file: "#{Rails.root.to_s}/public/500", layout: false, status: 500}
74
+ format.html {render file: "#{Rails.root}/public/500", layout: false, status: 500}
75
+ format.mobile {render file: "#{Rails.root}/public/500", layout: false, status: 500}
77
76
  format.xml {render template: 'page/500', status: 500}
78
77
  format.json { render text: '{"error": "server_error"}' }
79
78
  format.xml {render template: 'page/500.xml', status: 500}
@@ -138,7 +137,7 @@ module EnjuLeaf
138
137
  def convert_charset
139
138
  case params[:format]
140
139
  when 'csv'
141
- return unless Setting.csv_charset_conversion
140
+ return unless LibraryGroup.site_config.settings[:csv_charset_conversion]
142
141
  # TODO: 他の言語
143
142
  if @locale.to_sym == :ja
144
143
  headers["Content-Type"] = "text/csv; charset=Shift_JIS"
@@ -214,8 +213,8 @@ module EnjuLeaf
214
213
 
215
214
  def get_top_page_content
216
215
  if defined?(EnjuNews)
217
- @news_feeds = Rails.cache.fetch('news_feed_all'){NewsFeed.all}
218
- @news_posts = NewsPost.limit(Setting.news_post.number.top_page)
216
+ @news_feeds = Rails.cache.fetch('news_feed_all'){NewsFeed.order(:position)}
217
+ @news_posts = NewsPost.limit(LibraryGroup.site_config.settings[:news_post_number_top_page] || 10)
219
218
  end
220
219
  @libraries = Library.real
221
220
  end
@@ -28,10 +28,10 @@ module CalculateStat
28
28
  end
29
29
 
30
30
  def send_message
31
- sender = User.find(1) # system
31
+ sender = User.find(1) #system
32
32
  message_template = MessageTemplate.localized_template('counting_completed', user.profile.locale)
33
33
  request = MessageRequest.new
34
- request.assign_attributes({:sender => sender, :receiver => user, :message_template => message_template})
34
+ request.assign_attributes({sender: sender, receiver: user, message_template: message_template})
35
35
  request.save_message_body
36
36
  request.transition_to!(:sent)
37
37
  end
@@ -7,12 +7,11 @@ require 'friendly_id'
7
7
  require 'addressable/uri'
8
8
  require 'sunspot_rails'
9
9
  require 'resque/server'
10
- require 'settingslogic'
11
10
  require 'nested_form'
12
11
  require 'enju_biblio'
13
12
  require 'enju_library'
14
13
  require 'enju_manifestation_viewer'
15
- require 'redcarpet'
14
+ require 'kramdown'
16
15
  require 'mobylette'
17
16
  require 'rails_autolink'
18
17
  require 'devise-encryptable'