enju_leaf 1.1.0.rc20 → 1.1.0.rc21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/unknown_resource.png +0 -0
  3. data/app/controllers/my_accounts_controller.rb +0 -11
  4. data/app/controllers/page_controller.rb +12 -0
  5. data/app/controllers/profiles_controller.rb +23 -5
  6. data/app/controllers/user_import_files_controller.rb +1 -0
  7. data/app/helpers/page_helper.rb +14 -0
  8. data/app/models/profile.rb +7 -1
  9. data/app/models/user_export_file.rb +1 -0
  10. data/app/models/user_import_file.rb +20 -10
  11. data/app/views/page/_menu.html.erb +40 -51
  12. data/app/views/page/advanced_search.html.erb +14 -3
  13. data/app/views/page/configuration.html.erb +3 -0
  14. data/app/views/page/statistics.html.erb +0 -14
  15. data/app/views/page/system_information.html.erb +13 -1
  16. data/app/views/profiles/_edit_profile.html.erb +2 -2
  17. data/app/views/user_import_files/_results.html.erb +22 -0
  18. data/app/views/user_import_files/show.html.erb +8 -12
  19. data/app/views/user_import_results/_list.html.erb +22 -0
  20. data/app/views/user_import_results/_list_lines.html.erb +24 -0
  21. data/app/views/user_import_results/index.html.erb +5 -30
  22. data/app/views/user_import_results/show.html.erb +1 -1
  23. data/config/locales/devise.ja.yml +3 -3
  24. data/config/locales/translation_en.yml +5 -1
  25. data/config/locales/translation_ja.yml +5 -1
  26. data/lib/enju_leaf/calculate_stat.rb +3 -0
  27. data/lib/enju_leaf/engine.rb +0 -1
  28. data/lib/enju_leaf/helper.rb +22 -7
  29. data/lib/enju_leaf/import_file.rb +4 -0
  30. data/lib/enju_leaf/master_model.rb +1 -0
  31. data/lib/enju_leaf/user.rb +52 -20
  32. data/lib/enju_leaf/version.rb +1 -1
  33. data/lib/generators/enju_leaf/setup/setup_generator.rb +1 -1
  34. data/spec/controllers/my_accounts_controller_spec.rb +2 -2
  35. data/spec/controllers/profiles_controller_spec.rb +19 -5
  36. data/spec/controllers/user_import_files_controller_spec.rb +8 -1
  37. data/spec/controllers/user_import_results_controller_spec.rb +21 -1
  38. data/spec/dummy/app/assets/javascripts/application.js +4 -6
  39. data/spec/dummy/config/initializers/kaminari_config.rb +10 -0
  40. data/spec/fixtures/user_import_files.yml +2 -0
  41. data/spec/models/user_import_file_spec.rb +32 -24
  42. data/spec/models/user_spec.rb +29 -1
  43. data/spec/rails_helper.rb +82 -0
  44. data/spec/spec_helper.rb +86 -51
  45. data/spec/views/page/configuration.html.erb_spec.rb +1 -1
  46. data/spec/views/user_import_results/index.html.erb_spec.rb +32 -0
  47. metadata +20 -11
@@ -0,0 +1,22 @@
1
+ <h2><%= t('activerecord.models.user_import_result') %></h2>
2
+ <table class="table table-striped index">
3
+ <tr>
4
+ <th><%= t('activerecord.attributes.user_import_result.lineno') %></th>
5
+ <th><%= t('activerecord.attributes.user_import_result.body') %></th>
6
+ <th><%= t('activerecord.models.user') %></th>
7
+ <th></th>
8
+ </tr>
9
+ <% @user_import_results.each_with_index do |user_import_result, idx| %>
10
+ <tr class="line<%= cycle("0", "1") -%>">
11
+ <td><%= @user_import_results.offset_value + idx + 1 %></td>
12
+ <td><%= user_import_result.body.inspect %></td>
13
+ <td><%= link_to user_import_result.user.username, user_import_result.user.profile if user_import_result.user.try(:profile) %></td>
14
+ <td>
15
+ <%= link_to t('page.show'), user_import_result %>
16
+ <%= link_to t('page.destroy'), user_import_result, data: {confirm: t('page.are_you_sure')}, method: :delete %>
17
+ </td>
18
+ </tr>
19
+ <% end %>
20
+ </table>
21
+ <%= paginate(@user_import_results) %>
22
+
@@ -8,25 +8,18 @@
8
8
  <%= @user_import_file.id -%>
9
9
  </p>
10
10
 
11
+ <% if @user_import_file.user_import_file_name %>
11
12
  <p>
12
13
  <strong><%= t('activerecord.attributes.user_import_file.user_import_file_name') -%>:</strong>
13
- <%= link_to @user_import_file.user_import_file_name, user_import_file_path(@user_import_file, format: :download) if @user_import_file.user_import_file_name %>
14
- </p>
15
-
16
- <p>
17
- <strong><%= t('activerecord.attributes.user_import_file.user_import_content_type') -%>:</strong>
18
- <%= @user_import_file.user_import_content_type -%>
14
+ <%= link_to @user_import_file.user_import_file_name, user_import_file_path(@user_import_file, format: :download) %>
15
+ (<%= @user_import_file.user_import_content_type -%>)
19
16
  </p>
20
17
 
21
18
  <p>
22
19
  <strong><%= t('activerecord.attributes.user_import_file.user_import_file_size') -%>:</strong>
23
20
  <%= @user_import_file.user_import_file_size -%>
24
21
  </p>
25
-
26
- <p>
27
- <strong><%= t('activerecord.attributes.user_import_file.user_import_fingerprint') -%>:</strong>
28
- <%= @user_import_file.user_import_fingerprint -%>
29
- </p>
22
+ <% end %>
30
23
 
31
24
  <p>
32
25
  <strong><%= t('page.created_at') -%>:</strong>
@@ -73,13 +66,16 @@
73
66
  <%= link_to @user_import_file.user.username, @user_import_file.user.profile if @user_import_file.user.try(:profile) -%>
74
67
  </p>
75
68
 
69
+ <% if @user_import_results %>
70
+ <%= render 'results' %>
71
+ <% end %>
72
+
76
73
  </div>
77
74
  </div>
78
75
 
79
76
  <div id="submenu" class="ui-corner-all ui-widget-content">
80
77
  <%= form_for(@user_import_file) do |f| %>
81
78
  <ul>
82
- <li><%= link_to t('activerecord.models.user_import_result'), user_import_file_user_import_results_path(@user_import_file) -%></li>
83
79
  <li><%= back_to_index(flash[:page_info]) -%></li>
84
80
  <% if current_user.has_role?('Administrator') %>
85
81
  <li><%= link_to 'Resque', resque_path %></li>
@@ -0,0 +1,22 @@
1
+ <table class="table table-striped index">
2
+ <tr>
3
+ <th><%= t('activerecord.models.user_import_file') %></th>
4
+ <th><%= t('activerecord.models.user') %></th>
5
+ <th></th>
6
+ </tr>
7
+
8
+ <% @user_import_results.each do |user_import_result| %>
9
+ <tr class="line<%= cycle("0", "1") -%>">
10
+ <td>
11
+ <%= link_to user_import_result.user_import_file.user_import_file_name, user_import_result.user_import_file %>
12
+ <br />
13
+ <%=l user_import_result.created_at %>
14
+ </td>
15
+ <td><%= link_to user_import_result.user.username, user_import_result.user.profile if user_import_result.user.try(:profile) %></td>
16
+ <td>
17
+ <%= link_to t('page.show'), user_import_result %>
18
+ <%= link_to t('page.destroy'), user_import_result, data: {confirm: t('page.are_you_sure')}, method: :delete %>
19
+ </td>
20
+ </tr>
21
+ <% end %>
22
+ </table>
@@ -0,0 +1,24 @@
1
+ <ul>
2
+ <li><%= t('activerecord.models.user_import_file') %>: <%= link_to @user_import_file.user_import_file_name, @user_import_file %>
3
+ <li><%= t('page.created_at') %>: <%= l(@user_import_file.created_at) %>
4
+ </h2>
5
+ <table class="table table-striped index">
6
+ <tr>
7
+ <th><%= t('activerecord.attributes.user_import_result.lineno') %></th>
8
+ <th><%= t('activerecord.attributes.user_import_result.body') %></th>
9
+ <th><%= t('activerecord.models.user') %></th>
10
+ <th></th>
11
+ </tr>
12
+
13
+ <% @user_import_results.each_with_index do |user_import_result, idx| %>
14
+ <tr class="line<%= cycle("0", "1") -%>">
15
+ <td><%= @user_import_results.offset_value + idx + 1 %></td>
16
+ <td><%= user_import_result.body.inspect %></td>
17
+ <td><%= link_to user_import_result.user.username, user_import_result.user.profile if user_import_result.user.try(:profile) %></td>
18
+ <td>
19
+ <%= link_to t('page.show'), user_import_result %>
20
+ <%= link_to t('page.destroy'), user_import_result, data: {confirm: t('page.are_you_sure')}, method: :delete %>
21
+ </td>
22
+ </tr>
23
+ <% end %>
24
+ </table>
@@ -2,36 +2,11 @@
2
2
  <h1 class="title"><%= t('page.listing', model: t('activerecord.models.user_import_result')) -%></h1>
3
3
  <div id="content_list">
4
4
  <% if @user_import_file %>
5
- <h2 class="resource_title">
6
- <%= link_to @user_import_file.user_import_file_name, @user_import_file %>
7
- </h2>
5
+ <%= render 'list_lines' %>
6
+ <% else %>
7
+ <%= render 'list' %>
8
8
  <% end %>
9
-
10
- <table class="table table-striped index">
11
- <tr>
12
- <th><%= t('activerecord.models.user_import_file') %></th>
13
- <th><%= t('activerecord.models.user') %></th>
14
- <th></th>
15
- </tr>
16
-
17
- <% @user_import_results.each do |user_import_result| %>
18
- <tr class="line<%= cycle("0", "1") -%>">
19
- <td>
20
- <%= link_to user_import_result.user_import_file.user_import_file_name, user_import_result.user_import_file %>
21
- <br />
22
- <%=l user_import_result.created_at %>
23
- </td>
24
- <td><%= link_to user_import_result.user.username, user_import_result.user.profile if user_import_result.user.try(:profile) %></td>
25
- <td>
26
- <%= link_to t('page.show'), user_import_result %>
27
- <%= link_to t('page.destroy'), user_import_result, data: {confirm: t('page.are_you_sure')}, method: :delete %>
28
- </td>
29
- </tr>
30
- <% end %>
31
- </table>
32
-
33
- <%= paginate(@user_import_results) %>
34
-
9
+ <%= paginate(@user_import_results) %>
35
10
  </div>
36
11
  </div>
37
12
 
@@ -40,7 +15,7 @@
40
15
  <li>
41
16
  <% if @user_import_file %>
42
17
  <%= link_to((image_tag 'icons/page_white_excel.png', size: '16x16', alt: 'TSV', class: 'icon'), user_import_file_user_import_results_path(@user_import_file, format: :txt, locale: @locale.to_s)) -%>
43
- (<%= link_to 'TSV', user_import_file_user_import_results_path(format: :txt, locale: @locale.to_s) -%>)
18
+ (<%= link_to 'TSV', user_import_file_user_import_results_path(@user_import_file, format: :txt, locale: @locale.to_s) -%>)
44
19
  <% else %>
45
20
  <%= link_to((image_tag 'icons/page_white_excel.png', size: '16x16', alt: 'TSV', class: 'icon'), user_import_results_path(format: :txt, locale: @locale.to_s)) -%>
46
21
  (<%= link_to 'TSV', user_import_results_path(format: :txt, locale: @locale.to_s) -%>)
@@ -15,7 +15,7 @@
15
15
 
16
16
  <p>
17
17
  <b><%= t('activerecord.attributes.user_import_result.body') %></b>
18
- <%= @user_import_result.body %>
18
+ <%= @user_import_result.body.inspect %>
19
19
  </p>
20
20
 
21
21
  <p>
@@ -51,8 +51,8 @@ ja:
51
51
  already_confirmed: "was already confirmed, please try signing in"
52
52
  confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
53
53
  expired: "有効期限が切れています。新しく登録してください。"
54
- not_found: "not found"
54
+ not_found: "は登録されていません。"
55
55
  not_locked: "was not locked"
56
56
  not_saved:
57
- one: "%{resource} を保存するときに1個のエラーが発生しました:"
58
- other: "%{resource} を保存するときに%{count}個のエラーが発生しました:"
57
+ one: "%{resource} の情報に1個のエラーがあります:"
58
+ other: "%{resource} の情報に%{count}個のエラーがあります:"
@@ -75,7 +75,8 @@ en:
75
75
  default_user_group_id: Default user group
76
76
  default_library_id: Default library
77
77
  user_import_result:
78
- body: Body
78
+ body: Contents
79
+ lineno: Line
79
80
  user_export_file:
80
81
  user_export_file_name: Filename
81
82
  user_export_file_size: Size
@@ -150,6 +151,7 @@ en:
150
151
  start_import: "Start import"
151
152
  import_record: "Import records"
152
153
  export: "Export"
154
+ other_format: "Other formats"
153
155
  detail: "Detail"
154
156
  acquisition: "Acquisition"
155
157
  configuration: "Configuration"
@@ -288,6 +290,7 @@ en:
288
290
  cannot_parse_yaml_header: "has an invalid YAML header. You must add a space after the header's colon."
289
291
  notice: Notice
290
292
  system_information: System information
293
+ default_locale: Default locale
291
294
  nosolr_error: 'There is an error on connecting to the search server.'
292
295
  nosolr_error_description: 'This error may be caused by a delay when the sever is still waiting for launching the search server. In that case, please wait for a while, and go back to this page later.'
293
296
  title:
@@ -304,6 +307,7 @@ en:
304
307
  to: "to"
305
308
  from_to: "-"
306
309
  all_libraries: "All libraries"
310
+ check_all: "Check/Uncheck All"
307
311
  work:
308
312
  agents_work: "%{agent_name}'s works"
309
313
  library_group_work: "Works in %{library_group_name}"
@@ -75,7 +75,8 @@ ja:
75
75
  default_user_group_id: 既定の利用者グループ
76
76
  default_library_id: 既定の図書館
77
77
  user_import_result:
78
- body: 本文
78
+ body: 内容
79
+ lineno: 行数
79
80
  user_export_file:
80
81
  user_export_file_name: ファイル名
81
82
  user_export_file_size: ファイルサイズ
@@ -141,6 +142,7 @@ ja:
141
142
  start_import: "インポートを開始"
142
143
  import_record: "書誌レコードのインポート"
143
144
  export: "エクスポート"
145
+ other_format: "書き出し"
144
146
  detail: "詳細"
145
147
  acquisition: "資料の受入"
146
148
  configuration: "システムの設定"
@@ -273,6 +275,7 @@ ja:
273
275
  cannot_parse_yaml_header: "のYAMLヘッダを読み込めません。ヘッダのコロンの後には、半角スペースを含める必要があります。"
274
276
  notice: 注意
275
277
  system_information: システムの基本的な情報の表示
278
+ default_locale: "既定の言語"
276
279
  nosolr_error: '検索サーバに不具合があるようです'
277
280
  nosolr_error_description: '検索サーバーの起動に時間がかかっている場合もこのエラーとなります。少し時間を置いてアクセスするとエラーが解消される場合もありますのでお試しください。'
278
281
  title:
@@ -288,6 +291,7 @@ ja:
288
291
  from: ""
289
292
  to: "から"
290
293
  all_libraries: "全ての図書館"
294
+ check_all: "全て選択/解除"
291
295
  work:
292
296
  agent_work: "%{agent_name} の書いた資料"
293
297
  library_group_work: "%{library_group_name} にある書いた資料"
@@ -10,6 +10,7 @@ module CalculateStat
10
10
  end
11
11
 
12
12
  module ClassMethods
13
+ # 利用統計の集計を開始します。
13
14
  def calculate_stat
14
15
  self.not_calculated.each do |stat|
15
16
  stat.transition_to!(:started)
@@ -18,6 +19,7 @@ module CalculateStat
18
19
  end
19
20
 
20
21
  module InstanceMethods
22
+ # 利用統計の日付をチェックします。
21
23
  def check_date
22
24
  if self.start_date and self.end_date
23
25
  if self.start_date >= self.end_date
@@ -27,6 +29,7 @@ module CalculateStat
27
29
  end
28
30
  end
29
31
 
32
+ # 利用統計の集計完了メッセージを送信します。
30
33
  def send_message
31
34
  sender = User.find(1) #system
32
35
  message_template = MessageTemplate.localized_template('counting_completed', user.profile.locale)
@@ -17,7 +17,6 @@ require 'rails_autolink'
17
17
  require 'devise-encryptable'
18
18
  require 'sitemap_generator'
19
19
  require 'redis-rails'
20
- require 'jquery-rails'
21
20
  require 'jquery-ui-rails'
22
21
  require 'statesman'
23
22
  require 'resque/scheduler/server'
@@ -1,5 +1,6 @@
1
1
  module EnjuLeaf
2
2
  module EnjuLeafHelper
3
+ # 使用中のデータベースのアダプタ名を表示します。
3
4
  def database_adapter
4
5
  case ActiveRecord::Base.connection.adapter_name
5
6
  when 'PostgreSQL'
@@ -10,7 +11,8 @@ module EnjuLeaf
10
11
  link_to 'SQLite', 'http://www.sqlite.org/'
11
12
  end
12
13
  end
13
-
14
+
15
+ # HTMLのtitleに表示されるアクション名を設定します。
14
16
  def title_action_name
15
17
  case controller.action_name
16
18
  when 'index'
@@ -39,7 +41,9 @@ module EnjuLeaf
39
41
  def move_position(object)
40
42
  render partial: 'page/position', locals: {object: object}
41
43
  end
42
-
44
+
45
+ # I18nに対応した状態名を表示します。
46
+ # @param [String] state 状態名
43
47
  def localized_state(state)
44
48
  case state
45
49
  when 'pending'
@@ -57,6 +61,8 @@ module EnjuLeaf
57
61
  end
58
62
  end
59
63
 
64
+ # I18nに対応した状態名を表示します。
65
+ # @param [Boolean] bool 状態名
60
66
  def localized_boolean(bool)
61
67
  case bool.to_s
62
68
  when nil
@@ -66,11 +72,13 @@ module EnjuLeaf
66
72
  t('page.boolean.false')
67
73
  end
68
74
  end
69
-
75
+
76
+ # ログイン中のユーザの権限名を表示します。
70
77
  def current_user_role_name
71
78
  current_user.try(:role).try(:name) || 'Guest'
72
79
  end
73
80
 
81
+ # HTMLのtitleを表示します。
74
82
  def title(controller_name)
75
83
  string = ''
76
84
  unless ['page', 'routing_error', 'my_accounts'].include?(controller_name)
@@ -82,7 +90,9 @@ module EnjuLeaf
82
90
  string << LibraryGroup.system_name + ' - Next-L Enju Leaf'
83
91
  string.html_safe
84
92
  end
85
-
93
+
94
+ # 前の画面に戻るリンクを表示します。
95
+ # @param [Hash] options
86
96
  def back_to_index(options = {})
87
97
  if options == nil
88
98
  options = {}
@@ -91,14 +101,17 @@ module EnjuLeaf
91
101
  options.delete(:page) if options[:page].to_i == 1
92
102
  end
93
103
  unless controller_name == 'test'
94
- link_to t('page.listing', model: t("activerecord.models.#{controller_name.singularize}")), url_for(params.merge(controller: controller_name, action: :index, id: nil, only_path: true).merge(options))
104
+ link_to t('page.listing', model: t("activerecord.models.#{controller_name.singularize}")), url_for(params.merge(controller: controller_name, action: :index, page: nil, id: nil, only_path: true).merge(options))
95
105
  end
96
106
  end
97
-
107
+
108
+ # 検索フォームにフォーカスを移動するJavaScriptを表示します。
98
109
  def set_focus_on_search_form
99
110
  javascript_tag("$(function(){$('#search_form').focus()})") if @query.blank?
100
111
  end
101
-
112
+
113
+ # Markdownの文字列をパースして表示します。
114
+ # @param [String] string Markdownの文字列
102
115
  def markdown_helper(string)
103
116
  return unless string
104
117
  if defined?(Redcarpet)
@@ -112,6 +125,8 @@ module EnjuLeaf
112
125
  end
113
126
  end
114
127
 
128
+ # ユーザの未読メッセージ数を表示します。
129
+ # @param [User] user ユーザ
115
130
  def messages_count(user)
116
131
  Message.search do
117
132
  with(:receiver_id).equal_to user.id
@@ -8,6 +8,7 @@ module ImportFile
8
8
  include InstanceMethods
9
9
  end
10
10
 
11
+ # 失敗したインポート処理を一括削除します。
11
12
  def expire
12
13
  self.stucked.find_each do |file|
13
14
  file.destroy
@@ -29,6 +30,8 @@ module ImportFile
29
30
  end
30
31
  end
31
32
 
33
+ # インポートするファイルの文字コードをUTF-8に変換します。
34
+ # @param [String] line 変換する文字列
32
35
  def convert_encoding(line)
33
36
  if defined?(CharlockHolmes::EncodingDetector)
34
37
  begin
@@ -49,6 +52,7 @@ module ImportFile
49
52
  end
50
53
  end
51
54
 
55
+ # インポート完了時のメッセージを送信します。
52
56
  def send_message
53
57
  sender = User.find(1)
54
58
  message_template = MessageTemplate.localized_template('import_completed', user.profile.locale)
@@ -19,6 +19,7 @@ module MasterModel
19
19
  end
20
20
 
21
21
  module InstanceMethods
22
+ # 表示名を設定します。
22
23
  def set_display_name
23
24
  self.display_name = "#{I18n.locale}: #{name}" if display_name.blank?
24
25
  end
@@ -69,61 +69,70 @@ module EnjuLeaf
69
69
 
70
70
  paginates_per 10
71
71
 
72
+ # 有効期限切れのユーザを一括で使用不可にします。
72
73
  def lock_expired_users
73
74
  User.find_each do |user|
74
75
  user.lock_access! if user.expired? and user.active_for_authentication?
75
76
  end
76
77
  end
77
78
 
79
+ # ユーザの情報をエクスポートします。
80
+ # @param [Hash] options
78
81
  def export(options = {format: :txt})
79
82
  header = %w(
80
83
  username
84
+ full_name
85
+ full_name_transcription
81
86
  email
82
87
  user_number
83
88
  role
84
89
  user_group
85
90
  library
86
91
  locale
92
+ locked
93
+ required_role
87
94
  created_at
88
95
  updated_at
89
96
  expired_at
90
97
  keyword_list
91
98
  note
99
+ )
100
+ header += %w(
92
101
  checkout_icalendar_token
93
102
  save_checkout_history
94
- save_search_history
95
- share_bookmarks
96
- ).join("\t")
103
+ ) if defined? EnjuCirculation
104
+ header << "save_search_history" if defined? EnjuSearchLog
105
+ header << "share_bookmarks" if defined? EnjuBookmark
106
+ header = header.join("\t")
97
107
  users = User.all.map{|u|
98
108
  lines = []
99
109
  lines << u.username
110
+ lines << u.try(:profile).try(:full_name)
111
+ lines << u.try(:profile).try(:full_name_transcription)
100
112
  lines << u.email
101
113
  lines << u.try(:profile).try(:user_number)
102
114
  lines << u.role.name
103
115
  lines << u.try(:profile).try(:user_group).try(:name)
104
116
  lines << u.try(:profile).try(:library).try(:name)
105
117
  lines << u.try(:profile).try(:locale)
118
+ lines << u.access_locked?
119
+ lines << u.try(:profile).try(:required_role).try(:name)
106
120
  lines << u.created_at
107
121
  lines << u.updated_at
108
- lines << u.expired_at
122
+ lines << u.try(:profile).try(:expired_at)
109
123
  lines << u.try(:profile).try(:keyword_list).try(:split).try(:join, "//")
110
124
  lines << u.try(:profile).try(:note)
111
- if defined?(EnjuCirculation)
125
+ if defined? EnjuCirculation
112
126
  lines << u.try(:profile).try(:checkout_icalendar_token)
113
127
  lines << u.try(:profile).try(:save_checkout_history)
114
- else
115
- lines << nil
116
- end
117
- if defined?(EnjuSearchLog)
118
- lines << u.try(:save_search_history)
119
- else
120
- lines << nil
121
- end
122
- if defined?(EnjuBookmark)
123
- lines << u.try(:share_bookmarks)
124
- else
125
- lines << nil
126
- end
128
+ end
129
+ if defined? EnjuSearchLog
130
+ lines << u.try(:profile).try(:save_search_history)
131
+ end
132
+ if defined? EnjuBookmark
133
+ lines << u.try(:profile).try(:share_bookmarks)
134
+ end
135
+ lines
127
136
  }
128
137
  if options[:format] == :txt
129
138
  users.map{|u| u.join("\t")}.unshift(header).join("\r\n")
@@ -135,12 +144,17 @@ module EnjuLeaf
135
144
  end
136
145
 
137
146
  module InstanceMethods
147
+ # ユーザにパスワードが必要かどうかをチェックします。
148
+ # @return [Boolean]
138
149
  def password_required?
139
150
  if Devise.mappings[:user].modules.include?(:database_authenticatable)
140
151
  !persisted? || !password.nil? || !password_confirmation.nil?
141
152
  end
142
153
  end
143
154
 
155
+ # ユーザが特定の権限を持っているかどうかをチェックします。
156
+ # @param [String] role_in_question 権限名
157
+ # @return [Boolean]
144
158
  def has_role?(role_in_question)
145
159
  return false unless role
146
160
  return true if role.name == role_in_question
@@ -154,6 +168,7 @@ module EnjuLeaf
154
168
  end
155
169
  end
156
170
 
171
+ # ユーザに使用不可の設定を反映させます。
157
172
  def set_lock_information
158
173
  if locked == '1' and self.active_for_authentication?
159
174
  lock_access!
@@ -169,6 +184,8 @@ module EnjuLeaf
169
184
  end
170
185
  end
171
186
 
187
+ # ユーザが有効期限切れかどうかをチェックし、期限切れであれば使用不可に設定します。
188
+ # @return [Object]
172
189
  def check_expiration
173
190
  return if has_role?('Administrator')
174
191
  if expired_at
@@ -178,6 +195,8 @@ module EnjuLeaf
178
195
  end
179
196
  end
180
197
 
198
+ # ユーザの削除前に、管理者ユーザが不在にならないかどうかをチェックします。
199
+ # @return [Object]
181
200
  def check_role_before_destroy
182
201
  if has_role?('Administrator')
183
202
  if Role.where(name: 'Administrator').first.users.count == 1
@@ -186,26 +205,36 @@ module EnjuLeaf
186
205
  end
187
206
  end
188
207
 
208
+ # ユーザに自動生成されたパスワードを設定します。
209
+ # @return [String]
189
210
  def set_auto_generated_password
190
211
  password = Devise.friendly_token[0..7]
191
212
  self.password = password
192
213
  self.password_confirmation = password
193
214
  end
194
215
 
216
+ # ユーザが有効期限切れかどうかをチェックします。
217
+ # @return [Boolean]
195
218
  def expired?
196
219
  if expired_at
197
220
  true if expired_at.beginning_of_day < Time.zone.now.beginning_of_day
198
221
  end
199
222
  end
200
223
 
224
+ # ユーザが管理者かどうかをチェックします。
225
+ # @return [Boolean]
201
226
  def is_admin?
202
- true if has_role?('Administrator')
227
+ return true if has_role?('Administrator')
228
+ false
203
229
  end
204
230
 
231
+ # ユーザがシステム上の最後のLibrarian権限ユーザかどうかをチェックします。
232
+ # @return [Boolean]
205
233
  def last_librarian?
206
234
  if has_role?('Librarian')
207
235
  role = Role.where(name: 'Librarian').first
208
- true if role.users.size == 1
236
+ return true if role.users.count == 1
237
+ false
209
238
  end
210
239
  end
211
240
 
@@ -213,6 +242,9 @@ module EnjuLeaf
213
242
  Devise::Mailer.confirmation_instructions(self).deliver if email.present?
214
243
  end
215
244
 
245
+ # ユーザが削除可能かどうかをチェックします。
246
+ # @param [User] current_user ユーザ
247
+ # @return [Object]
216
248
  def deletable_by?(current_user)
217
249
  return nil unless current_user
218
250
  if defined?(EnjuCirculation)
@@ -1,3 +1,3 @@
1
1
  module EnjuLeaf
2
- VERSION = "1.1.0.rc20"
2
+ VERSION = "1.1.0.rc21"
3
3
  end
@@ -114,7 +114,7 @@ EOS
114
114
  "config.serve_static_assets = true"
115
115
  gsub_file 'config/environments/production.rb',
116
116
  /# config.cache_store = :mem_cache_store$/,
117
- "config.cache_store = :dalli_store, {:compress => true}"
117
+ "config.cache_store = :redis_store, ENV['REDIS_URL'], { expires_in: 1.day }"
118
118
  gsub_file 'config/environments/production.rb',
119
119
  /# config.assets.precompile \+= %w\( search.js \)$/,
120
120
  "config.assets.precompile += %w( mobile.js mobile.css print.css )"
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require 'spec_helper'
2
+ require 'rails_helper'
3
3
 
4
4
  describe MyAccountsController do
5
5
  fixtures :all
@@ -29,7 +29,7 @@ describe MyAccountsController do
29
29
  describe "When logged in as Administrator" do
30
30
  before(:each) do
31
31
  profile = FactoryGirl.create(:profile)
32
- @user = User.find('enjuadmin')
32
+ @user = FactoryGirl.create(:admin)
33
33
  @user.profile = profile
34
34
  sign_in @user
35
35
  end