enju_seed 0.4.0.rc.1 → 0.4.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/profiles_controller.rb +3 -3
- data/app/controllers/roles_controller.rb +1 -1
- data/app/models/concerns/enju_seed/enju_user.rb +3 -3
- data/app/models/profile.rb +9 -9
- data/app/models/role.rb +2 -2
- data/app/models/user_has_role.rb +6 -6
- data/app/views/roles/_form.html.erb +1 -1
- data/db/migrate/041_create_roles.rb +1 -1
- data/db/migrate/20100606065209_create_user_has_roles.rb +1 -1
- data/db/migrate/20130221154434_add_additional_attributes_to_user.rb +1 -2
- data/db/migrate/20140122054321_create_profiles.rb +1 -1
- data/db/migrate/20140610123439_drop_email_unique_constraint_enju_leaf_rc10.rb +1 -1
- data/db/migrate/20140811031145_add_expired_at_to_profile.rb +1 -1
- data/db/migrate/20141003181336_add_full_name_transcription_to_profile.rb +1 -1
- data/db/migrate/20141003182825_add_date_of_birth_to_profile.rb +1 -1
- data/lib/enju_seed/version.rb +1 -1
- data/spec/dummy/app/models/user.rb +1 -1
- data/spec/dummy/db/migrate/059_create_libraries.rb +1 -2
- data/spec/dummy/db/migrate/069_create_shelves.rb +1 -2
- data/spec/dummy/db/migrate/077_create_user_groups.rb +1 -2
- data/spec/dummy/db/migrate/080_create_library_groups.rb +1 -1
- data/spec/dummy/db/migrate/120_create_baskets.rb +1 -1
- data/spec/dummy/db/migrate/124_create_bookstores.rb +1 -2
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +1 -1
- data/spec/dummy/db/migrate/131_create_request_types.rb +1 -1
- data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +1 -2
- data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +1 -1
- data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +1 -1
- data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb +1 -1
- data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +1 -1
- data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +1 -1
- data/spec/dummy/db/migrate/20120129014038_create_budget_types.rb +1 -1
- data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +1 -1
- data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +1 -1
- data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +1 -1
- data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +1 -1
- data/spec/dummy/db/migrate/20140110131010_create_user_import_results.rb +1 -1
- data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +2 -6
- data/spec/dummy/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +1 -1
- data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +2 -6
- data/spec/dummy/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +1 -1
- data/spec/dummy/db/migrate/20140821151023_create_colors.rb +1 -1
- data/spec/dummy/db/migrate/20150221063719_add_settings_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20150506105356_add_error_message_to_user_import_result.rb +1 -1
- data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +1 -1
- data/spec/dummy/db/migrate/20160610093229_add_html_snippet_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160627232316_add_most_recent_to_user_export_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20160813203039_add_user_id_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20170305064014_add_csv_charset_conversion_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20171014084528_add_header_logo_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20171126133835_rename_login_banner_to_old_login_banner.rb +1 -1
- data/spec/dummy/db/migrate/20171126135238_add_foreign_key_to_library_group_id_on_library.rb +1 -1
- data/spec/dummy/db/migrate/20180102162311_add_header_logo_meta_to_library_group.rb +1 -1
- data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +1 -1
- data/spec/dummy/db/migrate/20191216131755_add_email_to_library_group.rb +6 -0
- data/spec/dummy/db/schema.rb +100 -101
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/fixtures/profiles.yml +7 -7
- data/spec/fixtures/roles.yml +1 -1
- data/spec/fixtures/user_has_roles.yml +5 -5
- data/spec/models/profile_spec.rb +7 -7
- data/spec/models/role_spec.rb +1 -1
- data/spec/models/user_has_role_spec.rb +5 -5
- metadata +257 -253
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77bf05eb53d054c79b891f6970a7e80277be554a4f4ce49588cc7836a2506f8a
|
4
|
+
data.tar.gz: 2b925b9a23968bd6a08ba40214e09523902e470da8ccc3e7ad5c43e3b5843134
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc7a73ccff4bf3621c210082b8856b633655e794f5c6efd04153d62e28cf88ae6522d0e428e1c8d8f6a626c5f9e5613dbf3c6e3e0719470201bd0e2e541bb4ad
|
7
|
+
data.tar.gz: d9d5d19fa8b23b459b14964e3bc68de2094931faa5b41bdcffba4bd835e49f64f3295d7374f8320e2ede400f78a29a2303f026e6b8929b20971a93ae53c0ae26
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# EnjuSeed
|
2
|
-
![](https://
|
2
|
+
[![CircleCI](https://circleci.com/gh/next-l/enju_seed/tree/2.x.svg?style=svg)](https://circleci.com/gh/next-l/enju_seed/tree/2.x)
|
3
3
|
[![Coverage Status](https://coveralls.io/repos/github/next-l/enju_seed/badge.svg?branch=2.x)](https://coveralls.io/github/next-l/enju_seed?branch=2.x)
|
4
4
|
|
5
5
|
This project rocks and uses MIT-LICENSE.
|
@@ -8,7 +8,7 @@ class ProfilesController < ApplicationController
|
|
8
8
|
# GET /profiles.json
|
9
9
|
def index
|
10
10
|
if params[:username].present?
|
11
|
-
profile = User.
|
11
|
+
profile = User.find_by(username: params[:username]).try(:profile)
|
12
12
|
if profile
|
13
13
|
redirect_to profile
|
14
14
|
return
|
@@ -116,7 +116,7 @@ class ProfilesController < ApplicationController
|
|
116
116
|
respond_to do |format|
|
117
117
|
if @profile.save
|
118
118
|
if @profile.user
|
119
|
-
@profile.user.role = Role.
|
119
|
+
@profile.user.role = Role.find_by(name: 'User')
|
120
120
|
flash[:temporary_password] = password
|
121
121
|
end
|
122
122
|
format.html { redirect_to @profile, notice: t('controller.successfully_created', model: t('activerecord.models.profile')) }
|
@@ -132,7 +132,7 @@ class ProfilesController < ApplicationController
|
|
132
132
|
# PUT /profiles/1
|
133
133
|
# PUT /profiles/1.json
|
134
134
|
def update
|
135
|
-
@profile.
|
135
|
+
@profile.update(profile_update_params)
|
136
136
|
if @profile.user
|
137
137
|
if @profile.user.auto_generated_password == "1"
|
138
138
|
password = @profile.user.set_auto_generated_password
|
@@ -35,7 +35,7 @@ class RolesController < ApplicationController
|
|
35
35
|
end
|
36
36
|
|
37
37
|
respond_to do |format|
|
38
|
-
if @role.
|
38
|
+
if @role.update(role_params)
|
39
39
|
format.html { redirect_to @role, notice: t('controller.successfully_updated', model: t('activerecord.models.role')) }
|
40
40
|
format.json { head :no_content }
|
41
41
|
else
|
@@ -176,7 +176,7 @@ module EnjuSeed
|
|
176
176
|
# @return [Object]
|
177
177
|
def check_role_before_destroy
|
178
178
|
if has_role?('Administrator')
|
179
|
-
if Role.
|
179
|
+
if Role.find_by(name: 'Administrator').users.count == 1
|
180
180
|
raise username + 'This is the last administrator in this system.'
|
181
181
|
end
|
182
182
|
end
|
@@ -209,7 +209,7 @@ module EnjuSeed
|
|
209
209
|
# @return [Boolean]
|
210
210
|
def last_librarian?
|
211
211
|
if has_role?('Librarian')
|
212
|
-
role = Role.
|
212
|
+
role = Role.find_by(name: 'Librarian')
|
213
213
|
return true if role.users.count == 1
|
214
214
|
false
|
215
215
|
end
|
@@ -244,7 +244,7 @@ module EnjuSeed
|
|
244
244
|
|
245
245
|
# 最後の管理者を削除しようとした
|
246
246
|
if has_role?('Administrator')
|
247
|
-
if Role.
|
247
|
+
if Role.find_by(name: 'Administrator').users.count == 1
|
248
248
|
errors[:base] << I18n.t('user.last_administrator')
|
249
249
|
end
|
250
250
|
end
|
data/app/models/profile.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class Profile <
|
1
|
+
class Profile < ApplicationRecord
|
2
2
|
scope :administrators, -> { joins(user: :role).where('roles.name = ?', 'Administrator') }
|
3
3
|
scope :librarians, -> { joins(user: :role).where('roles.name = ? OR roles.name = ?', 'Administrator', 'Librarian') }
|
4
4
|
belongs_to :user, dependent: :destroy, optional: true
|
@@ -50,7 +50,7 @@ class Profile < ActiveRecord::Base
|
|
50
50
|
# 既定のユーザ権限を設定します。
|
51
51
|
# @return [void]
|
52
52
|
def set_role_and_agent
|
53
|
-
self.required_role = Role.
|
53
|
+
self.required_role = Role.find_by(name: 'Librarian') unless required_role
|
54
54
|
self.locale = I18n.default_locale.to_s unless locale
|
55
55
|
end
|
56
56
|
|
@@ -77,18 +77,18 @@ end
|
|
77
77
|
#
|
78
78
|
# Table name: profiles
|
79
79
|
#
|
80
|
-
# id :
|
81
|
-
# user_id :
|
82
|
-
# user_group_id :
|
83
|
-
# library_id :
|
80
|
+
# id :bigint not null, primary key
|
81
|
+
# user_id :bigint
|
82
|
+
# user_group_id :bigint
|
83
|
+
# library_id :bigint
|
84
84
|
# locale :string
|
85
85
|
# user_number :string
|
86
86
|
# full_name :text
|
87
87
|
# note :text
|
88
88
|
# keyword_list :text
|
89
|
-
# required_role_id :
|
90
|
-
# created_at :datetime
|
91
|
-
# updated_at :datetime
|
89
|
+
# required_role_id :bigint
|
90
|
+
# created_at :datetime not null
|
91
|
+
# updated_at :datetime not null
|
92
92
|
# checkout_icalendar_token :string
|
93
93
|
# save_checkout_history :boolean default(FALSE), not null
|
94
94
|
# expired_at :datetime
|
data/app/models/role.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class Role <
|
1
|
+
class Role < ApplicationRecord
|
2
2
|
include MasterModel
|
3
3
|
validates :name, presence: true, format: { with: /\A[A-Za-z][a-z_,]*[a-z]\z/ }
|
4
4
|
has_many :user_has_roles
|
@@ -22,7 +22,7 @@ end
|
|
22
22
|
#
|
23
23
|
# Table name: roles
|
24
24
|
#
|
25
|
-
# id :
|
25
|
+
# id :bigint not null, primary key
|
26
26
|
# name :string not null
|
27
27
|
# display_name :string
|
28
28
|
# note :text
|
data/app/models/user_has_role.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class UserHasRole <
|
1
|
+
class UserHasRole < ApplicationRecord
|
2
2
|
belongs_to :user
|
3
3
|
belongs_to :role
|
4
4
|
accepts_nested_attributes_for :role
|
@@ -8,9 +8,9 @@ end
|
|
8
8
|
#
|
9
9
|
# Table name: user_has_roles
|
10
10
|
#
|
11
|
-
# id :
|
12
|
-
# user_id :
|
13
|
-
# role_id :
|
14
|
-
# created_at :datetime
|
15
|
-
# updated_at :datetime
|
11
|
+
# id :bigint not null, primary key
|
12
|
+
# user_id :bigint not null
|
13
|
+
# role_id :bigint not null
|
14
|
+
# created_at :datetime not null
|
15
|
+
# updated_at :datetime not null
|
16
16
|
#
|
@@ -1,7 +1,6 @@
|
|
1
|
-
class AddAdditionalAttributesToUser < ActiveRecord::Migration[
|
1
|
+
class AddAdditionalAttributesToUser < ActiveRecord::Migration[5.2]
|
2
2
|
def change
|
3
3
|
add_column :users, :username, :string
|
4
|
-
add_column :users, :deleted_at, :datetime
|
5
4
|
add_column :users, :expired_at, :datetime
|
6
5
|
|
7
6
|
add_column :users, :failed_attempts, :integer, default: 0
|
data/lib/enju_seed/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateLibraries < ActiveRecord::Migration[
|
1
|
+
class CreateLibraries < ActiveRecord::Migration[5.2]
|
2
2
|
def change
|
3
3
|
create_table :libraries do |t|
|
4
4
|
t.string :name, index: true, null: false
|
@@ -20,7 +20,6 @@ class CreateLibraries < ActiveRecord::Migration[4.2]
|
|
20
20
|
t.references :country
|
21
21
|
|
22
22
|
t.timestamps
|
23
|
-
t.datetime :deleted_at
|
24
23
|
end
|
25
24
|
end
|
26
25
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateShelves < ActiveRecord::Migration[
|
1
|
+
class CreateShelves < ActiveRecord::Migration[5.2]
|
2
2
|
def change
|
3
3
|
create_table :shelves do |t|
|
4
4
|
t.string :name, null: false
|
@@ -8,7 +8,6 @@ class CreateShelves < ActiveRecord::Migration[4.2]
|
|
8
8
|
t.integer :items_count, default: 0, null: false
|
9
9
|
t.integer :position
|
10
10
|
t.timestamps
|
11
|
-
t.datetime :deleted_at
|
12
11
|
end
|
13
12
|
end
|
14
13
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateUserGroups < ActiveRecord::Migration[
|
1
|
+
class CreateUserGroups < ActiveRecord::Migration[5.2]
|
2
2
|
def change
|
3
3
|
create_table :user_groups do |t|
|
4
4
|
t.string :name, not_null: true
|
@@ -6,7 +6,6 @@ class CreateUserGroups < ActiveRecord::Migration[4.2]
|
|
6
6
|
t.text :note
|
7
7
|
t.integer :position
|
8
8
|
t.timestamps
|
9
|
-
t.datetime :deleted_at
|
10
9
|
end
|
11
10
|
end
|
12
11
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateBookstores < ActiveRecord::Migration[
|
1
|
+
class CreateBookstores < ActiveRecord::Migration[5.2]
|
2
2
|
def change
|
3
3
|
create_table :bookstores do |t|
|
4
4
|
t.text :name, null: false
|
@@ -9,7 +9,6 @@ class CreateBookstores < ActiveRecord::Migration[4.2]
|
|
9
9
|
t.string :fax_number
|
10
10
|
t.string :url
|
11
11
|
t.integer :position
|
12
|
-
t.datetime :deleted_at
|
13
12
|
|
14
13
|
t.timestamps
|
15
14
|
end
|
@@ -1,11 +1,10 @@
|
|
1
|
-
class CreateSubscriptions < ActiveRecord::Migration[
|
1
|
+
class CreateSubscriptions < ActiveRecord::Migration[5.2]
|
2
2
|
def change
|
3
3
|
create_table :subscriptions do |t|
|
4
4
|
t.text :title, null: false
|
5
5
|
t.text :note
|
6
6
|
t.references :user, index: true
|
7
7
|
t.references :order_list, index: true
|
8
|
-
t.datetime :deleted_at
|
9
8
|
t.integer :subscribes_count, default: 0, null: false
|
10
9
|
|
11
10
|
t.timestamps
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddValidPeriodForNewUserToUserGroup < ActiveRecord::Migration[
|
1
|
+
class AddValidPeriodForNewUserToUserGroup < ActiveRecord::Migration[5.2]
|
2
2
|
def self.up
|
3
3
|
add_column :user_groups, :valid_period_for_new_user, :integer, default: 0, null: false
|
4
4
|
add_column :user_groups, :expired_at, :timestamp
|
@@ -1,12 +1,8 @@
|
|
1
|
-
class CreateUserImportFileTransitions < ActiveRecord::Migration[
|
1
|
+
class CreateUserImportFileTransitions < ActiveRecord::Migration[5.2]
|
2
2
|
def change
|
3
3
|
create_table :user_import_file_transitions do |t|
|
4
4
|
t.string :to_state
|
5
|
-
|
6
|
-
t.text :metadata
|
7
|
-
else
|
8
|
-
t.text :metadata, default: "{}"
|
9
|
-
end
|
5
|
+
t.text :metadata, default: "{}"
|
10
6
|
t.integer :sort_key
|
11
7
|
t.references :user_import_file, index: true
|
12
8
|
t.timestamps
|