enju_leaf 1.1.0.rc16 → 1.1.0.rc17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +1 -1
  3. data/app/assets/javascripts/mobile.js +1 -1
  4. data/app/assets/stylesheets/enju.css +1 -1
  5. data/app/assets/stylesheets/mobile.css +1 -1
  6. data/app/controllers/my_accounts_controller.rb +28 -8
  7. data/app/controllers/profiles_controller.rb +48 -11
  8. data/app/controllers/roles_controller.rb +6 -1
  9. data/app/controllers/user_export_files_controller.rb +7 -2
  10. data/app/controllers/user_groups_controller.rb +13 -2
  11. data/app/controllers/user_import_files_controller.rb +9 -2
  12. data/app/controllers/user_import_results_controller.rb +7 -0
  13. data/app/models/profile.rb +3 -11
  14. data/app/models/role.rb +0 -1
  15. data/app/models/user_export_file.rb +13 -3
  16. data/app/models/user_export_file_transition.rb +1 -1
  17. data/app/models/user_group.rb +0 -6
  18. data/app/models/user_has_role.rb +0 -2
  19. data/app/models/user_import_file.rb +31 -8
  20. data/app/models/user_import_file_transition.rb +1 -1
  21. data/app/models/user_import_result.rb +0 -1
  22. data/app/views/my_accounts/show.html.erb +4 -26
  23. data/app/views/page/export.html.erb +5 -5
  24. data/app/views/profiles/index.html.erb +3 -1
  25. data/app/views/profiles/show.html.erb +10 -27
  26. data/app/views/user_export_files/index.html.erb +2 -2
  27. data/app/views/user_export_files/show.html.erb +1 -1
  28. data/app/views/user_import_files/index.html.erb +1 -1
  29. data/app/views/user_import_files/show.html.erb +1 -1
  30. data/lib/enju_leaf/calculate_stat.rb +2 -2
  31. data/lib/enju_leaf/engine.rb +11 -0
  32. data/lib/enju_leaf/export_file.rb +1 -2
  33. data/lib/enju_leaf/import_file.rb +1 -1
  34. data/lib/enju_leaf/user.rb +20 -20
  35. data/lib/enju_leaf/version.rb +1 -1
  36. data/lib/generators/enju_leaf/setup/setup_generator.rb +9 -10
  37. data/lib/generators/enju_leaf/setup/templates/Procfile +1 -1
  38. data/lib/generators/enju_leaf/setup/templates/config/application.yml +1 -0
  39. data/lib/tasks/enju_leaf_tasks.rake +5 -0
  40. data/spec/controllers/my_accounts_controller_spec.rb +11 -0
  41. data/spec/controllers/profiles_controller_spec.rb +2 -2
  42. data/spec/dummy/app/helpers/application_helper.rb +1 -0
  43. data/spec/dummy/bin/bundle +3 -0
  44. data/spec/dummy/bin/rails +4 -0
  45. data/spec/dummy/bin/rake +4 -0
  46. data/spec/dummy/bin/setup +29 -0
  47. data/spec/dummy/db/schema.rb +108 -108
  48. data/spec/fixtures/events.yml +13 -39
  49. data/spec/models/user_import_file_spec.rb +17 -6
  50. data/vendor/assets/javascripts/jquery.colorbox.js +6 -6
  51. data/vendor/assets/javascripts/jquery.cookie.js +47 -26
  52. data/vendor/assets/javascripts/{jquery.mobile-1.4.4.js → jquery.mobile-1.4.5.js} +278 -228
  53. data/vendor/assets/stylesheets/{jquery.mobile-1.4.4.css → jquery.mobile-1.4.5.css} +7 -2
  54. metadata +198 -48
  55. data/spec/dummy/script/rails +0 -6
  56. data/spec/fixtures/series_has_manifestations.yml +0 -35
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39450aed8ab4e4e97cf12f78408cbda1141aa118
4
- data.tar.gz: f5b50dc4938bb00e16a9e998e0d58c387984f34b
3
+ metadata.gz: a8d14bdad46e9c610c2389ca04b54bc526cd3877
4
+ data.tar.gz: b6cd6d4d8be8126685adcd08586fb5830d621a77
5
5
  SHA512:
6
- metadata.gz: db43ab43a91a071fe6fc284e07878be2197ea5f629016c78eafc84d91d6b7b2bdf2197cfe0b6b0bb14f39ce2c07f4aac3f87d615cec7f48048c6f7b07cb7f9f8
7
- data.tar.gz: d217264a96f8976dcb0c746b22d33f3e1d8054b82137a7a51afdb01662d6de8d67d1d02d593f4ff4c3571e37b7c3c05cd0b06beab0749da2c0a3215d9963c870
6
+ metadata.gz: 4a40ca67ed8ac850e90aac0ba18e48b1b9985e47e4f65e453b8b794bd45a5b723e436e0da2d194863845a7bd66c0d48eedbd8e35f1321aedbb04c02faa20c46f
7
+ data.tar.gz: 729bdbf4a9d147afa295ebac0abc997f7a129ebd7088c3681de30b9465481d65af9a126bdb3228d51216109651caae1c95e60455d7e8c5ab52f93593fca4e029
data/README.rdoc CHANGED
@@ -1,5 +1,5 @@
1
1
  = Next-L Enju Leaf
2
- {<img src="https://travis-ci.org/next-l/enju_leaf.png?branch=1.1" alt="Build Status" />}[https://travis-ci.org/next-l/enju_leaf]
2
+ {<img src="https://travis-ci.org/next-l/enju_leaf.svg?branch=1.1" alt="Build Status" />}[https://travis-ci.org/next-l/enju_leaf]
3
3
  {<img src="https://coveralls.io/repos/next-l/enju_leaf/badge.png?branch=1.1" alt="Coverage Status" />}[https://coveralls.io/r/next-l/enju_leaf?branch=1.1]
4
4
  {<img src="https://hakiri.io/github/next-l/enju_leaf/1.1.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_leaf/1.1]
5
5
 
@@ -1,4 +1,4 @@
1
1
  //= require jquery
2
2
  //= require jquery_ujs
3
- //= require jquery.mobile-1.4.4
3
+ //= require jquery.mobile-1.4.5
4
4
  //= require jquery.colorbox
@@ -475,7 +475,7 @@ div#flash_notice{
475
475
  }
476
476
 
477
477
  td#edit_icons, th#edit_icons{
478
- width: 50px;
478
+ width: 100px;
479
479
  line-height: 200%;
480
480
  }
481
481
 
@@ -3,6 +3,6 @@
3
3
  * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
4
  * the top of the compiled file, but it's generally better to create a new file per style scope.
5
5
  *= require_self
6
- *= require jquery.mobile-1.4.4
6
+ *= require jquery.mobile-1.4.5
7
7
  *= require enju_mobile
8
8
  */
@@ -28,15 +28,18 @@ class MyAccountsController < ApplicationController
28
28
 
29
29
  def update
30
30
  @profile = current_user.profile
31
+ user_attrs = [
32
+ :id, :email, :current_password, :password, :password_confirmation
33
+ ]
34
+ user_attrs += [
35
+ {:user_has_role_attributes => [:id, :role_id]}
36
+ ] if current_user.has_role?('Administrator')
37
+
38
+ user_params = ActionController::Parameters.new(params[:profile][:user_attributes]).permit(*user_attrs)
31
39
 
32
40
  respond_to do |format|
33
- if current_user.has_role?('Librarian')
34
- saved = current_user.update_with_password(params[:profile][:user_attributes], as: :admin)
35
- @profile.assign_attributes(params[:profile], as: :admin)
36
- else
37
- saved = current_user.update_with_password(params[:profile][:user_attributes])
38
- @profile.assign_attributes(params[:profile])
39
- end
41
+ saved = current_user.update_with_password(user_params)
42
+ @profile.assign_attributes(profile_params)
40
43
 
41
44
  if saved
42
45
  if @profile.save
@@ -49,7 +52,9 @@ class MyAccountsController < ApplicationController
49
52
  format.json { render json: current_user.errors, status: :unprocessable_entity }
50
53
  end
51
54
  else
52
- @profile.errors[:base] << I18n.t('activerecord.attributes.user.current_password')
55
+ current_user.errors.full_messages.each do |msg|
56
+ @profile.errors[:base] << msg
57
+ end
53
58
  prepare_options
54
59
  format.html { render action: "edit" }
55
60
  format.json { render json: current_user.errors, status: :unprocessable_entity }
@@ -68,6 +73,21 @@ class MyAccountsController < ApplicationController
68
73
  end
69
74
 
70
75
  private
76
+ def profile_params
77
+ attrs = [
78
+ :full_name, :full_name_transcription, :user_number,
79
+ :library_id, :keyword_list, :note,
80
+ :locale, :required_role_id, :expired_at,
81
+ :locked, :birth_date,
82
+ :save_checkout_history, :checkout_icalendar_token, # EnjuCirculation
83
+ :save_search_history # EnjuSearchLog
84
+ ]
85
+ if current_user.has_role?('Librarian')
86
+ attrs << :user_group_id
87
+ end
88
+ params.require(:profile).permit(*attrs)
89
+ end
90
+
71
91
  def prepare_options
72
92
  @user_groups = UserGroup.order(:position)
73
93
  @roles = Role.order(:position)
@@ -76,26 +76,29 @@ class ProfilesController < ApplicationController
76
76
  redirect_to edit_my_account_url
77
77
  return
78
78
  end
79
+ if @profile.user.try(:locked_at?)
80
+ @profile.user.locked = true
81
+ end
79
82
  end
80
83
 
81
84
  # POST /profiles
82
85
  # POST /profiles.json
83
86
  def create
84
87
  if current_user.has_role?('Librarian')
85
- @profile = Profile.new(params[:profile], as: :admin)
88
+ @profile = Profile.new(profile_params)
86
89
  if @profile.user
87
90
  @profile.user.operator = current_user
88
- @profile.user.set_auto_generated_password
91
+ password = @profile.user.set_auto_generated_password
89
92
  end
90
93
  else
91
- @profile = Profile.new(params[:profile])
94
+ @profile = Profile.new(profile_params)
92
95
  end
93
96
 
94
97
  respond_to do |format|
95
98
  if @profile.save
96
99
  if @profile.user
97
100
  @profile.user.role = Role.where(name: 'User').first
98
- flash[:temporary_password] = @profile.user.password
101
+ flash[:temporary_password] = password
99
102
  end
100
103
  format.html { redirect_to @profile, notice: t('controller.successfully_created', model: t('activerecord.models.profile')) }
101
104
  format.json { render json: @profile, status: :created, location: @profile }
@@ -110,20 +113,16 @@ class ProfilesController < ApplicationController
110
113
  # PUT /profiles/1
111
114
  # PUT /profiles/1.json
112
115
  def update
113
- if current_user.has_role?('Librarian')
114
- @profile.update_attributes(params[:profile], as: :admin)
115
- else
116
- @profile.update_attributes(params[:profile])
117
- end
116
+ @profile.update_attributes(profile_update_params)
118
117
  if @profile.user
119
118
  if @profile.user.auto_generated_password == "1"
120
- @profile.user.set_auto_generated_password
121
- flash[:temporary_password] = @profile.user.password
119
+ password = @profile.user.set_auto_generated_password
122
120
  end
123
121
  end
124
122
 
125
123
  respond_to do |format|
126
124
  if @profile.save
125
+ flash[:temporary_password] = password
127
126
  format.html { redirect_to @profile, notice: t('controller.successfully_updated', model: t('activerecord.models.profile')) }
128
127
  format.json { head :no_content }
129
128
  else
@@ -146,6 +145,44 @@ class ProfilesController < ApplicationController
146
145
  end
147
146
 
148
147
  private
148
+ def profile_params
149
+ attrs = [
150
+ :full_name, :full_name_transcription,
151
+ :keyword_list, :locale,
152
+ :save_checkout_history, :checkout_icalendar_token, # EnjuCirculation
153
+ :save_search_history, # EnjuSearchLog
154
+ ]
155
+ attrs += [
156
+ :library_id, :expired_at, :birth_date,
157
+ :user_group_id, :required_role_id, :note, :locked, :user_number, {
158
+ :user_attributes => [
159
+ :id, :username, :email, :current_password,
160
+ {:user_has_role_attributes => [:id, :role_id]}
161
+ ]
162
+ }
163
+ ] if current_user.has_role?('Librarian')
164
+ params.require(:profile).permit(*attrs)
165
+ end
166
+
167
+ def profile_update_params
168
+ attrs = [
169
+ :full_name, :full_name_transcription,
170
+ :keyword_list, :locale,
171
+ :save_checkout_history, # EnjuCirculation
172
+ :save_search_history, # EnjuSearchLog
173
+ ]
174
+ attrs += [
175
+ :library_id, :expired_at, :birth_date,
176
+ :user_group_id, :required_role_id, :note, :locked, :user_number, {
177
+ :user_attributes => [
178
+ :id, :email, :current_password, :auto_generated_password,
179
+ {:user_has_role_attributes => [:id, :role_id]}
180
+ ]
181
+ }
182
+ ] if current_user.has_role?('Librarian')
183
+ params.require(:profile).permit(*attrs)
184
+ end
185
+
149
186
  def prepare_options
150
187
  @user_groups = UserGroup.all
151
188
  @roles = Role.all
@@ -32,7 +32,7 @@ class RolesController < ApplicationController
32
32
  end
33
33
 
34
34
  respond_to do |format|
35
- if @role.update_attributes(params[:role])
35
+ if @role.update_attributes(role_params)
36
36
  format.html { redirect_to @role, notice: t('controller.successfully_updated', model: t('activerecord.models.role')) }
37
37
  format.json { head :no_content }
38
38
  else
@@ -41,4 +41,9 @@ class RolesController < ApplicationController
41
41
  end
42
42
  end
43
43
  end
44
+
45
+ private
46
+ def role_params
47
+ params.require(:role).permit(:name, :display_name, :note)
48
+ end
44
49
  end
@@ -53,7 +53,7 @@ class UserExportFilesController < ApplicationController
53
53
  # POST /user_export_files
54
54
  # POST /user_export_files.json
55
55
  def create
56
- @user_export_file = UserExportFile.new(params[:user_export_file])
56
+ @user_export_file = UserExportFile.new(user_export_file_params)
57
57
  @user_export_file.user = current_user
58
58
 
59
59
  respond_to do |format|
@@ -74,7 +74,7 @@ class UserExportFilesController < ApplicationController
74
74
  # PUT /user_export_files/1.json
75
75
  def update
76
76
  respond_to do |format|
77
- if @user_export_file.update_attributes(params[:user_export_file])
77
+ if @user_export_file.update_attributes(user_export_file_params)
78
78
  if @user_export_file.mode == 'export'
79
79
  UserExportFileQueue.perform(@user_export_file.id)
80
80
  end
@@ -97,4 +97,9 @@ class UserExportFilesController < ApplicationController
97
97
  format.json { head :no_content }
98
98
  end
99
99
  end
100
+
101
+ private
102
+ def user_export_file_params
103
+ params.require(:user_export_file).permit(:mode)
104
+ end
100
105
  end
@@ -40,7 +40,7 @@ class UserGroupsController < ApplicationController
40
40
  # POST /user_groups
41
41
  # POST /user_groups.json
42
42
  def create
43
- @user_group = UserGroup.new(params[:user_group])
43
+ @user_group = UserGroup.new(user_group_params)
44
44
 
45
45
  respond_to do |format|
46
46
  if @user_group.save
@@ -63,7 +63,7 @@ class UserGroupsController < ApplicationController
63
63
  end
64
64
 
65
65
  respond_to do |format|
66
- if @user_group.update_attributes(params[:user_group])
66
+ if @user_group.update_attributes(user_group_params)
67
67
  format.html { redirect_to @user_group, notice: t('controller.successfully_updated', model: t('activerecord.models.user_group')) }
68
68
  format.json { head :no_content }
69
69
  else
@@ -86,6 +86,17 @@ class UserGroupsController < ApplicationController
86
86
  end
87
87
 
88
88
  private
89
+ def user_group_params
90
+ params.require(:user_group).permit(
91
+ :name, :display_name, :note, :valid_period_for_new_user,
92
+ :expired_at, :number_of_day_to_notify_overdue,
93
+ :number_of_day_to_notify_overdue,
94
+ :number_of_day_to_notify_due_date,
95
+ :number_of_time_to_notify_overdue,
96
+ :user_group_has_checkout_types_attributes # EnjuCirculation
97
+ )
98
+ end
99
+
89
100
  def prepare_options
90
101
  if defined?(EnjuCirculation)
91
102
  @checkout_types = CheckoutType.select([:id, :display_name, :position])
@@ -55,7 +55,7 @@ class UserImportFilesController < ApplicationController
55
55
  # POST /user_import_files
56
56
  # POST /user_import_files.json
57
57
  def create
58
- @user_import_file = UserImportFile.new(params[:user_import_file])
58
+ @user_import_file = UserImportFile.new(user_import_file_params)
59
59
  @user_import_file.user = current_user
60
60
 
61
61
  respond_to do |format|
@@ -77,7 +77,7 @@ class UserImportFilesController < ApplicationController
77
77
  # PUT /user_import_files/1.json
78
78
  def update
79
79
  respond_to do |format|
80
- if @user_import_file.update_attributes(params[:user_import_file])
80
+ if @user_import_file.update_attributes(user_import_file_params)
81
81
  if @user_import_file.mode == 'import'
82
82
  Resque.enqueue(UserImportFileQueue, @user_import_file.id)
83
83
  end
@@ -103,6 +103,13 @@ class UserImportFilesController < ApplicationController
103
103
  end
104
104
 
105
105
  private
106
+ def user_import_file_params
107
+ params.require(:user_import_file).permit(
108
+ :user_import, :edit_mode, :user_encoding, :mode,
109
+ :default_user_group_id, :default_library_id
110
+ )
111
+ end
112
+
106
113
  def prepare_options
107
114
  @user_groups = UserGroup.all
108
115
  @libraries = Library.all
@@ -37,4 +37,11 @@ class UserImportResultsController < ApplicationController
37
37
  format.json { head :no_content }
38
38
  end
39
39
  end
40
+
41
+ private
42
+ def user_import_result_params
43
+ params.require(:user_import_result).permit(
44
+ :user_import_file_id, :user_id, :body
45
+ )
46
+ end
40
47
  end
@@ -1,18 +1,10 @@
1
1
  class Profile < ActiveRecord::Base
2
- attr_accessible :full_name, :full_name_transcription, :keyword_list, :locale
3
- attr_accessible :full_name, :full_name_transcription, :user_number,
4
- :library_id, :keyword_list, :note,
5
- :user_group_id, :user_id, :locale, :required_role_id, :expired_at,
6
- :user_attributes,
7
- :save_checkout_history, :birth_date,
8
- as: :admin
9
-
10
2
  enju_circulation_profile_model if defined?(EnjuCirculation)
11
3
  enju_search_log_profile_model if defined?(EnjuSearchLog)
12
4
 
13
5
  scope :administrators, -> { joins(user: :role).where('roles.name = ?', 'Administrator') }
14
6
  scope :librarians, -> { joins(user: :role).where('roles.name = ? OR roles.name = ?', 'Administrator', 'Librarian') }
15
- belongs_to :user
7
+ belongs_to :user, dependent: :destroy
16
8
  belongs_to :library, validate: true
17
9
  belongs_to :user_group
18
10
  belongs_to :required_role, class_name: 'Role', foreign_key: 'required_role_id' #, validate: true
@@ -23,7 +15,7 @@ class Profile < ActiveRecord::Base
23
15
  validates :user_number, uniqueness: true, format: { with: /\A[0-9A-Za-z_]+\Z/ }, allow_blank: true
24
16
  validates :birth_date, format: { with: /\A\d{4}-\d{1,2}-\d{1,2}\Z/ }, allow_blank: true
25
17
 
26
- attr_accessor :birth_date
18
+ attr_accessor :birth_date, :locked
27
19
 
28
20
  searchable do
29
21
  text :user_number, :full_name, :full_name_transcription, :note
@@ -52,7 +44,7 @@ class Profile < ActiveRecord::Base
52
44
  accepts_nested_attributes_for :user
53
45
 
54
46
  def set_role_and_agent
55
- self.required_role = Role.where(name: 'Librarian').first
47
+ self.required_role = Role.where(name: 'Librarian').first unless required_role
56
48
  self.locale = I18n.default_locale.to_s unless locale
57
49
  end
58
50
 
data/app/models/role.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  class Role < ActiveRecord::Base
2
- attr_accessible :name, :display_name, :note
3
2
  include MasterModel
4
3
  default_scope { order("roles.position") }
5
4
  validates :name, presence: true, format: { with: /\A[A-Za-z][a-z_,]*[a-z]\Z/ }
@@ -1,9 +1,15 @@
1
1
  class UserExportFile < ActiveRecord::Base
2
- attr_accessible
3
- include Statesman::Adapters::ActiveRecordModel
2
+ include Statesman::Adapters::ActiveRecordQueries
4
3
  include ExportFile
5
4
  enju_export_file_model
6
- has_attached_file :user_export
5
+ if Setting.uploaded_file.storage == :s3
6
+ has_attached_file :user_export, storage: :s3,
7
+ s3_credentials: Setting.amazon,
8
+ s3_permissions: :private
9
+ else
10
+ has_attached_file :user_export,
11
+ path: ":rails_root/private/system/:class/:attachment/:id_partition/:style/:filename"
12
+ end
7
13
  validates_attachment_content_type :user_export, content_type: /\Atext\/plain\Z/
8
14
 
9
15
  has_many :user_export_file_transitions
@@ -35,6 +41,10 @@ class UserExportFile < ActiveRecord::Base
35
41
  def self.transition_class
36
42
  UserExportFileTransition
37
43
  end
44
+
45
+ def self.initial_state
46
+ :pending
47
+ end
38
48
  end
39
49
 
40
50
  # == Schema Information
@@ -3,7 +3,7 @@ class UserExportFileTransition < ActiveRecord::Base
3
3
 
4
4
 
5
5
  belongs_to :user_export_file, inverse_of: :user_export_file_transitions
6
- attr_accessible :to_state, :sort_key, :metadata
6
+ #attr_accessible :to_state, :sort_key, :metadata
7
7
  end
8
8
 
9
9
  # == Schema Information
@@ -1,11 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  class UserGroup < ActiveRecord::Base
3
- attr_accessible :name, :display_name, :note, :valid_period_for_new_user,
4
- :expired_at, :number_of_day_to_notify_overdue,
5
- :number_of_day_to_notify_overdue,
6
- :number_of_day_to_notify_due_date,
7
- :number_of_time_to_notify_overdue
8
-
9
3
  include MasterModel
10
4
  default_scope { order("user_groups.position") }
11
5
  has_many :profiles
@@ -1,6 +1,4 @@
1
1
  class UserHasRole < ActiveRecord::Base
2
- attr_accessible :user_id, :role_id, :role
3
- attr_accessible :user_id, :role_id, :role, as: :admin
4
2
  belongs_to :user
5
3
  belongs_to :role
6
4
  accepts_nested_attributes_for :role
@@ -1,7 +1,5 @@
1
1
  class UserImportFile < ActiveRecord::Base
2
- attr_accessible :user_import, :edit_mode, :user_encoding, :mode,
3
- :default_user_group_id, :default_library_id
4
- include Statesman::Adapters::ActiveRecordModel
2
+ include Statesman::Adapters::ActiveRecordQueries
5
3
  include ImportFile
6
4
  default_scope {order('user_import_files.id DESC')}
7
5
  scope :not_imported, -> { in_state(:pending) }
@@ -9,7 +7,7 @@ class UserImportFile < ActiveRecord::Base
9
7
 
10
8
  if Setting.uploaded_file.storage == :s3
11
9
  has_attached_file :user_import, storage: :s3,
12
- s3_credentials: "#{Setting.amazon}",
10
+ s3_credentials: Setting.amazon,
13
11
  s3_permissions: :private
14
12
  else
15
13
  has_attached_file :user_import,
@@ -77,11 +75,14 @@ class UserImportFile < ActiveRecord::Base
77
75
  end
78
76
  new_user.operator = user
79
77
  new_user.username = username
80
- new_user.assign_attributes(set_user_params(new_user, row), as: :admin)
78
+ new_user.assign_attributes(set_user_params(new_user, row))
81
79
  profile = Profile.new
82
- profile.assign_attributes(set_profile_params(row), as: :admin)
80
+ profile.assign_attributes(set_profile_params(row))
83
81
 
84
82
  if new_user.save
83
+ if profile.locked
84
+ new_user.lock_access!
85
+ end
85
86
  new_user.profile = profile
86
87
  if profile.save
87
88
  num[:user_imported] += 1
@@ -167,7 +168,12 @@ class UserImportFile < ActiveRecord::Base
167
168
  row_num += 1
168
169
  username = row['username'].to_s.strip
169
170
  user = User.where(username: username).first
170
- user.destroy if user
171
+ if user
172
+ UserImportFile.transaction do
173
+ user.profile.destroy
174
+ user.destroy
175
+ end
176
+ end
171
177
  end
172
178
  transition_to!(:completed)
173
179
  rescue => e
@@ -182,10 +188,15 @@ class UserImportFile < ActiveRecord::Base
182
188
  UserImportFileTransition
183
189
  end
184
190
 
191
+ def self.initial_state
192
+ :pending
193
+ end
194
+
185
195
  def open_import_file(tempfile)
186
196
  file = CSV.open(tempfile.path, 'r:utf-8', col_sep: "\t")
187
197
  header_columns = %w(
188
198
  username role email password user_group user_number expired_at
199
+ full_name full_name_transcription required_role locked
189
200
  keyword_list note locale library dummy
190
201
  )
191
202
  if defined?(EnjuCirculation)
@@ -240,18 +251,30 @@ class UserImportFile < ActiveRecord::Base
240
251
  end
241
252
  params[:user_group_id] = user_group.id if user_group
242
253
 
254
+ required_role = Role.where(name: row['required_role']).first
255
+ unless required_role
256
+ required_role = Role.where(name: 'Librarian').first
257
+ end
258
+ params[:required_role_id] = required_role.id if required_role
259
+
243
260
  params[:user_number] = row['user_number']
261
+ params[:full_name] = row['full_name']
262
+ params[:full_name_transcription] = row['full_name_transcription']
244
263
 
245
264
  if row['expired_at'].present?
246
265
  params[:expired_at] = Time.zone.parse(row['expired_at']).end_of_day
247
266
  end
248
267
 
249
268
  if row['keyword_list'].present?
250
- params[:keyword_list] = row['keyword_list'].split('//').join('\n')
269
+ params[:keyword_list] = row['keyword_list'].split('//').join("\n")
251
270
  end
252
271
 
253
272
  params[:note] = row['note']
254
273
 
274
+ if %w(t true).include?(row['locked'].to_s.downcase.strip)
275
+ params[:locked] = true
276
+ end
277
+
255
278
  if I18n.available_locales.include?(row['locale'].to_s.to_sym)
256
279
  params[:locale] = row['locale']
257
280
  end
@@ -3,7 +3,7 @@ class UserImportFileTransition < ActiveRecord::Base
3
3
 
4
4
 
5
5
  belongs_to :user_import_file, inverse_of: :user_import_file_transitions
6
- attr_accessible :to_state, :sort_key, :metadata
6
+ #attr_accessible :to_state, :sort_key, :metadata
7
7
  end
8
8
 
9
9
  # == Schema Information
@@ -1,5 +1,4 @@
1
1
  class UserImportResult < ActiveRecord::Base
2
- attr_accessible :user_import_file_id, :user_id, :body
3
2
  default_scope { order('user_import_results.id') }
4
3
  scope :file_id, proc{ |file_id| where(user_import_file_id: file_id) }
5
4
  scope :failed, -> { where(user_id: nil) }
@@ -13,33 +13,11 @@
13
13
  <% if defined?(EnjuCirculation) %>
14
14
  <h2>
15
15
  <%= t('activerecord.models.checkout') %>
16
- <%= link_to image_tag('icons/date.png', size: '16x16', alt: 'iCalendar', class: 'icon'), checkouts_url(icalendar_token: current_user.checkout_icalendar_token, format: :ics) if current_user.checkout_icalendar_token? %>
17
- <%= link_to image_tag('icons/feed.png', size: '16x16', alt: 'RSS', class: 'icon'), checkouts_url(user_id: current_user.username, format: :rss) %>
18
- <%= link_to image_tag('icons/page_white_excel.png', size: '16x16', alt: 'TSV', class: 'icon'), checkouts_url(user_id: current_user.username, format: :txt) %>
16
+ <%= link_to image_tag('icons/date.png', size: '16x16', alt: 'iCalendar', class: 'icon'), checkouts_path(icalendar_token: current_user.profile.checkout_icalendar_token, format: :ics) if current_user.profile.checkout_icalendar_token? %>
17
+ <%= link_to image_tag('icons/feed.png', size: '16x16', alt: 'RSS', class: 'icon'), checkouts_path(user_id: current_user.username, format: :rss) %>
18
+ <%= link_to image_tag('icons/page_white_excel.png', size: '16x16', alt: 'TSV', class: 'icon'), checkouts_path(user_id: current_user.username, format: :txt) %>
19
19
  </h2>
20
- <table class="table table-striped index">
21
- <tr>
22
- <th><%= t('activerecord.models.item') %></th>
23
- <th><%= t('activerecord.attributes.checkout.due_date') %></th>
24
- </tr>
25
- <% current_user.checkouts.not_returned.each do |checkout| %>
26
- <tr class="line<%= cycle("0", "1") -%>">
27
- <td>
28
- <%= link_to checkout.item.item_identifier, checkout.item %><br />
29
- (<%= link_to checkout.item.manifestation.original_title, checkout.item.manifestation %>)
30
- </td>
31
- <td>
32
- <%=l checkout.due_date, formats: :only_date %>
33
- <br />
34
- <%- if can? :update, checkout -%>
35
- <% unless checkout.checkin %>
36
- (<%= link_to t('checkout.extend'), edit_checkout_path(checkout) -%>)
37
- <% end %>
38
- <%- end -%>
39
- </td>
40
- </tr>
41
- <% end %>
42
- </table>
20
+ <%= render 'checkouts/list', checkouts: current_user.checkouts.page(params[:page]) %>
43
21
  <% end %>
44
22
  </div>
45
23
  </div>
@@ -3,6 +3,11 @@
3
3
  <div id="content_list">
4
4
 
5
5
  <ul>
6
+ <% if current_user.try(:has_role?, 'Administrator') %>
7
+ <li>
8
+ <%= link_to t('activerecord.models.user_export_file'), user_export_files_path -%>
9
+ </li>
10
+ <% end %>
6
11
  <li>
7
12
  <%= link_to t('activerecord.models.resource_export_file'), resource_export_files_path -%>
8
13
  </li>
@@ -11,11 +16,6 @@
11
16
  <%= link_to t('activerecord.models.event_export_file'), event_export_files_path -%>
12
17
  </li>
13
18
  <% end %>
14
- <% if current_user.try(:has_role?, 'Administrator') %>
15
- <li>
16
- <%= link_to t('activerecord.models.user_export_file'), user_export_files_path -%>
17
- </li>
18
- <% end %>
19
19
  </ul>
20
20
  </div>
21
21
  </div>
@@ -30,7 +30,7 @@
30
30
  <%- @profiles.each_with_index do |profile, i| -%>
31
31
  <tr class="line<%= cycle("0", "1") -%>">
32
32
  <td>
33
- <% if profile.user_number %>
33
+ <% if profile.user_number? %>
34
34
  <%= link_to profile.user_number, profile -%>
35
35
  <% else %>
36
36
  <%= link_to t('profile.no_number'), profile -%>
@@ -38,6 +38,8 @@
38
38
  </td>
39
39
  <td>
40
40
  <%= profile.user.try(:username) -%>
41
+ <br />
42
+ <%= profile.full_name %>
41
43
  </td>
42
44
  <td><%= l(profile.created_at) -%></td>
43
45
  <td>