enju_library 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +47 -0
- data/app/controllers/bookstores_controller.rb +17 -0
- data/app/controllers/budget_types_controller.rb +13 -0
- data/app/controllers/libraries_controller.rb +125 -0
- data/app/controllers/library_groups_controller.rb +46 -0
- data/app/controllers/request_status_types_controller.rb +13 -0
- data/app/controllers/request_types_controller.rb +13 -0
- data/app/controllers/search_engines_controller.rb +17 -0
- data/app/controllers/shelves_controller.rb +138 -0
- data/app/controllers/subscribes_controller.rb +82 -0
- data/app/controllers/subscriptions_controller.rb +87 -0
- data/app/helpers/shelves_helper.rb +13 -0
- data/app/models/bookstore.rb +37 -0
- data/app/models/budget_type.rb +19 -0
- data/app/models/library.rb +131 -0
- data/app/models/library_group.rb +86 -0
- data/app/models/library_group_sweeper.rb +12 -0
- data/app/models/request_status_type.rb +20 -0
- data/app/models/request_type.rb +19 -0
- data/app/models/search_engine.rb +52 -0
- data/app/models/shelf.rb +66 -0
- data/app/models/subscribe.rb +23 -0
- data/app/models/subscription.rb +44 -0
- data/app/views/accepts/_form.html.erb +11 -0
- data/app/views/accepts/_list.html.erb +31 -0
- data/app/views/accepts/edit.html.erb +13 -0
- data/app/views/accepts/index.csv.erb +4 -0
- data/app/views/accepts/index.html.erb +49 -0
- data/app/views/accepts/index.js.erb +1 -0
- data/app/views/accepts/new.html.erb +14 -0
- data/app/views/accepts/show.html.erb +31 -0
- data/app/views/bookstores/_form.html.erb +42 -0
- data/app/views/bookstores/edit.html.erb +13 -0
- data/app/views/bookstores/index.html.erb +49 -0
- data/app/views/bookstores/new.html.erb +12 -0
- data/app/views/bookstores/show.html.erb +52 -0
- data/app/views/budget_types/_form.html.erb +19 -0
- data/app/views/budget_types/edit.html.erb +13 -0
- data/app/views/budget_types/index.html.erb +43 -0
- data/app/views/budget_types/new.html.erb +12 -0
- data/app/views/budget_types/show.html.erb +29 -0
- data/app/views/libraries/_calendar.html.erb +13 -0
- data/app/views/libraries/_form.html.erb +90 -0
- data/app/views/libraries/_map.html.erb +25 -0
- data/app/views/libraries/_map.mobile.erb +25 -0
- data/app/views/libraries/edit.html.erb +13 -0
- data/app/views/libraries/index.html.erb +75 -0
- data/app/views/libraries/new.html.erb +12 -0
- data/app/views/libraries/show.html.erb +131 -0
- data/app/views/libraries/show.mobile.erb +26 -0
- data/app/views/library_groups/_form.html.erb +59 -0
- data/app/views/library_groups/edit.html.erb +12 -0
- data/app/views/library_groups/index.html.erb +30 -0
- data/app/views/library_groups/new.html.erb +12 -0
- data/app/views/library_groups/show.html.erb +66 -0
- data/app/views/request_status_types/_form.html.erb +19 -0
- data/app/views/request_status_types/edit.html.erb +13 -0
- data/app/views/request_status_types/index.html.erb +40 -0
- data/app/views/request_status_types/new.html.erb +12 -0
- data/app/views/request_status_types/show.html.erb +29 -0
- data/app/views/request_types/_form.html.erb +19 -0
- data/app/views/request_types/edit.html.erb +13 -0
- data/app/views/request_types/index.html.erb +40 -0
- data/app/views/request_types/new.html.erb +12 -0
- data/app/views/request_types/show.html.erb +29 -0
- data/app/views/search_engines/_form.html.erb +44 -0
- data/app/views/search_engines/edit.html.erb +13 -0
- data/app/views/search_engines/index.html.erb +44 -0
- data/app/views/search_engines/new.html.erb +12 -0
- data/app/views/search_engines/show.html.erb +49 -0
- data/app/views/shelves/_form.html.erb +37 -0
- data/app/views/shelves/_library_facet.html.erb +12 -0
- data/app/views/shelves/_select_form.html.erb +1 -0
- data/app/views/shelves/edit.html.erb +13 -0
- data/app/views/shelves/index.html.erb +73 -0
- data/app/views/shelves/new.html.erb +18 -0
- data/app/views/shelves/show.html.erb +65 -0
- data/app/views/subscribes/edit.html.erb +37 -0
- data/app/views/subscribes/index.html.erb +31 -0
- data/app/views/subscribes/new.html.erb +48 -0
- data/app/views/subscribes/show.html.erb +34 -0
- data/app/views/subscriptions/edit.html.erb +29 -0
- data/app/views/subscriptions/index.html.erb +39 -0
- data/app/views/subscriptions/new.html.erb +28 -0
- data/app/views/subscriptions/show.html.erb +40 -0
- data/config/routes.rb +17 -0
- data/db/migrate/059_create_libraries.rb +28 -0
- data/db/migrate/069_create_shelves.rb +15 -0
- data/db/migrate/080_create_library_groups.rb +20 -0
- data/db/migrate/124_create_bookstores.rb +17 -0
- data/db/migrate/130_create_request_status_types.rb +12 -0
- data/db/migrate/131_create_request_types.rb +12 -0
- data/db/migrate/20081006090811_create_subscriptions.rb +17 -0
- data/db/migrate/20081006093246_create_subscribes.rb +14 -0
- data/db/migrate/20081023092436_create_search_engines.rb +17 -0
- data/db/migrate/20110222073537_add_url_to_library_group.rb +9 -0
- data/db/migrate/20110620173525_add_bookstore_id_to_item.rb +11 -0
- data/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb +13 -0
- data/db/migrate/20120105074911_add_isil_to_library.rb +5 -0
- data/db/migrate/20120129014038_create_budget_types.rb +12 -0
- data/db/migrate/20120510140958_add_closed_to_shelf.rb +5 -0
- data/lib/enju_library/engine.rb +16 -0
- data/lib/enju_library/master_model.rb +19 -0
- data/lib/enju_library/url_validator.rb +10 -0
- data/lib/enju_library/version.rb +3 -0
- data/lib/enju_library.rb +49 -0
- data/lib/tasks/enju_library_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +56 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/enju_library_test.rb +7 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- metadata +576 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 Kosuke Tanabe
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'EnjuLibrary'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
33
|
+
t.libs << 'lib'
|
34
|
+
t.libs << 'test'
|
35
|
+
t.pattern = 'test/**/*_test.rb'
|
36
|
+
t.verbose = false
|
37
|
+
end
|
38
|
+
|
39
|
+
require 'rspec/core'
|
40
|
+
require 'rspec/core/rake_task'
|
41
|
+
|
42
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
43
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
task :default => :spec
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class BookstoresController < InheritedResources::Base
|
2
|
+
respond_to :html, :json
|
3
|
+
load_and_authorize_resource
|
4
|
+
|
5
|
+
def update
|
6
|
+
@bookstore = Bookstore.find(params[:id])
|
7
|
+
if params[:move]
|
8
|
+
move_position(@bookstore, params[:move])
|
9
|
+
return
|
10
|
+
end
|
11
|
+
update!
|
12
|
+
end
|
13
|
+
|
14
|
+
def index
|
15
|
+
@bookstores = Bookstore.page(params[:page])
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class BudgetTypesController < InheritedResources::Base
|
2
|
+
respond_to :html, :json
|
3
|
+
load_and_authorize_resource
|
4
|
+
|
5
|
+
def update
|
6
|
+
@budget_type = BudgetType.find(params[:id])
|
7
|
+
if params[:move]
|
8
|
+
move_position(@budget_type, params[:move])
|
9
|
+
return
|
10
|
+
end
|
11
|
+
update!
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
class LibrariesController < ApplicationController
|
3
|
+
load_and_authorize_resource
|
4
|
+
after_filter :solr_commit, :only => [:create, :update, :destroy]
|
5
|
+
|
6
|
+
# GET /libraries
|
7
|
+
# GET /libraries.json
|
8
|
+
def index
|
9
|
+
sort = {:sort_by => 'position', :order => 'asc'}
|
10
|
+
case params[:sort_by]
|
11
|
+
when 'name'
|
12
|
+
sort[:sort_by] = 'name'
|
13
|
+
end
|
14
|
+
sort[:order] = 'desc' if params[:order] == 'desc'
|
15
|
+
|
16
|
+
query = @query = params[:query].to_s.strip
|
17
|
+
page = params[:page] || 1
|
18
|
+
|
19
|
+
@libraries = Library.search(:include => [:shelves]) do
|
20
|
+
fulltext query if query.present?
|
21
|
+
paginate :page => page.to_i, :per_page => Library.per_page
|
22
|
+
order_by sort[:sort_by], sort[:order]
|
23
|
+
end.results
|
24
|
+
|
25
|
+
respond_to do |format|
|
26
|
+
format.html # index.html.erb
|
27
|
+
format.json { render :json => @libraries }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# GET /libraries/1
|
32
|
+
# GET /libraries/1.json
|
33
|
+
def show
|
34
|
+
if defined?(EnjuEvent)
|
35
|
+
search = Sunspot.new_search(Event)
|
36
|
+
library = @library.dup
|
37
|
+
search.build do
|
38
|
+
with(:library_id).equal_to library.id
|
39
|
+
order_by(:start_at, :desc)
|
40
|
+
end
|
41
|
+
page = params[:event_page] || 1
|
42
|
+
search.query.paginate(page.to_i, Event.per_page)
|
43
|
+
@events = search.execute!.results
|
44
|
+
end
|
45
|
+
|
46
|
+
respond_to do |format|
|
47
|
+
format.html # show.html.erb
|
48
|
+
format.json { render :json => @library }
|
49
|
+
format.js
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# GET /libraries/new
|
54
|
+
def new
|
55
|
+
@library = Library.new
|
56
|
+
@library.country = LibraryGroup.site_config.country
|
57
|
+
prepare_options
|
58
|
+
|
59
|
+
respond_to do |format|
|
60
|
+
format.html # new.html.erb
|
61
|
+
format.json { render :json => @library }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# GET /libraries/1/edit
|
66
|
+
def edit
|
67
|
+
prepare_options
|
68
|
+
end
|
69
|
+
|
70
|
+
# POST /libraries
|
71
|
+
# POST /libraries.json
|
72
|
+
def create
|
73
|
+
#patron = Patron.create(:name => params[:library][:name], :patron_type => 'CorporateBody')
|
74
|
+
@library = Library.new(params[:library])
|
75
|
+
|
76
|
+
respond_to do |format|
|
77
|
+
if @library.save
|
78
|
+
format.html { redirect_to @library, :notice => t('controller.successfully_created', :model => t('activerecord.models.library')) }
|
79
|
+
format.json { render :json => @library, :status => :created }
|
80
|
+
else
|
81
|
+
prepare_options
|
82
|
+
format.html { render :action => "new" }
|
83
|
+
format.json { render :json => @library.errors, :status => :unprocessable_entity }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# PUT /libraries/1
|
89
|
+
# PUT /libraries/1.json
|
90
|
+
def update
|
91
|
+
if params[:move]
|
92
|
+
move_position(@library, params[:move])
|
93
|
+
return
|
94
|
+
end
|
95
|
+
|
96
|
+
respond_to do |format|
|
97
|
+
if @library.update_attributes(params[:library])
|
98
|
+
format.html { redirect_to @library, :notice => t('controller.successfully_updated', :model => t('activerecord.models.library')) }
|
99
|
+
format.json { head :no_content }
|
100
|
+
else
|
101
|
+
@library.name = @library.name_was
|
102
|
+
prepare_options
|
103
|
+
format.html { render :action => "edit" }
|
104
|
+
format.json { render :json => @library.errors, :status => :unprocessable_entity }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# DELETE /libraries/1
|
110
|
+
# DELETE /libraries/1.json
|
111
|
+
def destroy
|
112
|
+
@library.destroy
|
113
|
+
|
114
|
+
respond_to do |format|
|
115
|
+
format.html { redirect_to libraries_url }
|
116
|
+
format.json { head :no_content }
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
def prepare_options
|
122
|
+
@library_groups = LibraryGroup.all
|
123
|
+
@countries = Country.all_cache
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
class LibraryGroupsController < ApplicationController
|
3
|
+
load_and_authorize_resource
|
4
|
+
cache_sweeper :library_group_sweeper, :only => [:update]
|
5
|
+
|
6
|
+
# GET /library_groups
|
7
|
+
# GET /library_groups.json
|
8
|
+
def index
|
9
|
+
@library_groups = LibraryGroup.all
|
10
|
+
|
11
|
+
respond_to do |format|
|
12
|
+
format.html # index.html.erb
|
13
|
+
format.json { render :json => @library_groups }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# GET /library_groups/1
|
18
|
+
# GET /library_groups/1.json
|
19
|
+
def show
|
20
|
+
respond_to do |format|
|
21
|
+
format.html # show.html.erb
|
22
|
+
format.json { render :json => @library_group }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# GET /library_groups/1/edit
|
27
|
+
def edit
|
28
|
+
@countries = Country.all
|
29
|
+
end
|
30
|
+
|
31
|
+
# PUT /library_groups/1
|
32
|
+
# PUT /library_groups/1.json
|
33
|
+
def update
|
34
|
+
respond_to do |format|
|
35
|
+
if @library_group.update_attributes(params[:library_group])
|
36
|
+
expire_page '/page/opensearch'
|
37
|
+
format.html { redirect_to @library_group, :notice => t('controller.successfully_updated', :model => t('activerecord.models.library_group')) }
|
38
|
+
format.json { head :no_content }
|
39
|
+
else
|
40
|
+
@countries = Country.all
|
41
|
+
format.html { render :action => "edit" }
|
42
|
+
format.json { render :json => @library_group.errors, :status => :unprocessable_entity }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class RequestStatusTypesController < InheritedResources::Base
|
2
|
+
respond_to :html, :json
|
3
|
+
load_and_authorize_resource
|
4
|
+
|
5
|
+
def update
|
6
|
+
@request_status_type = RequestStatusType.find(params[:id])
|
7
|
+
if params[:move]
|
8
|
+
move_position(@request_status_type, params[:move])
|
9
|
+
return
|
10
|
+
end
|
11
|
+
update!
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class RequestTypesController < InheritedResources::Base
|
2
|
+
respond_to :html, :json
|
3
|
+
load_and_authorize_resource
|
4
|
+
|
5
|
+
def update
|
6
|
+
@request_type = RequestType.find(params[:id])
|
7
|
+
if params[:move]
|
8
|
+
move_position(@request_type, params[:move])
|
9
|
+
return
|
10
|
+
end
|
11
|
+
update!
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class SearchEnginesController < InheritedResources::Base
|
2
|
+
respond_to :html, :json
|
3
|
+
load_and_authorize_resource
|
4
|
+
|
5
|
+
def update
|
6
|
+
@search_engine = SearchEngine.find(params[:id])
|
7
|
+
if params[:move]
|
8
|
+
move_position(@search_engine, params[:move])
|
9
|
+
return
|
10
|
+
end
|
11
|
+
update!
|
12
|
+
end
|
13
|
+
|
14
|
+
def index
|
15
|
+
@search_engines = @search_engines.page(params[:page])
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
class ShelvesController < ApplicationController
|
2
|
+
load_and_authorize_resource
|
3
|
+
before_filter :get_library
|
4
|
+
before_filter :get_libraries, :only => [:new, :edit, :create, :update]
|
5
|
+
|
6
|
+
# GET /shelves
|
7
|
+
# GET /shelves.json
|
8
|
+
def index
|
9
|
+
if params[:mode] == 'select'
|
10
|
+
if @library
|
11
|
+
@shelves = @library.shelves
|
12
|
+
else
|
13
|
+
@shelves = Shelf.real
|
14
|
+
end
|
15
|
+
render :partial => 'select_form'
|
16
|
+
return
|
17
|
+
else
|
18
|
+
sort = {:sort_by => 'name', :order => 'asc'}
|
19
|
+
#case params[:sort_by]
|
20
|
+
#when 'name'
|
21
|
+
# sort[:sort_by] = 'name'
|
22
|
+
#end
|
23
|
+
sort[:order] = 'desc' if params[:order] == 'desc'
|
24
|
+
|
25
|
+
query = @query = params[:query].to_s.strip
|
26
|
+
page = params[:page] || 1
|
27
|
+
library = @library if @library
|
28
|
+
|
29
|
+
search = Shelf.search(:include => [:library]) do
|
30
|
+
fulltext query if query.present?
|
31
|
+
paginate :page => page.to_i, :per_page => Shelf.per_page
|
32
|
+
if library
|
33
|
+
with(:library).equal_to library.name
|
34
|
+
order_by :position, :asc
|
35
|
+
end
|
36
|
+
order_by sort[:sort_by], sort[:order]
|
37
|
+
facet :library
|
38
|
+
end
|
39
|
+
@shelves = search.results
|
40
|
+
@library_facet = search.facet(:library).rows
|
41
|
+
@library_names = Library.select(:name).collect(&:name)
|
42
|
+
end
|
43
|
+
|
44
|
+
respond_to do |format|
|
45
|
+
format.html # index.html.erb
|
46
|
+
format.json { render :json => @shelves }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# GET /shelves/1
|
51
|
+
# GET /shelves/1.json
|
52
|
+
def show
|
53
|
+
@shelf = Shelf.find(params[:id], :include => :library)
|
54
|
+
|
55
|
+
respond_to do |format|
|
56
|
+
format.html # show.html.erb
|
57
|
+
format.json { render :json => @shelf }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# GET /shelves/new
|
62
|
+
# GET /shelves/new.json
|
63
|
+
def new
|
64
|
+
@library = Library.web if @library.nil?
|
65
|
+
@shelf = Shelf.new
|
66
|
+
@shelf.library = @library
|
67
|
+
#@shelf.user = current_user
|
68
|
+
|
69
|
+
respond_to do |format|
|
70
|
+
format.html # new.html.erb
|
71
|
+
format.json { render :json => @shelf }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# GET /shelves/1/edit
|
76
|
+
def edit
|
77
|
+
@shelf = Shelf.find(params[:id], :include => :library)
|
78
|
+
end
|
79
|
+
|
80
|
+
# POST /shelves
|
81
|
+
# POST /shelves.json
|
82
|
+
def create
|
83
|
+
@shelf = Shelf.new(params[:shelf])
|
84
|
+
if @library
|
85
|
+
@shelf.library = @library
|
86
|
+
else
|
87
|
+
@shelf.library = Library.web #unless current_user.has_role?('Librarian')
|
88
|
+
end
|
89
|
+
|
90
|
+
respond_to do |format|
|
91
|
+
if @shelf.save
|
92
|
+
format.html { redirect_to @shelf, :notice => t('controller.successfully_created', :model => t('activerecord.models.shelf')) }
|
93
|
+
format.json { render :json => @shelf, :status => :created, :location => @shelf }
|
94
|
+
else
|
95
|
+
@library = Library.first if @shelf.library.nil?
|
96
|
+
format.html { render :action => "new" }
|
97
|
+
format.json { render :json => @shelf.errors, :status => :unprocessable_entity }
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# PUT /shelves/1
|
103
|
+
# PUT /shelves/1.json
|
104
|
+
def update
|
105
|
+
@shelf.library = @library if @library
|
106
|
+
|
107
|
+
if params[:move]
|
108
|
+
move_position(@shelf, params[:move], false)
|
109
|
+
redirect_to library_shelves_url(@shelf.library)
|
110
|
+
return
|
111
|
+
end
|
112
|
+
|
113
|
+
respond_to do |format|
|
114
|
+
if @shelf.update_attributes(params[:shelf])
|
115
|
+
format.html { redirect_to @shelf, :notice => t('controller.successfully_updated', :model => t('activerecord.models.shelf')) }
|
116
|
+
format.json { head :no_content }
|
117
|
+
else
|
118
|
+
@library = Library.first if @library.nil?
|
119
|
+
format.html { render :action => "edit" }
|
120
|
+
format.json { render :json => @shelf.errors, :status => :unprocessable_entity }
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# DELETE /shelves/1
|
126
|
+
# DELETE /shelves/1.json
|
127
|
+
def destroy
|
128
|
+
if @shelf.id == 1
|
129
|
+
access_denied; return
|
130
|
+
end
|
131
|
+
@shelf.destroy
|
132
|
+
|
133
|
+
respond_to do |format|
|
134
|
+
format.html { redirect_to shelves_url }
|
135
|
+
format.json { head :no_content }
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
class SubscribesController < ApplicationController
|
2
|
+
load_and_authorize_resource
|
3
|
+
before_filter :get_subscription, :get_work
|
4
|
+
|
5
|
+
# GET /subscribes
|
6
|
+
# GET /subscribes.json
|
7
|
+
def index
|
8
|
+
@subscribes = Subscribe.page(params[:page])
|
9
|
+
|
10
|
+
respond_to do |format|
|
11
|
+
format.html # index.html.erb
|
12
|
+
format.json { render :json => @subscribes }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# GET /subscribes/1
|
17
|
+
# GET /subscribes/1.json
|
18
|
+
def show
|
19
|
+
respond_to do |format|
|
20
|
+
format.html # show.html.erb
|
21
|
+
format.json { render :json => @subscribe }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /subscribes/new
|
26
|
+
# GET /subscribes/new.json
|
27
|
+
def new
|
28
|
+
@subscribe = Subscribe.new
|
29
|
+
@subscribe.subscription = @subscription if @subscription
|
30
|
+
@subscribe.work = @work if @work
|
31
|
+
|
32
|
+
respond_to do |format|
|
33
|
+
format.html # new.html.erb
|
34
|
+
format.json { render :json => @subscribe }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# GET /subscribes/1/edit
|
39
|
+
def edit
|
40
|
+
end
|
41
|
+
|
42
|
+
# POST /subscribes
|
43
|
+
# POST /subscribes.json
|
44
|
+
def create
|
45
|
+
@subscribe = Subscribe.new(params[:subscribe])
|
46
|
+
|
47
|
+
respond_to do |format|
|
48
|
+
if @subscribe.save
|
49
|
+
format.html { redirect_to @subscribe, :notice => t('controller.successfully_created', :model => t('activerecord.models.subscribe')) }
|
50
|
+
format.json { render :json => @subscribe, :status => :created, :location => @subscribe }
|
51
|
+
else
|
52
|
+
format.html { render :action => "new" }
|
53
|
+
format.json { render :json => @subscribe.errors, :status => :unprocessable_entity }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# PUT /subscribes/1
|
59
|
+
# PUT /subscribes/1.json
|
60
|
+
def update
|
61
|
+
respond_to do |format|
|
62
|
+
if @subscribe.update_attributes(params[:subscribe])
|
63
|
+
format.html { redirect_to @subscribe, :notice => t('controller.successfully_updated', :model => t('activerecord.models.subscribe')) }
|
64
|
+
format.json { head :no_content }
|
65
|
+
else
|
66
|
+
format.html { render :action => "edit" }
|
67
|
+
format.json { render :json => @subscribe.errors, :status => :unprocessable_entity }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# DELETE /subscribes/1
|
73
|
+
# DELETE /subscribes/1.json
|
74
|
+
def destroy
|
75
|
+
@subscribe.destroy
|
76
|
+
|
77
|
+
respond_to do |format|
|
78
|
+
format.html { redirect_to subscribes_url }
|
79
|
+
format.json { head :no_content }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
class SubscriptionsController < ApplicationController
|
2
|
+
load_and_authorize_resource
|
3
|
+
before_filter :get_work
|
4
|
+
after_filter :solr_commit, :only => [:create, :update, :destroy]
|
5
|
+
|
6
|
+
# GET /subscriptions
|
7
|
+
# GET /subscriptions.json
|
8
|
+
def index
|
9
|
+
if @work
|
10
|
+
@subscriptions = @work.subscriptions.page(params[:page])
|
11
|
+
else
|
12
|
+
@subscriptions = Subscription.page(params[:page])
|
13
|
+
end
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html # index.html.erb
|
17
|
+
format.json { render :json => @subscriptions }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# GET /subscriptions/1
|
22
|
+
# GET /subscriptions/1.json
|
23
|
+
def show
|
24
|
+
respond_to do |format|
|
25
|
+
format.html # show.html.erb
|
26
|
+
format.json { render :json => @subscription }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# GET /subscriptions/new
|
31
|
+
# GET /subscriptions/new.json
|
32
|
+
def new
|
33
|
+
@subscription = Subscription.new
|
34
|
+
|
35
|
+
respond_to do |format|
|
36
|
+
format.html # new.html.erb
|
37
|
+
format.json { render :json => @subscription }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# GET /subscriptions/1/edit
|
42
|
+
def edit
|
43
|
+
end
|
44
|
+
|
45
|
+
# POST /subscriptions
|
46
|
+
# POST /subscriptions.json
|
47
|
+
def create
|
48
|
+
@subscription = Subscription.new(params[:subscription])
|
49
|
+
@subscription.user = current_user
|
50
|
+
|
51
|
+
respond_to do |format|
|
52
|
+
if @subscription.save
|
53
|
+
format.html { redirect_to @subscription, :notice => t('controller.successfully_created', :model => t('activerecord.models.subscription')) }
|
54
|
+
format.json { render :json => @subscription, :status => :created, :location => @subscription }
|
55
|
+
else
|
56
|
+
format.html { render :action => "new" }
|
57
|
+
format.json { render :json => @subscription.errors, :status => :unprocessable_entity }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# PUT /subscriptions/1
|
63
|
+
# PUT /subscriptions/1.json
|
64
|
+
def update
|
65
|
+
@subscription.assign_attributes(params[:subscription])
|
66
|
+
respond_to do |format|
|
67
|
+
if @subscription.save
|
68
|
+
format.html { redirect_to @subscription, :notice => t('controller.successfully_updated', :model => t('activerecord.models.subscription')) }
|
69
|
+
format.json { head :no_content }
|
70
|
+
else
|
71
|
+
format.html { render :action => "edit" }
|
72
|
+
format.json { render :json => @subscription.errors, :status => :unprocessable_entity }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# DELETE /subscriptions/1
|
78
|
+
# DELETE /subscriptions/1.json
|
79
|
+
def destroy
|
80
|
+
@subscription.destroy
|
81
|
+
|
82
|
+
respond_to do |format|
|
83
|
+
format.html { redirect_to subscriptions_url }
|
84
|
+
format.json { head :no_content }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ShelvesHelper
|
2
|
+
def library_shelf_facet(library, current_library, facet)
|
3
|
+
string = ''
|
4
|
+
current = true if current_library.try(:name) == library.name
|
5
|
+
if current
|
6
|
+
content_tag :strong do
|
7
|
+
link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(params.merge(:page => nil, :library_id => library.name, :only_path => true)))
|
8
|
+
end
|
9
|
+
else
|
10
|
+
link_to("#{library.display_name.localize} (" + facet.count.to_s + ")", url_for(params.merge(:page => nil, :library_id => library.name, :only_path => true)))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Bookstore < ActiveRecord::Base
|
2
|
+
attr_accessible :name, :zip_code, :address, :note, :telephone_number,
|
3
|
+
:fax_number, :url
|
4
|
+
default_scope :order => "bookstores.position"
|
5
|
+
has_many :items
|
6
|
+
|
7
|
+
acts_as_list
|
8
|
+
validates_presence_of :name
|
9
|
+
validates :url, :url => true, :allow_blank => true, :length => {:maximum => 255}
|
10
|
+
|
11
|
+
def self.per_page
|
12
|
+
10
|
13
|
+
end
|
14
|
+
|
15
|
+
if defined?(EnjuPurchaseRequest)
|
16
|
+
has_many :order_lists
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# == Schema Information
|
21
|
+
#
|
22
|
+
# Table name: bookstores
|
23
|
+
#
|
24
|
+
# id :integer not null, primary key
|
25
|
+
# name :text not null
|
26
|
+
# zip_code :string(255)
|
27
|
+
# address :text
|
28
|
+
# note :text
|
29
|
+
# telephone_number :string(255)
|
30
|
+
# fax_number :string(255)
|
31
|
+
# url :string(255)
|
32
|
+
# position :integer
|
33
|
+
# deleted_at :datetime
|
34
|
+
# created_at :datetime
|
35
|
+
# updated_at :datetime
|
36
|
+
#
|
37
|
+
|