enju_bookmark 0.1.2.pre14 → 0.1.2.pre15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/bookmark_stat_has_manifestations_controller.rb +12 -12
- data/app/controllers/bookmark_stats_controller.rb +13 -13
- data/app/controllers/bookmarks_controller.rb +18 -19
- data/app/controllers/tags_controller.rb +6 -7
- data/app/models/bookmark.rb +12 -12
- data/app/models/bookmark_stat.rb +20 -12
- data/app/models/bookmark_stat_has_manifestation.rb +2 -2
- data/app/models/bookmark_stat_state_machine.rb +13 -0
- data/app/models/bookmark_stat_transition.rb +20 -0
- data/app/models/tag.rb +5 -5
- data/app/views/bookmark_stat_has_manifestations/edit.html.erb +3 -3
- data/app/views/bookmark_stat_has_manifestations/index.html.erb +5 -5
- data/app/views/bookmark_stat_has_manifestations/new.html.erb +3 -3
- data/app/views/bookmark_stat_has_manifestations/show.html.erb +3 -3
- data/app/views/bookmark_stats/edit.html.erb +3 -3
- data/app/views/bookmark_stats/index.html.erb +6 -6
- data/app/views/bookmark_stats/new.html.erb +3 -3
- data/app/views/bookmark_stats/show.html.erb +6 -6
- data/app/views/bookmarks/_index.html.erb +8 -8
- data/app/views/bookmarks/_index_user.html.erb +9 -9
- data/app/views/bookmarks/_tag_cloud.html.erb +1 -1
- data/app/views/bookmarks/edit.html.erb +8 -8
- data/app/views/bookmarks/new.html.erb +7 -7
- data/app/views/bookmarks/show.html.erb +7 -7
- data/app/views/manifestations/_bookmarks_for_this_manifestation.html.erb +3 -3
- data/app/views/manifestations/_show_tag.html.erb +1 -1
- data/app/views/manifestations/_tag_edit.html.erb +8 -8
- data/app/views/manifestations/_tag_list.html.erb +2 -2
- data/app/views/tags/edit.html.erb +5 -5
- data/app/views/tags/index.atom.builder +2 -2
- data/app/views/tags/index.html.erb +8 -8
- data/app/views/tags/index.rss.builder +5 -5
- data/app/views/tags/show.html.erb +6 -6
- data/config/routes.rb +0 -3
- data/db/migrate/20081212151614_create_bookmark_stats.rb +0 -3
- data/db/migrate/20140812093836_add_share_bookmarks_to_profile.rb +5 -0
- data/lib/enju_bookmark.rb +2 -0
- data/lib/enju_bookmark/engine.rb +1 -1
- data/lib/enju_bookmark/profile.rb +13 -0
- data/lib/enju_bookmark/user.rb +2 -0
- data/lib/enju_bookmark/version.rb +1 -1
- data/spec/controllers/bookmark_stat_has_manifestations_controller_spec.rb +21 -21
- data/spec/controllers/bookmark_stats_controller_spec.rb +21 -21
- data/spec/controllers/bookmarks_controller_spec.rb +5 -11
- data/spec/controllers/tags_controller_spec.rb +15 -15
- data/spec/dummy/config/initializers/statesman.rb +3 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/001_create_agents.rb +0 -3
- data/spec/dummy/db/migrate/005_create_manifestations.rb +7 -19
- data/spec/dummy/db/migrate/006_create_items.rb +0 -3
- data/spec/dummy/db/migrate/041_create_roles.rb +13 -0
- data/spec/dummy/db/migrate/20081028083142_create_agent_import_files.rb +0 -2
- data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +1 -3
- data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +0 -1
- data/spec/dummy/db/migrate/{20111201163718_create_user_has_roles.rb → 20100606065209_create_user_has_roles.rb} +2 -0
- data/spec/dummy/db/migrate/20110318183304_add_valid_period_for_new_user_to_user_group.rb +0 -2
- data/spec/dummy/db/migrate/20121116031206_add_fulltext_content_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20121116033446_add_doi_to_manifestation.rb +6 -0
- data/spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb +1 -11
- data/spec/dummy/db/migrate/20130421093852_add_periodical_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20130421155019_add_creator_string_to_series_statement.rb +7 -0
- data/spec/dummy/db/migrate/20130421164124_add_series_master_to_series_statement.rb +5 -0
- data/spec/dummy/db/migrate/20130429020822_add_root_manifestation_id_to_series_statement.rb +6 -0
- data/spec/dummy/db/migrate/{20111201121844_create_roles.rb → 20130506175303_create_identifier_types.rb} +2 -2
- data/spec/dummy/db/migrate/20130506175834_create_identifiers.rb +15 -0
- data/spec/dummy/db/migrate/20130509185724_add_statement_of_responsibility_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +18 -0
- data/spec/dummy/db/migrate/20140110131010_create_user_import_results.rb +11 -0
- data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +20 -0
- data/spec/dummy/db/migrate/20140519170214_create_resource_import_file_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140519171220_create_import_request_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140524020735_create_agent_import_file_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140610123439_drop_email_unique_constraint_enju_leaf_rc10.rb +11 -0
- data/spec/dummy/db/migrate/20140614065404_create_resource_export_files.rb +11 -0
- data/spec/dummy/db/migrate/20140614141500_create_resource_export_file_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140628073524_add_user_encoding_to_agent_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140628073535_add_user_encoding_to_resource_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +11 -0
- data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140720140916_add_binding_item_identifier_to_item.rb +8 -0
- data/spec/dummy/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +5 -0
- data/spec/dummy/db/migrate/20140721151416_add_default_shelf_id_to_resource_import_file.rb +5 -0
- data/spec/dummy/db/migrate/{20121119153944_add_manifestation_id_to_item.rb → 20140802082007_add_manifestation_id_to_item.rb} +1 -0
- data/spec/dummy/db/schema.rb +215 -55
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/solr/default/data/index/segments.gen +0 -0
- data/spec/dummy/solr/default/data/index/segments_1bi +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001699 +0 -0
- data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000000905 → tlog.0000000000000001700} +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001701 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001702 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001703 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001704 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001705 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001706 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001707 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000001708 +0 -0
- data/spec/factories/profile.rb +10 -0
- data/spec/factories/user.rb +0 -13
- data/spec/fixtures/agents.yml +0 -12
- data/spec/fixtures/bookmark_stats.yml +0 -4
- data/spec/fixtures/items.yml +60 -21
- data/spec/fixtures/manifestations.yml +42 -178
- data/spec/fixtures/profiles.yml +99 -0
- data/spec/fixtures/users.yml +3 -29
- data/spec/models/bookmark_spec.rb +1 -1
- data/spec/models/bookmark_stat_spec.rb +1 -3
- data/spec/spec_helper.rb +2 -0
- metadata +117 -42
- data/app/models/bookmark_sweeper.rb +0 -21
- data/spec/dummy/db/migrate/20110916053430_rename_manifestation_number_list_to_number_string.rb +0 -13
- data/spec/dummy/db/migrate/20120415060308_rename_resource_import_file_imported_at_to_executed_at.rb +0 -9
- data/spec/dummy/solr/default/data/index/segments_pf +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000904 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000906 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000907 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000908 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000909 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000910 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000911 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000912 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000913 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 597585d3b39392f7465ae13a8dc80e8623d94c25
|
4
|
+
data.tar.gz: 07ab6bca2ef50010e713b9174cbd0fc350d94adf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74bdf38277422a83a639401a630e86f8c60ff059b5c4105e928e167e9dfd1d95118a4e32063bb812b433b08524d8eacfd17b832bb9c544f78c44f181b52fc46f
|
7
|
+
data.tar.gz: b6da333ffed0d4ddaabac3e24767d2968aedd731d1a4d9ce7a5788fccf4e3f08abc68bb46fcc586e692f7712799eaf495296d78349d139f96939bb0bf8ccd896
|
@@ -8,7 +8,7 @@ class BookmarkStatHasManifestationsController < ApplicationController
|
|
8
8
|
|
9
9
|
respond_to do |format|
|
10
10
|
format.html # index.html.erb
|
11
|
-
format.json { render :
|
11
|
+
format.json { render json: @bookmark_stat_has_manifestations }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
@@ -17,7 +17,7 @@ class BookmarkStatHasManifestationsController < ApplicationController
|
|
17
17
|
def show
|
18
18
|
respond_to do |format|
|
19
19
|
format.html # show.html.erb
|
20
|
-
format.json { render :
|
20
|
+
format.json { render json: @bookmark_stat_has_manifestation }
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -28,7 +28,7 @@ class BookmarkStatHasManifestationsController < ApplicationController
|
|
28
28
|
|
29
29
|
respond_to do |format|
|
30
30
|
format.html # new.html.erb
|
31
|
-
format.json { render :
|
31
|
+
format.json { render json: @bookmark_stat_has_manifestation }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -40,15 +40,15 @@ class BookmarkStatHasManifestationsController < ApplicationController
|
|
40
40
|
# POST /bookmark_stat_has_manifestations.json
|
41
41
|
def create
|
42
42
|
@bookmark_stat_has_manifestation = BookmarkStatHasManifestation.new
|
43
|
-
@bookmark_stat_has_manifestation.assign_attributes(params[:bookmark_stat_has_manifestation], :
|
43
|
+
@bookmark_stat_has_manifestation.assign_attributes(params[:bookmark_stat_has_manifestation], as: :admin)
|
44
44
|
|
45
45
|
respond_to do |format|
|
46
46
|
if @bookmark_stat_has_manifestation.save
|
47
|
-
format.html { redirect_to @bookmark_stat_has_manifestation, :
|
48
|
-
format.json { render :
|
47
|
+
format.html { redirect_to @bookmark_stat_has_manifestation, notice: t('controller.successfully_created', model: t('activerecord.models.bookmark_stat_has_manifestation')) }
|
48
|
+
format.json { render json: @bookmark_stat_has_manifestation, status: :created, location: @bookmark_stat_has_manifestation }
|
49
49
|
else
|
50
|
-
format.html { render :
|
51
|
-
format.json { render :
|
50
|
+
format.html { render action: "new" }
|
51
|
+
format.json { render json: @bookmark_stat_has_manifestation.errors, status: :unprocessable_entity }
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -56,14 +56,14 @@ class BookmarkStatHasManifestationsController < ApplicationController
|
|
56
56
|
# PUT /bookmark_stat_has_manifestations/1
|
57
57
|
# PUT /bookmark_stat_has_manifestations/1.json
|
58
58
|
def update
|
59
|
-
@bookmark_stat_has_manifestation.assign_attributes(params[:bookmark_stat_has_manifestation], :
|
59
|
+
@bookmark_stat_has_manifestation.assign_attributes(params[:bookmark_stat_has_manifestation], as: :admin)
|
60
60
|
respond_to do |format|
|
61
61
|
if @bookmark_stat_has_manifestation.save
|
62
|
-
format.html { redirect_to @bookmark_stat_has_manifestation, :
|
62
|
+
format.html { redirect_to @bookmark_stat_has_manifestation, notice: t('controller.successfully_updated', model: t('activerecord.models.bookmark_stat_has_manifestation')) }
|
63
63
|
format.json { head :no_content }
|
64
64
|
else
|
65
|
-
format.html { render :
|
66
|
-
format.json { render :
|
65
|
+
format.html { render action: "edit" }
|
66
|
+
format.json { render json: @bookmark_stat_has_manifestation.errors, status: :unprocessable_entity }
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class BookmarkStatsController < ApplicationController
|
2
2
|
load_and_authorize_resource
|
3
|
-
after_filter :convert_charset, :
|
3
|
+
after_filter :convert_charset, only: :show
|
4
4
|
|
5
5
|
# GET /bookmark_stats
|
6
6
|
# GET /bookmark_stats.json
|
@@ -9,14 +9,14 @@ class BookmarkStatsController < ApplicationController
|
|
9
9
|
|
10
10
|
respond_to do |format|
|
11
11
|
format.html # index.html.erb
|
12
|
-
format.json { render :
|
12
|
+
format.json { render json: @bookmark_stats }
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
# GET /bookmark_stats/1
|
17
17
|
# GET /bookmark_stats/1.json
|
18
18
|
def show
|
19
|
-
if params[:format] == '
|
19
|
+
if params[:format] == 'txt'
|
20
20
|
per_page = 65534
|
21
21
|
else
|
22
22
|
per_page = BookmarkStatHasManifestation.default_per_page
|
@@ -25,8 +25,8 @@ class BookmarkStatsController < ApplicationController
|
|
25
25
|
|
26
26
|
respond_to do |format|
|
27
27
|
format.html # show.html.erb
|
28
|
-
format.json { render :
|
29
|
-
format.
|
28
|
+
format.json { render json: @bookmark_stat }
|
29
|
+
format.txt
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -37,7 +37,7 @@ class BookmarkStatsController < ApplicationController
|
|
37
37
|
|
38
38
|
respond_to do |format|
|
39
39
|
format.html # new.html.erb
|
40
|
-
format.json { render :
|
40
|
+
format.json { render json: @bookmark_stat }
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -52,11 +52,11 @@ class BookmarkStatsController < ApplicationController
|
|
52
52
|
|
53
53
|
respond_to do |format|
|
54
54
|
if @bookmark_stat.save
|
55
|
-
format.html { redirect_to @bookmark_stat, :
|
56
|
-
format.json { render :
|
55
|
+
format.html { redirect_to @bookmark_stat, notice: t('controller.successfully_created', model: t('activerecord.models.bookmark_stat')) }
|
56
|
+
format.json { render json: @bookmark_stat, status: :created, location: @bookmark_stat }
|
57
57
|
else
|
58
|
-
format.html { render :
|
59
|
-
format.json { render :
|
58
|
+
format.html { render action: "new" }
|
59
|
+
format.json { render json: @bookmark_stat.errors, status: :unprocessable_entity }
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -66,11 +66,11 @@ class BookmarkStatsController < ApplicationController
|
|
66
66
|
def update
|
67
67
|
respond_to do |format|
|
68
68
|
if @bookmark_stat.update_attributes(params[:bookmark_stat])
|
69
|
-
format.html { redirect_to @bookmark_stat, :
|
69
|
+
format.html { redirect_to @bookmark_stat, notice: t('controller.successfully_updated', model: t('activerecord.models.bookmark_stat')) }
|
70
70
|
format.json { head :no_content }
|
71
71
|
else
|
72
|
-
format.html { render :
|
73
|
-
format.json { render :
|
72
|
+
format.html { render action: "edit" }
|
73
|
+
format.json { render json: @bookmark_stat.errors, status: :unprocessable_entity }
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
class BookmarksController < ApplicationController
|
3
3
|
before_filter :store_location
|
4
|
-
load_and_authorize_resource :
|
5
|
-
authorize_resource :
|
6
|
-
before_filter :get_user, :
|
7
|
-
after_filter :solr_commit, :
|
8
|
-
cache_sweeper :bookmark_sweeper, :only => [:create, :update, :destroy]
|
4
|
+
load_and_authorize_resource except: :index
|
5
|
+
authorize_resource only: :index
|
6
|
+
before_filter :get_user, only: :index
|
7
|
+
after_filter :solr_commit, only: [:create, :update, :destroy]
|
9
8
|
|
10
9
|
# GET /bookmarks
|
11
10
|
# GET /bookmarks.json
|
@@ -17,7 +16,7 @@ class BookmarksController < ApplicationController
|
|
17
16
|
end
|
18
17
|
user = @user
|
19
18
|
unless current_user.has_role?('Librarian')
|
20
|
-
if user and user != current_user and !user.try(:share_bookmarks)
|
19
|
+
if user and user != current_user and !user.profile.try(:share_bookmarks)
|
21
20
|
access_denied; return
|
22
21
|
end
|
23
22
|
if current_user == @user
|
@@ -42,7 +41,7 @@ class BookmarksController < ApplicationController
|
|
42
41
|
|
43
42
|
respond_to do |format|
|
44
43
|
format.html # index.html.erb
|
45
|
-
format.json { render :
|
44
|
+
format.json { render json: @bookmarks }
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
@@ -51,7 +50,7 @@ class BookmarksController < ApplicationController
|
|
51
50
|
def show
|
52
51
|
respond_to do |format|
|
53
52
|
format.html # show.html.erb
|
54
|
-
format.json { render :
|
53
|
+
format.json { render json: @bookmark }
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
@@ -82,20 +81,20 @@ class BookmarksController < ApplicationController
|
|
82
81
|
|
83
82
|
respond_to do |format|
|
84
83
|
if @bookmark.save
|
85
|
-
flash[:notice] = t('controller.successfully_created', :
|
84
|
+
flash[:notice] = t('controller.successfully_created', model: t('activerecord.models.bookmark'))
|
86
85
|
@bookmark.create_tag_index
|
87
86
|
@bookmark.manifestation.index!
|
88
87
|
if params[:mode] == 'tag_edit'
|
89
88
|
format.html { redirect_to(@bookmark.manifestation) }
|
90
|
-
format.json { render :
|
89
|
+
format.json { render json: @bookmark, status: :created, location: @bookmark }
|
91
90
|
else
|
92
91
|
format.html { redirect_to(@bookmark) }
|
93
|
-
format.json { render :
|
92
|
+
format.json { render json: @bookmark, status: :created, location: @bookmark }
|
94
93
|
end
|
95
94
|
else
|
96
95
|
@user = current_user
|
97
|
-
format.html { render :
|
98
|
-
format.json { render :
|
96
|
+
format.html { render action: "new" }
|
97
|
+
format.json { render json: @bookmark.errors, status: :unprocessable_entity }
|
99
98
|
end
|
100
99
|
end
|
101
100
|
|
@@ -113,7 +112,7 @@ class BookmarksController < ApplicationController
|
|
113
112
|
|
114
113
|
respond_to do |format|
|
115
114
|
if @bookmark.update_attributes(params[:bookmark])
|
116
|
-
flash[:notice] = t('controller.successfully_updated', :
|
115
|
+
flash[:notice] = t('controller.successfully_updated', model: t('activerecord.models.bookmark'))
|
117
116
|
@bookmark.manifestation.index!
|
118
117
|
@bookmark.create_tag_index
|
119
118
|
case params[:mode]
|
@@ -125,8 +124,8 @@ class BookmarksController < ApplicationController
|
|
125
124
|
format.json { head :no_content }
|
126
125
|
end
|
127
126
|
else
|
128
|
-
format.html { render :
|
129
|
-
format.json { render :
|
127
|
+
format.html { render action: "edit" }
|
128
|
+
format.json { render json: @bookmark.errors, status: :unprocessable_entity }
|
130
129
|
end
|
131
130
|
end
|
132
131
|
end
|
@@ -135,17 +134,17 @@ class BookmarksController < ApplicationController
|
|
135
134
|
# DELETE /bookmarks/1.json
|
136
135
|
def destroy
|
137
136
|
@bookmark.destroy
|
138
|
-
flash[:notice] = t('controller.successfully_deleted', :
|
137
|
+
flash[:notice] = t('controller.successfully_deleted', model: t('activerecord.models.bookmark'))
|
139
138
|
@bookmark.create_tag_index
|
140
139
|
|
141
140
|
if @user
|
142
141
|
respond_to do |format|
|
143
|
-
format.html { redirect_to
|
142
|
+
format.html { redirect_to bookmarks_url(user_id: @user.username) }
|
144
143
|
format.json { head :no_content }
|
145
144
|
end
|
146
145
|
else
|
147
146
|
respond_to do |format|
|
148
|
-
format.html { redirect_to
|
147
|
+
format.html { redirect_to bookmarks_url(user_id: @bookmark.user.username) }
|
149
148
|
format.json { head :no_content }
|
150
149
|
end
|
151
150
|
end
|
@@ -1,8 +1,7 @@
|
|
1
1
|
class TagsController < ApplicationController
|
2
2
|
load_and_authorize_resource
|
3
3
|
before_filter :get_user
|
4
|
-
after_filter :solr_commit, :
|
5
|
-
cache_sweeper :bookmark_sweeper, :only => [:create, :update, :destroy]
|
4
|
+
after_filter :solr_commit, only: [:create, :update, :destroy]
|
6
5
|
|
7
6
|
def index
|
8
7
|
session[:params] ={} unless session[:params]
|
@@ -28,7 +27,7 @@ class TagsController < ApplicationController
|
|
28
27
|
|
29
28
|
respond_to do |format|
|
30
29
|
format.html # index.html.erb
|
31
|
-
format.json { render :
|
30
|
+
format.json { render json: @tags }
|
32
31
|
format.rss
|
33
32
|
format.atom
|
34
33
|
end
|
@@ -37,7 +36,7 @@ class TagsController < ApplicationController
|
|
37
36
|
def show
|
38
37
|
respond_to do |format|
|
39
38
|
format.html # show.html.erb
|
40
|
-
format.json { render :
|
39
|
+
format.json { render json: @tag }
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
@@ -50,11 +49,11 @@ class TagsController < ApplicationController
|
|
50
49
|
|
51
50
|
respond_to do |format|
|
52
51
|
if @tag.update_attributes(params[:tag])
|
53
|
-
format.html { redirect_to @tag, :
|
52
|
+
format.html { redirect_to @tag, notice: t('controller.successfully_updated', model: t('activerecord.models.tag')) }
|
54
53
|
format.json { head :no_content }
|
55
54
|
else
|
56
|
-
format.html { render :
|
57
|
-
format.json { render :
|
55
|
+
format.html { render action: "edit" }
|
56
|
+
format.json { render json: @tag.errors, status: :unprocessable_entity }
|
58
57
|
end
|
59
58
|
end
|
60
59
|
end
|
data/app/models/bookmark.rb
CHANGED
@@ -4,15 +4,15 @@ class Bookmark < ActiveRecord::Base
|
|
4
4
|
scope :bookmarked, lambda {|start_date, end_date| {:conditions => ['created_at >= ? AND created_at < ?', start_date, end_date]}}
|
5
5
|
scope :user_bookmarks, lambda {|user| where(:user_id => user.id)}
|
6
6
|
scope :shared, where(:shared => true)
|
7
|
-
belongs_to :manifestation
|
8
|
-
belongs_to :user #, :counter_cache => true, :
|
7
|
+
belongs_to :manifestation, touch: true
|
8
|
+
belongs_to :user #, :counter_cache => true, validate: true
|
9
9
|
|
10
10
|
validates_presence_of :user, :title
|
11
|
-
validates_presence_of :url, :
|
12
|
-
validates_presence_of :manifestation_id, :
|
11
|
+
validates_presence_of :url, on: :create
|
12
|
+
validates_presence_of :manifestation_id, on: :update
|
13
13
|
validates_associated :user, :manifestation
|
14
|
-
validates_uniqueness_of :manifestation_id, :
|
15
|
-
validates :url, :
|
14
|
+
validates_uniqueness_of :manifestation_id, scope: :user_id
|
15
|
+
validates :url, url: true, presence: true, length: {:maximum => 255}
|
16
16
|
before_save :create_manifestation, :if => :url_changed?
|
17
17
|
validate :bookmarkable_url?
|
18
18
|
validate :already_bookmarked?, :if => :url_changed?
|
@@ -27,7 +27,7 @@ class Bookmark < ActiveRecord::Base
|
|
27
27
|
manifestation.title
|
28
28
|
end
|
29
29
|
string :url
|
30
|
-
string :tag, :
|
30
|
+
string :tag, multiple: true do
|
31
31
|
tags.pluck(:name)
|
32
32
|
end
|
33
33
|
integer :user_id
|
@@ -49,10 +49,10 @@ class Bookmark < ActiveRecord::Base
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def save_tagger
|
52
|
-
#user.tag(self, :
|
52
|
+
#user.tag(self, with: tag_list, on: :tags)
|
53
53
|
taggings.each do |tagging|
|
54
54
|
tagging.tagger = user
|
55
|
-
tagging.save(:
|
55
|
+
tagging.save(validate: false)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -151,7 +151,7 @@ class Bookmark < ActiveRecord::Base
|
|
151
151
|
return
|
152
152
|
end
|
153
153
|
manifestation = Manifestation.new(:access_address => url)
|
154
|
-
manifestation.carrier_type = CarrierType.where(:
|
154
|
+
manifestation.carrier_type = CarrierType.where(name: 'file').first
|
155
155
|
if self.title.present?
|
156
156
|
manifestation.original_title = self.title
|
157
157
|
else
|
@@ -166,12 +166,12 @@ class Bookmark < ActiveRecord::Base
|
|
166
166
|
item.shelf = Shelf.web
|
167
167
|
item.manifestation = manifestation
|
168
168
|
if defined?(EnjuCirculation)
|
169
|
-
item.circulation_status = CirculationStatus.where(:
|
169
|
+
item.circulation_status = CirculationStatus.where(name: 'Not Available').first
|
170
170
|
end
|
171
171
|
|
172
172
|
item.save!
|
173
173
|
if defined?(EnjuCirculation)
|
174
|
-
item.use_restriction = UseRestriction.where(:
|
174
|
+
item.use_restriction = UseRestriction.where(name: 'Not For Loan').first
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
data/app/models/bookmark_stat.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
class BookmarkStat < ActiveRecord::Base
|
2
|
-
|
2
|
+
include Statesman::Adapters::ActiveRecordModel
|
3
3
|
include CalculateStat
|
4
|
-
|
5
|
-
|
4
|
+
attr_accessible :start_date, :end_date, :note
|
5
|
+
default_scope order: 'id DESC'
|
6
|
+
scope :not_calculated, -> {in_state(:pending)}
|
6
7
|
has_many :bookmark_stat_has_manifestations
|
7
|
-
has_many :manifestations, :
|
8
|
+
has_many :manifestations, through: :bookmark_stat_has_manifestations
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
paginates_per 10
|
11
|
+
|
12
|
+
has_many :bookmark_stat_transitions
|
13
|
+
|
14
|
+
def state_machine
|
15
|
+
BookmarkStatStateMachine.new(self, transition_class: BookmarkStatTransition)
|
14
16
|
end
|
15
17
|
|
16
|
-
|
18
|
+
delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
|
19
|
+
to: :state_machine
|
17
20
|
|
18
|
-
def calculate_count
|
21
|
+
def calculate_count!
|
19
22
|
self.started_at = Time.zone.now
|
20
23
|
Manifestation.find_each do |manifestation|
|
21
24
|
daily_count = Bookmark.manifestations_count(start_date, end_date, manifestation)
|
@@ -29,6 +32,12 @@ class BookmarkStat < ActiveRecord::Base
|
|
29
32
|
end
|
30
33
|
end
|
31
34
|
self.completed_at = Time.zone.now
|
35
|
+
transition_to!(:completed)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def self.transition_class
|
40
|
+
BookmarkStatTransition
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
@@ -42,7 +51,6 @@ end
|
|
42
51
|
# started_at :datetime
|
43
52
|
# completed_at :datetime
|
44
53
|
# note :text
|
45
|
-
# state :string(255)
|
46
54
|
# created_at :datetime not null
|
47
55
|
# updated_at :datetime not null
|
48
56
|
#
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class BookmarkStatHasManifestation < ActiveRecord::Base
|
2
2
|
attr_accessible
|
3
|
-
attr_accessible :bookmark_stat_id, :manifestation_id, :
|
3
|
+
attr_accessible :bookmark_stat_id, :manifestation_id, as: :admin
|
4
4
|
belongs_to :bookmark_stat
|
5
5
|
belongs_to :manifestation
|
6
6
|
|
7
|
-
validates_uniqueness_of :manifestation_id, :
|
7
|
+
validates_uniqueness_of :manifestation_id, scope: :bookmark_stat_id
|
8
8
|
validates_presence_of :bookmark_stat_id, :manifestation_id
|
9
9
|
|
10
10
|
paginates_per 10
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class BookmarkStatStateMachine
|
2
|
+
include Statesman::Machine
|
3
|
+
state :pending, initial: true
|
4
|
+
state :started
|
5
|
+
state :completed
|
6
|
+
|
7
|
+
transition from: :pending, to: :started
|
8
|
+
transition from: :started, to: :completed
|
9
|
+
|
10
|
+
after_transition(to: :started) do |bookmark_stat|
|
11
|
+
bookmark_stat.calculate_count!
|
12
|
+
end
|
13
|
+
end
|