enju_leaf 1.1.4 → 1.2.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +3 -3
- data/app/assets/javascripts/autocomplete_agent.js +30 -0
- data/app/assets/javascripts/{menu.enju.js → enju.menu.js} +5 -0
- data/app/assets/javascripts/enju_leaf.js +3 -3
- data/app/assets/javascripts/portlets.js +2 -2
- data/app/assets/stylesheets/enju.css +52 -18
- data/app/assets/stylesheets/enju_leaf.css +2 -0
- data/app/controllers/concerns/enju_leaf/controller.rb +225 -0
- data/app/controllers/my_accounts_controller.rb +9 -7
- data/app/controllers/names_controller.rb +60 -0
- data/app/controllers/page_controller.rb +5 -4
- data/app/controllers/profiles_controller.rb +13 -4
- data/app/controllers/roles_controller.rb +11 -2
- data/app/controllers/user_export_files_controller.rb +13 -3
- data/app/controllers/user_groups_controller.rb +12 -3
- data/app/controllers/user_import_files_controller.rb +14 -4
- data/app/controllers/user_import_results_controller.rb +11 -1
- data/app/jobs/user_export_file_job.rb +7 -0
- data/app/jobs/user_import_file_job.rb +7 -0
- data/app/mailers/notifier.rb +0 -2
- data/app/models/concerns/calculate_stat.rb +35 -0
- data/app/models/concerns/enju_leaf/enju_user.rb +309 -0
- data/app/models/concerns/export_file.rb +19 -0
- data/app/models/concerns/import_file.rb +89 -0
- data/app/models/concerns/master_model.rb +38 -0
- data/app/models/profile.rb +2 -2
- data/app/models/user_export_file.rb +0 -2
- data/app/models/user_group.rb +0 -3
- data/app/models/user_import_file.rb +0 -1
- data/app/policies/application_policy.rb +53 -0
- data/app/policies/name_policy.rb +21 -0
- data/app/policies/profile_policy.rb +55 -0
- data/app/policies/role_policy.rb +21 -0
- data/app/policies/user_export_file_policy.rb +21 -0
- data/app/policies/user_group_policy.rb +22 -0
- data/app/policies/user_import_file_policy.rb +21 -0
- data/app/policies/user_import_result_policy.rb +21 -0
- data/app/views/devise/sessions/{new.mobile.erb → new.html+phone.erb} +0 -0
- data/app/views/layouts/{application.mobile.erb → application.html+phone.erb} +0 -0
- data/app/views/layouts/application.html.erb +2 -2
- data/app/views/layouts/devise/{passwords.mobile.erb → passwords.html+phone.erb} +0 -0
- data/app/views/layouts/devise/{sessions.mobile.erb → sessions.html+phone.erb} +0 -0
- data/app/views/my_accounts/{show.mobile.erb → show.html+phone.erb} +0 -0
- data/app/views/my_accounts/show.html.erb +3 -3
- data/app/views/names/_form.html.erb +41 -0
- data/app/views/names/edit.html.erb +6 -0
- data/app/views/names/index.html.erb +37 -0
- data/app/views/names/new.html.erb +5 -0
- data/app/views/names/show.html.erb +34 -0
- data/app/views/page/{403.mobile.erb → 403.html+phone.erb} +0 -0
- data/app/views/page/{404.mobile.erb → 404.html+phone.erb} +0 -0
- data/app/views/page/{500.mobile.erb → 500.html+phone.erb} +0 -0
- data/app/views/page/_footer.html+phone.erb +3 -0
- data/app/views/page/_footer.html.erb +3 -10
- data/app/views/page/{_index.mobile.erb → _index.html+phone.erb} +0 -0
- data/app/views/page/_menu.html.erb +1 -1
- data/app/views/page/{_mobile.mobile.erb → _mobile.html+phone.erb} +0 -0
- data/app/views/page/{_search_form.mobile.erb → _search_form.html+phone.erb} +0 -0
- data/app/views/page/_select_locale.html.erb +1 -1
- data/app/views/page/configuration.html.erb +1 -1
- data/app/views/page/{index.mobile.erb → index.html+phone.erb} +0 -0
- data/app/views/profiles/edit.html.erb +1 -1
- data/app/views/profiles/index.html.erb +5 -5
- data/app/views/profiles/{show.mobile.erb → show.html+phone.erb} +0 -0
- data/app/views/profiles/show.html.erb +9 -4
- data/app/views/roles/index.html.erb +2 -2
- data/app/views/roles/show.html.erb +1 -1
- data/app/views/user_groups/_form.html.erb +1 -1
- data/app/views/user_groups/index.html.erb +4 -4
- data/app/views/user_groups/show.html.erb +2 -2
- data/config/locales/translation_ja.yml +2 -2
- data/config/routes.rb +1 -4
- data/db/migrate/20151126005552_add_provider_to_identity.rb +5 -0
- data/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb +9 -0
- data/db/migrate/20160627232316_add_most_recent_to_user_export_file_transitions.rb +9 -0
- data/lib/enju_leaf/engine.rb +4 -8
- data/lib/enju_leaf/helper.rb +1 -1
- data/lib/enju_leaf/version.rb +1 -1
- data/lib/enju_leaf.rb +0 -249
- data/lib/generators/enju_leaf/setup/setup_generator.rb +19 -26
- data/lib/generators/enju_leaf/setup/templates/config/initializers/enju_leaf.rb +1 -0
- data/lib/tasks/enju_leaf_tasks.rake +2 -2
- data/spec/controllers/profiles_controller_spec.rb +22 -12
- data/spec/controllers/user_export_files_controller_spec.rb +9 -10
- data/spec/controllers/user_groups_controller_spec.rb +9 -9
- data/spec/controllers/user_import_files_controller_spec.rb +6 -6
- data/spec/controllers/user_import_results_controller_spec.rb +3 -3
- data/spec/dummy/app/controllers/application_controller.rb +6 -7
- data/spec/dummy/app/models/user.rb +4 -5
- data/spec/dummy/config/application.rb +6 -38
- data/spec/dummy/config/environments/development.rb +22 -18
- data/spec/dummy/config/environments/production.rb +46 -34
- data/spec/dummy/config/environments/test.rb +19 -14
- data/spec/dummy/config/initializers/enju_leaf.rb +2 -0
- data/spec/dummy/config/routes.rb +5 -1
- data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +13 -0
- data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +9 -0
- data/spec/dummy/db/schema.rb +15 -0
- data/spec/factories/profile.rb +6 -6
- data/spec/models/user_export_file_spec.rb +1 -1
- data/spec/models/user_import_file_spec.rb +5 -5
- data/spec/rails_helper.rb +4 -11
- data/spec/routing/users_spec.rb +14 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/devise.rb +2 -2
- data/spec/views/my_accounts/show.html.erb_spec.rb +43 -0
- data/spec/views/page/about.html.erb_spec.rb +0 -3
- data/spec/views/page/advanced_search.html.erb_spec.rb +1 -4
- data/spec/views/page/configuration.html.erb_spec.rb +0 -3
- data/spec/views/page/export.html.erb_spec.rb +0 -3
- data/spec/views/page/import.html.erb_spec.rb +0 -3
- data/spec/views/page/index.html.erb_spec.rb +1 -4
- data/spec/views/page/opensearch.xml.builder_spec.rb +1 -4
- data/spec/views/page/statistics.html.erb_spec.rb +0 -3
- data/spec/views/profiles/edit.html.erb_spec.rb +11 -14
- data/spec/views/profiles/index.html.erb_spec.rb +3 -4
- data/spec/views/profiles/show.html.erb_spec.rb +3 -8
- data/spec/views/user_import_results/index.html.erb_spec.rb +0 -3
- data/vendor/assets/javascripts/jquery.highlight.js +97 -56
- metadata +114 -288
- data/app/assets/javascripts/tab_view.js +0 -4
- data/app/models/enju_leaf/ability.rb +0 -102
- data/app/views/page/_footer.mobile.erb +0 -3
- data/app/workers/user_export_file_queue.rb +0 -7
- data/app/workers/user_import_file_queue.rb +0 -7
- data/config/initializers/resque.rb +0 -1
- data/lib/enju_leaf/calculate_stat.rb +0 -42
- data/lib/enju_leaf/controller.rb +0 -24
- data/lib/enju_leaf/export_file.rb +0 -26
- data/lib/enju_leaf/import_file.rb +0 -99
- data/lib/enju_leaf/master_model.rb +0 -42
- data/lib/enju_leaf/user.rb +0 -317
- data/lib/plugins/ext/mobylette/resolvers/chained_fallback_resolver.rb +0 -73
- data/lib/plugins/ext/mobylette.rb +0 -2
- data/lib/plugins/ext/sunspot/abstract_search.rb +0 -12
- data/lib/plugins/ext/sunspot/dismax.rb +0 -41
- data/lib/plugins/ext/sunspot/start_record.rb +0 -55
- data/lib/plugins/ext/sunspot.rb +0 -3
- data/lib/plugins/ext.rb +0 -2
- data/lib/plugins.rb +0 -2
- data/spec/dummy/config/application.yml +0 -47
- data/spec/routing/accounts_spec.rb +0 -14
@@ -134,7 +134,7 @@ ja:
|
|
134
134
|
checkout: "貸出"
|
135
135
|
checkin: "返却"
|
136
136
|
name: "名前"
|
137
|
-
are_you_sure: "
|
137
|
+
are_you_sure: "本当に実行してもよろしいですか?"
|
138
138
|
file: "ファイル"
|
139
139
|
cancel: "取消"
|
140
140
|
feed: "フィード"
|
@@ -289,7 +289,7 @@ ja:
|
|
289
289
|
successfully_deleted: "%{model}は正常に削除されました。"
|
290
290
|
advanced_search:
|
291
291
|
from: ""
|
292
|
-
to: "
|
292
|
+
to: "〜"
|
293
293
|
all_libraries: "全ての図書館"
|
294
294
|
check_all: "全て選択/解除"
|
295
295
|
work:
|
data/config/routes.rb
CHANGED
data/lib/enju_leaf/engine.rb
CHANGED
@@ -1,25 +1,21 @@
|
|
1
1
|
require 'kaminari'
|
2
2
|
require 'devise'
|
3
|
-
require '
|
3
|
+
require 'pundit'
|
4
4
|
require 'acts_as_list'
|
5
|
-
require '
|
5
|
+
require 'strip_attributes'
|
6
6
|
require 'friendly_id'
|
7
7
|
require 'addressable/uri'
|
8
8
|
require 'sunspot_rails'
|
9
|
-
require '
|
10
|
-
require 'nested_form'
|
9
|
+
require 'cocoon'
|
11
10
|
require 'enju_biblio'
|
12
11
|
require 'enju_library'
|
13
12
|
require 'enju_manifestation_viewer'
|
14
13
|
require 'kramdown'
|
15
|
-
require 'mobylette'
|
16
14
|
require 'rails_autolink'
|
17
|
-
require 'devise-encryptable'
|
18
15
|
require 'sitemap_generator'
|
19
|
-
require 'redis-rails'
|
20
16
|
require 'jquery-ui-rails'
|
21
17
|
require 'statesman'
|
22
|
-
require '
|
18
|
+
require 'browser'
|
23
19
|
|
24
20
|
module EnjuLeaf
|
25
21
|
class Engine < ::Rails::Engine
|
data/lib/enju_leaf/helper.rb
CHANGED
data/lib/enju_leaf/version.rb
CHANGED
data/lib/enju_leaf.rb
CHANGED
@@ -1,264 +1,15 @@
|
|
1
1
|
require "enju_leaf/engine"
|
2
2
|
require "enju_leaf/version"
|
3
|
-
require "enju_leaf/controller"
|
4
|
-
require "enju_leaf/user"
|
5
3
|
require "enju_leaf/helper"
|
6
|
-
require "enju_leaf/calculate_stat"
|
7
|
-
require "enju_leaf/import_file"
|
8
|
-
require "enju_leaf/export_file"
|
9
4
|
require "enju_leaf/localized_name"
|
10
|
-
require "enju_leaf/master_model"
|
11
5
|
require "enju_leaf/url_validator"
|
12
6
|
|
13
7
|
require 'csv'
|
14
|
-
#require 'mathn'
|
15
8
|
require 'rss'
|
16
9
|
require 'nkf'
|
17
10
|
require 'ipaddr'
|
18
|
-
require 'plugins'
|
19
11
|
|
20
12
|
module EnjuLeaf
|
21
|
-
def self.included(base)
|
22
|
-
base.extend(ClassMethods)
|
23
|
-
end
|
24
|
-
|
25
|
-
module InstanceMethods
|
26
|
-
private
|
27
|
-
def after_sign_in_path_for(resource)
|
28
|
-
session[:locale] = nil
|
29
|
-
super
|
30
|
-
end
|
31
|
-
|
32
|
-
def render_403
|
33
|
-
return if performed?
|
34
|
-
if user_signed_in?
|
35
|
-
respond_to do |format|
|
36
|
-
format.html {render template: 'page/403', status: 403}
|
37
|
-
format.mobile {render template: 'page/403', status: 403}
|
38
|
-
format.xml {render template: 'page/403', status: 403}
|
39
|
-
format.json { render text: '{"error": "forbidden"}' }
|
40
|
-
format.rss {render template: 'page/403.xml', status: 403}
|
41
|
-
end
|
42
|
-
else
|
43
|
-
respond_to do |format|
|
44
|
-
format.html { redirect_to new_user_session_url }
|
45
|
-
format.mobile { redirect_to new_user_session_url }
|
46
|
-
format.xml { render template: 'page/403', status: 403 }
|
47
|
-
format.json { render text: '{"error": "forbidden"}' }
|
48
|
-
format.rss { render template: 'page/403.xml', status: 403 }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def render_404
|
54
|
-
return if performed?
|
55
|
-
respond_to do |format|
|
56
|
-
format.html { render template: 'page/404', status: 404 }
|
57
|
-
format.mobile { render template: 'page/404', status: 404 }
|
58
|
-
format.xml { render template: 'page/404', status: 404 }
|
59
|
-
format.json { render text: '{"error": "not_found"}' }
|
60
|
-
format.rss { render template: 'page/404.xml', status: 404 }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def render_404_invalid_format
|
65
|
-
return if performed?
|
66
|
-
render file: "#{Rails.root}/public/404", formats: [:html]
|
67
|
-
end
|
68
|
-
|
69
|
-
def render_500
|
70
|
-
return if performed?
|
71
|
-
respond_to do |format|
|
72
|
-
format.html {render file: "#{Rails.root}/public/500", layout: false, status: 500}
|
73
|
-
format.mobile {render file: "#{Rails.root}/public/500", layout: false, status: 500}
|
74
|
-
format.xml {render template: 'page/500', status: 500}
|
75
|
-
format.json { render text: '{"error": "server_error"}' }
|
76
|
-
format.xml {render template: 'page/500.xml', status: 500}
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def render_500_nosolr
|
81
|
-
Rails.logger.fatal("please confirm that the Solr is running.")
|
82
|
-
return if performed?
|
83
|
-
#flash[:notice] = t('page.connection_failed')
|
84
|
-
respond_to do |format|
|
85
|
-
format.html {render template: "page/500_nosolr", layout: false, status: 500}
|
86
|
-
format.mobile {render template: "page/500_nosolr", layout: false, status: 500}
|
87
|
-
format.xml {render template: 'page/500', status: 500}
|
88
|
-
format.json { render text: '{"error": "server_error"}' }
|
89
|
-
format.xml {render template: 'page/500.xml', status: 500}
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def set_locale
|
94
|
-
if params[:locale]
|
95
|
-
unless I18n.available_locales.include?(params[:locale].to_s.intern)
|
96
|
-
raise InvalidLocaleError
|
97
|
-
end
|
98
|
-
end
|
99
|
-
if user_signed_in?
|
100
|
-
locale = params[:locale] || session[:locale] || current_user.profile.try(:locale).try(:to_sym)
|
101
|
-
else
|
102
|
-
locale = params[:locale] || session[:locale]
|
103
|
-
end
|
104
|
-
if locale
|
105
|
-
I18n.locale = @locale = session[:locale] = locale.to_sym
|
106
|
-
else
|
107
|
-
I18n.locale = @locale = session[:locale] = I18n.default_locale
|
108
|
-
end
|
109
|
-
rescue InvalidLocaleError
|
110
|
-
@locale = I18n.default_locale
|
111
|
-
end
|
112
|
-
|
113
|
-
def default_url_options(options={})
|
114
|
-
{locale: nil}
|
115
|
-
end
|
116
|
-
|
117
|
-
def set_available_languages
|
118
|
-
if Rails.env == 'production'
|
119
|
-
@available_languages = Rails.cache.fetch('available_languages'){
|
120
|
-
Language.where(iso_639_1: I18n.available_locales.map{|l| l.to_s}).select([:id, :iso_639_1, :name, :native_name, :display_name, :position]).all
|
121
|
-
}
|
122
|
-
else
|
123
|
-
@available_languages = Language.where(iso_639_1: I18n.available_locales.map{|l| l.to_s})
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def reset_params_session
|
128
|
-
session[:params] = nil
|
129
|
-
end
|
130
|
-
|
131
|
-
def not_found
|
132
|
-
raise ActiveRecord::RecordNotFound
|
133
|
-
end
|
134
|
-
|
135
|
-
def access_denied
|
136
|
-
raise CanCan::AccessDenied
|
137
|
-
end
|
138
|
-
|
139
|
-
def get_user
|
140
|
-
@user = User.where(username: params[:user_id]).first if params[:user_id]
|
141
|
-
#authorize! :show, @user if @user
|
142
|
-
end
|
143
|
-
|
144
|
-
def get_user_group
|
145
|
-
@user_group = UserGroup.find(params[:user_group_id]) if params[:user_group_id]
|
146
|
-
end
|
147
|
-
|
148
|
-
def convert_charset
|
149
|
-
case params[:format]
|
150
|
-
when 'csv'
|
151
|
-
return unless LibraryGroup.site_config.settings[:csv_charset_conversion]
|
152
|
-
# TODO: 他の言語
|
153
|
-
if @locale.to_sym == :ja
|
154
|
-
headers["Content-Type"] = "text/csv; charset=Shift_JIS"
|
155
|
-
response.body = NKF::nkf('-Ws', response.body)
|
156
|
-
end
|
157
|
-
when 'xml'
|
158
|
-
if @locale.to_sym == :ja
|
159
|
-
headers["Content-Type"] = "application/xml; charset=Shift_JIS"
|
160
|
-
response.body = NKF::nkf('-Ws', response.body)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
def store_page
|
166
|
-
if request.get? and request.format.try(:html?) and !request.xhr?
|
167
|
-
flash[:page] = params[:page] if params[:page].to_i > 0
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
def store_location
|
172
|
-
if request.get? and request.format.try(:html?) and !request.xhr?
|
173
|
-
session[:user_return_to] = request.fullpath
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
def set_role_query(user, search)
|
178
|
-
role = user.try(:role) || Role.default_role
|
179
|
-
search.build do
|
180
|
-
with(:required_role_id).less_than_or_equal_to role.id
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
def solr_commit
|
185
|
-
Sunspot.commit
|
186
|
-
end
|
187
|
-
|
188
|
-
def get_version
|
189
|
-
@version = params[:version_id].to_i if params[:version_id]
|
190
|
-
@version = nil if @version == 0
|
191
|
-
end
|
192
|
-
|
193
|
-
def clear_search_sessions
|
194
|
-
session[:query] = nil
|
195
|
-
session[:params] = nil
|
196
|
-
session[:search_params] = nil
|
197
|
-
session[:manifestation_ids] = nil
|
198
|
-
end
|
199
|
-
|
200
|
-
def api_request?
|
201
|
-
true unless params[:format].nil? or params[:format] == 'html'
|
202
|
-
end
|
203
|
-
|
204
|
-
def current_ability
|
205
|
-
@current_ability ||= EnjuLeaf::Ability.new(current_user, request.remote_ip.split('%')[0])
|
206
|
-
@current_ability.merge(EnjuBiblio::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuBiblio)
|
207
|
-
@current_ability.merge(EnjuLibrary::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuLibrary)
|
208
|
-
@current_ability.merge(EnjuNii::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuNii)
|
209
|
-
@current_ability.merge(EnjuSubject::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuSubject)
|
210
|
-
@current_ability.merge(EnjuPurchaseRequest::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuPurchaseRequest)
|
211
|
-
@current_ability.merge(EnjuQuestion::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuQuestion)
|
212
|
-
@current_ability.merge(EnjuBookmark::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuBookmark)
|
213
|
-
@current_ability.merge(EnjuResourceMerge::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuResourceMerge)
|
214
|
-
@current_ability.merge(EnjuCirculation::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuCirculation)
|
215
|
-
@current_ability.merge(EnjuMessage::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuMessage)
|
216
|
-
@current_ability.merge(EnjuInterLibraryLoan::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuInterLibraryLoan)
|
217
|
-
@current_ability.merge(EnjuInventory::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuInventory)
|
218
|
-
@current_ability.merge(EnjuEvent::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuEvent)
|
219
|
-
@current_ability.merge(EnjuNews::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuNews)
|
220
|
-
@current_ability.merge(EnjuSearchLog::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuSearchLog)
|
221
|
-
@current_ability.merge(EnjuIr::Ability.new(current_user, request.remote_ip.split('%')[0])) if defined?(EnjuIr)
|
222
|
-
@current_ability
|
223
|
-
end
|
224
|
-
|
225
|
-
def get_top_page_content
|
226
|
-
if defined?(EnjuNews)
|
227
|
-
@news_feeds = Rails.cache.fetch('news_feed_all'){NewsFeed.order(:position)}
|
228
|
-
@news_posts = NewsPost.limit(LibraryGroup.site_config.settings[:news_post_number_top_page] || 10)
|
229
|
-
end
|
230
|
-
@libraries = Library.real
|
231
|
-
end
|
232
|
-
|
233
|
-
def set_mobile_request
|
234
|
-
if params[:mobile_view]
|
235
|
-
case params[:mobile_view]
|
236
|
-
when 'true'
|
237
|
-
session[:mobylette_override] = :force_mobile
|
238
|
-
request.format = :mobile
|
239
|
-
when 'false'
|
240
|
-
session[:mobylette_override] = :ignore_mobile
|
241
|
-
unless params[:format]
|
242
|
-
request.format = :html if request.format == :mobile
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
def move_position(resource, direction, redirect = true)
|
249
|
-
if ['higher', 'lower'].include?(direction)
|
250
|
-
resource.send("move_#{direction}")
|
251
|
-
if redirect
|
252
|
-
redirect_to url_for(controller: resource.class.to_s.pluralize.underscore)
|
253
|
-
return
|
254
|
-
end
|
255
|
-
end
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
13
|
class InvalidLocaleError < StandardError
|
260
14
|
end
|
261
15
|
end
|
262
|
-
|
263
|
-
ActiveRecord::Base.send(:include, EnjuLeaf::EnjuUser)
|
264
|
-
ActionController::Base.send(:include, EnjuLeaf)
|
@@ -7,12 +7,14 @@ class EnjuLeaf::SetupGenerator < Rails::Generators::Base
|
|
7
7
|
directory("solr", "example/solr")
|
8
8
|
copy_file("Procfile", "Procfile")
|
9
9
|
copy_file("config/schedule.rb", "config/schedule.rb")
|
10
|
+
copy_file("config/initializers/enju_leaf.rb", "config/initializers/enju_leaf.rb")
|
10
11
|
copy_file("config/initializers/resque.rb", "config/initializers/resque.rb")
|
11
12
|
append_to_file("config/initializers/assets.rb", "Rails.application.config.assets.precompile += %w( *.png )")
|
12
13
|
inject_into_file 'config/application.rb', after: /# config.i18n.default_locale = :de$\n/ do
|
13
14
|
<<"EOS"
|
14
15
|
config.i18n.available_locales = [:en, :ja]
|
15
16
|
config.i18n.enforce_available_locales = true
|
17
|
+
config.active_job.queue_adapter = :resque
|
16
18
|
EOS
|
17
19
|
end
|
18
20
|
gsub_file 'config/application.rb', /# config.i18n.default_locale = :de$/,
|
@@ -38,7 +40,7 @@ EOS
|
|
38
40
|
gsub_file 'app/models/user.rb', /, :trackable, :validatable$/, <<EOS
|
39
41
|
, :trackable, #:validatable,
|
40
42
|
:lockable, :lock_strategy => :none, :unlock_strategy => :none
|
41
|
-
|
43
|
+
include EnjuLeaf::EnjuUser
|
42
44
|
EOS
|
43
45
|
generate("sunspot_rails:install")
|
44
46
|
generate("kaminari:config")
|
@@ -50,33 +52,30 @@ EOS
|
|
50
52
|
gsub_file 'config/initializers/kaminari_config.rb',
|
51
53
|
/# config.default_per_page = 25$/,
|
52
54
|
"config.default_per_page = 10"
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
/\/\/= require turbolinks$/,
|
58
|
-
""
|
59
|
-
end
|
55
|
+
generate("friendly_id")
|
56
|
+
gsub_file "app/assets/javascripts/application.js",
|
57
|
+
/\/\/= require turbolinks$/,
|
58
|
+
""
|
60
59
|
gsub_file 'config/routes.rb', /devise_for :users$/, "devise_for :users, skip: [:registration]"
|
60
|
+
inject_into_file 'config/routes.rb', after: /Rails.application.routes.draw do$\n/ do
|
61
|
+
<<"EOS"
|
62
|
+
authenticate :user, lambda {|u| u.role.try(:name) == 'Administrator' } do
|
63
|
+
mount Resque::Server.new, at: "/resque", as: :resque
|
64
|
+
end
|
65
|
+
EOS
|
66
|
+
end
|
61
67
|
gsub_file 'config/initializers/devise.rb', '# config.email_regexp = /\A[^@]+@[^@]+\z/', 'config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i'
|
62
68
|
gsub_file 'config/initializers/devise.rb', '# config.authentication_keys = [:email]', 'config.authentication_keys = [:username]'
|
63
69
|
gsub_file 'config/initializers/devise.rb', '# config.secret_key', 'config.secret_key'
|
64
|
-
gsub_file 'config/initializers/devise.rb',
|
65
|
-
"# config.navigational_formats = ['*/*', :html]",
|
66
|
-
"config.navigational_formats = ['*/*', :html, :mobile]"
|
67
70
|
|
68
71
|
inject_into_class "app/controllers/application_controller.rb", ApplicationController do
|
69
72
|
<<"EOS"
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
+
include EnjuLeaf::Controller
|
74
|
+
include EnjuBiblio::Controller
|
75
|
+
include EnjuLibrary::Controller
|
73
76
|
|
74
|
-
|
75
|
-
|
76
|
-
config[:skip_user_agents] = ENV['ENJU_SKIP_MOBILE_AGENTS'].to_s.split(',').map{|a|
|
77
|
-
a.to_sym
|
78
|
-
}
|
79
|
-
end
|
77
|
+
include Pundit
|
78
|
+
after_action :verify_authorized, unless: :devise_controller?
|
80
79
|
EOS
|
81
80
|
end
|
82
81
|
|
@@ -101,12 +100,6 @@ EOS
|
|
101
100
|
<<"EOS"
|
102
101
|
require 'rack/protection'
|
103
102
|
use Rack::Protection, except: [:escaped_params, :json_csrf, :http_origin, :session_hijacking, :remote_token]
|
104
|
-
EOS
|
105
|
-
end
|
106
|
-
create_file 'config/initializers/mobile.rb' do <<"EOS"
|
107
|
-
ActionController::Responder.class_eval do
|
108
|
-
alias :to_mobile :to_html
|
109
|
-
end
|
110
103
|
EOS
|
111
104
|
end
|
112
105
|
remove_file "public/index.html"
|
@@ -0,0 +1 @@
|
|
1
|
+
Item.include(EnjuLibrary::EnjuItem)
|
@@ -5,7 +5,7 @@ namespace :enju_leaf do
|
|
5
5
|
desc "create initial records for enju_leaf"
|
6
6
|
task :setup => :environment do
|
7
7
|
Dir.glob(Rails.root.to_s + '/db/fixtures/enju_leaf/*.yml').each do |file|
|
8
|
-
ActiveRecord::
|
8
|
+
ActiveRecord::FixtureSet.create_fixtures('db/fixtures/enju_leaf', File.basename(file, '.*'))
|
9
9
|
end
|
10
10
|
|
11
11
|
Rake::Task['enju_biblio:setup'].invoke
|
@@ -33,7 +33,7 @@ namespace :enju_leaf do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
desc "reindex all models"
|
36
|
-
task :reindex, [:batch_size, :models, :silence] => :environment do |
|
36
|
+
task :reindex, [:batch_size, :models, :silence] => :environment do |_t, args|
|
37
37
|
Rails::Engine.subclasses.each{|engine| engine.instance.eager_load!}
|
38
38
|
Rake::Task['sunspot:reindex'].execute(args)
|
39
39
|
end
|
@@ -1,19 +1,16 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
require 'rails_helper'
|
3
2
|
|
4
3
|
describe ProfilesController do
|
5
4
|
fixtures :all
|
6
5
|
|
7
|
-
describe "GET index"
|
8
|
-
before do
|
9
|
-
Profile.reindex
|
10
|
-
end
|
11
|
-
|
6
|
+
describe "GET index" do
|
12
7
|
describe "When logged in as Administrator" do
|
13
8
|
login_fixture_admin
|
14
9
|
|
15
10
|
it "assigns all profiles as @profiles" do
|
16
11
|
get :index
|
12
|
+
Sunspot.session.should be_a_search_for(Profile)
|
13
|
+
Sunspot.session.should have_search_params(:fulltext, '')
|
17
14
|
assigns(:profiles).should_not be_nil
|
18
15
|
end
|
19
16
|
end
|
@@ -23,19 +20,26 @@ describe ProfilesController do
|
|
23
20
|
|
24
21
|
it "assigns all profiles as @profiles" do
|
25
22
|
get :index
|
23
|
+
Sunspot.session.should be_a_search_for(Profile)
|
24
|
+
Sunspot.session.should have_search_params(:fulltext, '')
|
26
25
|
assigns(:profiles).should_not be_nil
|
27
26
|
end
|
28
27
|
|
29
28
|
it "should get index with query" do
|
30
29
|
get :index, :query => 'user1'
|
31
30
|
response.should be_success
|
32
|
-
|
31
|
+
Sunspot.session.should be_a_search_for(Profile)
|
32
|
+
Sunspot.session.should have_search_params(:fulltext, 'user1')
|
33
|
+
assigns(:profiles).should_not be_nil
|
33
34
|
end
|
34
35
|
|
35
36
|
it "should get sorted index" do
|
36
37
|
get :index, :query => 'user1', :sort_by => 'username', :order => 'desc'
|
37
38
|
response.should be_success
|
38
|
-
|
39
|
+
Sunspot.session.should be_a_search_for(Profile)
|
40
|
+
Sunspot.session.should have_search_params(:fulltext, 'user1')
|
41
|
+
Sunspot.session.should have_search_params(:order_by, :username, :desc)
|
42
|
+
assigns(:profiles).should_not be_nil
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
@@ -66,6 +70,12 @@ describe ProfilesController do
|
|
66
70
|
get :show, id: profiles(:admin).id
|
67
71
|
assigns(:profile).should eq(profiles(:admin))
|
68
72
|
end
|
73
|
+
it "assigns the another requested user as @profile" do
|
74
|
+
admin_profile = FactoryGirl.create :admin_profile
|
75
|
+
get :show, id: admin_profile.id
|
76
|
+
expect(response).not_to be_forbidden
|
77
|
+
expect(assigns(:profile)).to eq admin_profile
|
78
|
+
end
|
69
79
|
end
|
70
80
|
|
71
81
|
describe "When logged in as Librarian" do
|
@@ -141,7 +151,7 @@ describe ProfilesController do
|
|
141
151
|
|
142
152
|
it "should not assign the requested user as @profile" do
|
143
153
|
get :new
|
144
|
-
assigns(:profile).
|
154
|
+
assigns(:profile).should be_nil
|
145
155
|
response.should be_forbidden
|
146
156
|
end
|
147
157
|
end
|
@@ -149,7 +159,7 @@ describe ProfilesController do
|
|
149
159
|
describe "When not logged in" do
|
150
160
|
it "should not assign the requested user as @profile" do
|
151
161
|
get :new
|
152
|
-
assigns(:profile).
|
162
|
+
assigns(:profile).should be_nil
|
153
163
|
response.should redirect_to(new_user_session_url)
|
154
164
|
end
|
155
165
|
end
|
@@ -546,8 +556,8 @@ describe ProfilesController do
|
|
546
556
|
|
547
557
|
it "should not be able to delete other librarian user" do
|
548
558
|
librarian = FactoryGirl.create(:librarian_profile)
|
549
|
-
|
550
|
-
|
559
|
+
delete :destroy, id: librarian.id
|
560
|
+
response.should be_forbidden
|
551
561
|
end
|
552
562
|
end
|
553
563
|
|
@@ -18,7 +18,7 @@ describe UserExportFilesController do
|
|
18
18
|
|
19
19
|
it "assigns empty as @user_export_files" do
|
20
20
|
get :index
|
21
|
-
assigns(:user_export_files).should
|
21
|
+
assigns(:user_export_files).should be_nil
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -27,7 +27,7 @@ describe UserExportFilesController do
|
|
27
27
|
|
28
28
|
it "assigns empty as @user_export_files" do
|
29
29
|
get :index
|
30
|
-
assigns(:user_export_files).should
|
30
|
+
assigns(:user_export_files).should be_nil
|
31
31
|
expect(response).to be_forbidden
|
32
32
|
end
|
33
33
|
end
|
@@ -35,7 +35,7 @@ describe UserExportFilesController do
|
|
35
35
|
describe "When not logged in" do
|
36
36
|
it "assigns empty as @user_export_files" do
|
37
37
|
get :index
|
38
|
-
assigns(:user_export_files).should
|
38
|
+
assigns(:user_export_files).should be_nil
|
39
39
|
expect(response).to redirect_to(new_user_session_url)
|
40
40
|
end
|
41
41
|
end
|
@@ -97,7 +97,7 @@ describe UserExportFilesController do
|
|
97
97
|
|
98
98
|
it "should not assign the requested user_export_file as @user_export_file" do
|
99
99
|
get :new
|
100
|
-
assigns(:user_export_file).
|
100
|
+
assigns(:user_export_file).should be_nil
|
101
101
|
expect(response).to be_forbidden
|
102
102
|
end
|
103
103
|
end
|
@@ -107,7 +107,7 @@ describe UserExportFilesController do
|
|
107
107
|
|
108
108
|
it "should not assign the requested user_export_file as @user_export_file" do
|
109
109
|
get :new
|
110
|
-
assigns(:user_export_file).
|
110
|
+
assigns(:user_export_file).should be_nil
|
111
111
|
expect(response).to be_forbidden
|
112
112
|
end
|
113
113
|
end
|
@@ -115,7 +115,7 @@ describe UserExportFilesController do
|
|
115
115
|
describe "When not logged in" do
|
116
116
|
it "should not assign the requested user_export_file as @user_export_file" do
|
117
117
|
get :new
|
118
|
-
assigns(:user_export_file).
|
118
|
+
assigns(:user_export_file).should be_nil
|
119
119
|
expect(response).to redirect_to(new_user_session_url)
|
120
120
|
end
|
121
121
|
end
|
@@ -138,8 +138,7 @@ describe UserExportFilesController do
|
|
138
138
|
|
139
139
|
it "should create agent_export_file" do
|
140
140
|
post :create, user_export_file: {mode: 'export'}
|
141
|
-
assigns(:user_export_file).
|
142
|
-
assigns(:user_export_file).user.should be_nil
|
141
|
+
assigns(:user_export_file).should be_nil
|
143
142
|
expect(response).to be_forbidden
|
144
143
|
end
|
145
144
|
end
|
@@ -149,7 +148,7 @@ describe UserExportFilesController do
|
|
149
148
|
|
150
149
|
it "should be forbidden" do
|
151
150
|
post :create, user_export_file: {mode: 'export'}
|
152
|
-
assigns(:user_export_file).
|
151
|
+
assigns(:user_export_file).should be_nil
|
153
152
|
expect(response).to be_forbidden
|
154
153
|
end
|
155
154
|
end
|
@@ -157,7 +156,7 @@ describe UserExportFilesController do
|
|
157
156
|
describe "When not logged in" do
|
158
157
|
it "should be redirected to new session url" do
|
159
158
|
post :create, user_export_file: {mode: 'export'}
|
160
|
-
assigns(:user_export_file).
|
159
|
+
assigns(:user_export_file).should be_nil
|
161
160
|
expect(response).to redirect_to new_user_session_url
|
162
161
|
end
|
163
162
|
end
|