enju_circulation 0.0.50 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module EnjuCirculation
2
- VERSION = "0.0.50"
2
+ VERSION = "0.0.51"
3
3
  end
@@ -1,2 +1,227 @@
1
+ # Methods added to this helper will be available to all templates in the application.
1
2
  module ApplicationHelper
3
+ include PictureFilesHelper if defined?(EnjuLibrary)
4
+ include EnjuBookJacket::BookJacketHelper if defined?(EnjuBookJacket)
5
+ include EnjuManifestationViewer::ManifestationViewerHelper if defined?(EnjuManifestationViewer)
6
+
7
+ def form_icon(carrier_type)
8
+ case carrier_type.name
9
+ when 'print'
10
+ image_tag('icons/book.png', :size => '16x16', :alt => carrier_type.display_name.localize)
11
+ when 'CD'
12
+ image_tag('icons/cd.png', :size => '16x16', :alt => carrier_type.display_name.localize)
13
+ when 'DVD'
14
+ image_tag('icons/dvd.png', :size => '16x16', :alt => carrier_type.display_name.localize)
15
+ when 'file'
16
+ image_tag('icons/monitor.png', :size => '16x16', :alt => carrier_type.display_name.localize)
17
+ else
18
+ image_tag('icons/help.png', :size => '16x16', :alt => t('page.unknown'))
19
+ end
20
+ rescue NoMethodError
21
+ image_tag('icons/help.png', :size => '16x16', :alt => t('page.unknown'))
22
+ end
23
+
24
+ def content_type_icon(content_type)
25
+ case content_type.name
26
+ when 'text'
27
+ image_tag('icons/page_white_text.png', :size => '16x16', :alt => content_type.display_name.localize)
28
+ when 'picture'
29
+ image_tag('icons/picture.png', :size => '16x16', :alt => content_type.display_name.localize)
30
+ when 'sound'
31
+ image_tag('icons/sound.png', :size => '16x16', :alt => content_type.display_name.localize)
32
+ when 'video'
33
+ image_tag('icons/film.png', :size => '16x16', :alt => content_type.display_name.localize)
34
+ else
35
+ image_tag('icons/help.png', :size => '16x16', :alt => t('page.unknown'))
36
+ end
37
+ rescue NoMethodError
38
+ image_tag('icons/help.png', :size => '16x16', :alt => t('page.unknown'))
39
+ end
40
+
41
+ def patron_type_icon(patron_type)
42
+ case patron_type
43
+ when 'Person'
44
+ image_tag('icons/user.png', :size => '16x16', :alt => 'Person')
45
+ when 'CorporateBody'
46
+ image_tag('icons/group.png', :size => '16x16', :alt => 'CorporateBody')
47
+ else
48
+ image_tag('icons/help.png', :size => '16x16', :alt => t('page.unknown'))
49
+ end
50
+ end
51
+
52
+ def link_to_tag(tag)
53
+ link_to tag, manifestations_path(:tag => tag.name)
54
+ end
55
+
56
+ def render_tag_cloud(tags, options = {})
57
+ return nil if tags.nil?
58
+ # TODO: add options to specify different limits and sorts
59
+ #tags = Tag.all(:limit => 100, :order => 'taggings_count DESC').sort_by(&:name)
60
+
61
+ # TODO: add option to specify which classes you want and overide this if you want?
62
+ classes = %w(popular v-popular vv-popular vvv-popular vvvv-popular)
63
+
64
+ max, min = 0, 0
65
+ tags.each do |tag|
66
+ #if options[:max] or options[:min]
67
+ # max = options[:max].to_i
68
+ # min = options[:min].to_i
69
+ #end
70
+ max = tag.taggings.size if tag.taggings.size > max
71
+ min = tag.taggings.size if tag.taggings.size < min
72
+ end
73
+ divisor = ((max - min).div(classes.size)) + 1
74
+
75
+ content_tag :div, :class => "hTagcloud" do
76
+ content_tag :ul, :class => "popularity" do
77
+ tags.each do |tag|
78
+ content_tag :li do
79
+ link_to(tag.name, manifestations_path(:tag => tag.name), :class => classes[(tag.taggings.size - min).div(divisor)])
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ def patrons_list(patrons = [], options = {})
87
+ return nil if patrons.blank?
88
+ patrons_list = []
89
+ if options[:nolink]
90
+ patrons_list = patrons.map{|patron| patron.full_name}
91
+ else
92
+ patrons_list = patrons.map{|patron| link_to(patron.full_name, patron, options)}
93
+ end
94
+ patrons_list.join(" ").html_safe
95
+ end
96
+
97
+ def book_jacket(manifestation)
98
+ if manifestation.picture_files.exists?
99
+ link = ''
100
+ manifestation.picture_files.each_with_index do |picture_file, i|
101
+ if i == 0
102
+ link += link_to(show_image(picture_file, :size => :thumb), picture_file_path(picture_file, :format => :download), :rel => "manifestation_#{manifestation.id}")
103
+ else
104
+ link += content_tag :span, :style => "display: none" do
105
+ link_to(show_image(picture_file, :size => :thumb), picture_file_path(picture_file, :format => :download), :rel => "manifestation_#{manifestation.id}")
106
+ end
107
+ end
108
+ end
109
+ return link.html_safe
110
+ else
111
+ link = book_jacket_tag(manifestation)
112
+ unless link
113
+ link = screenshot_tag(manifestation)
114
+ end
115
+ end
116
+
117
+ unless link
118
+ link = link_to image_tag('unknown_resource.png', :width => '100', :height => '100', :alt => '*', :itemprop => 'image'), manifestation
119
+ end
120
+ link
121
+ end
122
+
123
+ def database_adapter
124
+ case ActiveRecord::Base.configurations["#{Rails.env}"]['adapter']
125
+ when 'postgresql'
126
+ link_to 'PostgreSQL', 'http://www.postgresql.org/'
127
+ when 'jdbcpostgresql'
128
+ link_to 'PostgreSQL', 'http://www.postgresql.org/'
129
+ when 'mysql'
130
+ link_to 'MySQL', 'http://www.mysql.org/'
131
+ when 'jdbcmysql'
132
+ link_to 'MySQL', 'http://www.mysql.org/'
133
+ when 'sqlite3'
134
+ link_to 'SQLite', 'http://www.sqlite.org/'
135
+ when 'jdbcsqlite3'
136
+ link_to 'SQLite', 'http://www.sqlite.org/'
137
+ end
138
+ end
139
+
140
+ def title_action_name
141
+ case controller.action_name
142
+ when 'index'
143
+ t('title.index')
144
+ when 'show'
145
+ t('title.show')
146
+ when 'new'
147
+ t('title.new')
148
+ when 'edit'
149
+ t('title.edit')
150
+ end
151
+ end
152
+
153
+ def link_to_wikipedia(string)
154
+ link_to "Wikipedia", "http://#{I18n.locale}.wikipedia.org/wiki/#{URI.escape(string)}"
155
+ end
156
+
157
+ def locale_display_name(locale)
158
+ Language.where(:iso_639_1 => locale).first.display_name
159
+ end
160
+
161
+ def locale_native_name(locale)
162
+ Language.where(:iso_639_1 => locale).first.native_name
163
+ end
164
+
165
+ def move_position(object)
166
+ render :partial => 'page/position', :locals => {:object => object}
167
+ end
168
+
169
+ def localized_state(state)
170
+ case state
171
+ when 'pending'
172
+ t('state.pending')
173
+ when 'canceled'
174
+ t('state.canceled')
175
+ when 'started'
176
+ t('state.started')
177
+ when 'failed'
178
+ t('state.failed')
179
+ when 'completed'
180
+ t('state.completed')
181
+ else
182
+ state
183
+ end
184
+ end
185
+
186
+ def localized_boolean(bool)
187
+ case bool.to_s
188
+ when nil
189
+ when "true"
190
+ t('page.boolean.true')
191
+ when "false"
192
+ t('page.boolean.false')
193
+ end
194
+ end
195
+
196
+ def current_user_role_name
197
+ current_user.try(:role).try(:name) || 'Guest'
198
+ end
199
+
200
+ def title(controller_name)
201
+ string = ''
202
+ unless ['page', 'routing_error', 'my_accounts'].include?(controller_name)
203
+ string << t("activerecord.models.#{controller_name.singularize}") + ' - '
204
+ end
205
+ if controller_name == 'routing_error'
206
+ string << t("page.routing_error") + ' - '
207
+ end
208
+ string << LibraryGroup.system_name + ' - Next-L Enju Leaf'
209
+ string.html_safe
210
+ end
211
+
212
+ def back_to_index(options = {})
213
+ if options == nil
214
+ options = {}
215
+ else
216
+ options.reject!{|key, value| value.blank?}
217
+ options.delete(:page) if options[:page].to_i == 1
218
+ end
219
+ unless controller_name == 'test'
220
+ link_to t('page.listing', :model => t("activerecord.models.#{controller_name.singularize}")), url_for(params.merge(:controller => controller_name, :action => :index, :id => nil, :only_path => true).merge(options))
221
+ end
222
+ end
223
+
224
+ def set_focus_on_search_form
225
+ javascript_tag("$('#search_form').focus()") if @query.blank?
226
+ end
2
227
  end
Binary file
@@ -8,3 +8,4 @@ require 'enju_leaf/localized_name'
8
8
  require 'enju_leaf/url_validator'
9
9
  require 'enju_biblio'
10
10
  require 'enju_library'
11
+ require 'enju_manifestation_viewer'
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Accepts" do
4
+ describe "GET /accepts" do
5
+ it "works! (now write some real specs)" do
6
+ # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
7
+ get accepts_path
8
+ response.status.should be(302)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ describe AcceptsController do
4
+ describe "routing" do
5
+
6
+ it "routes to #index" do
7
+ get("/accepts").should route_to("accepts#index")
8
+ end
9
+
10
+ it "routes to #new" do
11
+ get("/accepts/new").should route_to("accepts#new")
12
+ end
13
+
14
+ it "routes to #show" do
15
+ get("/accepts/1").should route_to("accepts#show", :id => "1")
16
+ end
17
+
18
+ it "routes to #create" do
19
+ post("/accepts").should route_to("accepts#create")
20
+ end
21
+
22
+ it "routes to #destroy" do
23
+ delete("/accepts/1").should route_to("accepts#destroy", :id => "1")
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe BasketsController do
4
+ describe "routing" do
5
+
6
+ it "recognizes and generates #index" do
7
+ { :get => "/baskets" }.should route_to(:controller => "baskets", :action => "index")
8
+ end
9
+
10
+ it "recognizes and generates #new" do
11
+ { :get => "/baskets/new" }.should route_to(:controller => "baskets", :action => "new")
12
+ end
13
+
14
+ it "recognizes and generates #show" do
15
+ { :get => "/baskets/1" }.should route_to(:controller => "baskets", :action => "show", :id => "1")
16
+ end
17
+
18
+ it "recognizes and generates #edit" do
19
+ { :get => "/baskets/1/edit" }.should route_to(:controller => "baskets", :action => "edit", :id => "1")
20
+ end
21
+
22
+ it "recognizes and generates #create" do
23
+ { :post => "/baskets" }.should route_to(:controller => "baskets", :action => "create")
24
+ end
25
+
26
+ it "recognizes and generates #update" do
27
+ { :put => "/baskets/1" }.should route_to(:controller => "baskets", :action => "update", :id => "1")
28
+ end
29
+
30
+ it "recognizes and generates #destroy" do
31
+ { :delete => "/baskets/1" }.should route_to(:controller => "baskets", :action => "destroy", :id => "1")
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe "accepts/edit" do
4
+ before(:each) do
5
+ @accept = assign(:accept, stub_model(Accept,
6
+ :item_id => 1
7
+ ))
8
+ end
9
+
10
+ it "renders the edit accept form" do
11
+ render
12
+
13
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
14
+ assert_select "form", :action => accepts_path(@accept), :method => "post" do
15
+ assert_select "input#accept_item_id", :name => "accept[item_id]"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe "accepts/index" do
4
+ before(:each) do
5
+ assign(:accepts, [
6
+ stub_model(Accept,
7
+ :item_id => 1,
8
+ :created_at => Time.zone.now
9
+ ),
10
+ stub_model(Accept,
11
+ :item_id => 1,
12
+ :created_at => Time.zone.now
13
+ )
14
+ ].paginate(:page => 1))
15
+ basket = FactoryGirl.create(:basket)
16
+ assign(:basket, basket)
17
+ assign(:accept, basket.accepts.new)
18
+ end
19
+
20
+ it "renders a list of accepts" do
21
+ render
22
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
23
+ assert_select "tr>td"
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe "accepts/new" do
4
+ before(:each) do
5
+ assign(:accept, stub_model(Accept,
6
+ :item_id => 1
7
+ ).as_new_record)
8
+ assign(:basket, FactoryGirl.create(:basket))
9
+ assign(:accepts, [
10
+ stub_model(Accept,
11
+ :item_id => 1,
12
+ :created_at => Time.zone.now
13
+ ),
14
+ stub_model(Accept,
15
+ :item_id => 1,
16
+ :created_at => Time.zone.now
17
+ )
18
+ ].paginate(:page => 1))
19
+ end
20
+
21
+ it "renders new accept form" do
22
+ render
23
+
24
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
25
+ assert_select "form", :action => accepts_path, :method => "post" do
26
+ assert_select "input#accept_item_identifier", :name => "accept[item_identifier]"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe "accepts/show" do
4
+ before(:each) do
5
+ @accept = assign(:accept, stub_model(Accept,
6
+ :item_id => 1,
7
+ :librarian_id => 1,
8
+ :created_at => Time.zone.now
9
+ ))
10
+ end
11
+
12
+ it "renders attributes in <p>" do
13
+ render
14
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
15
+ rendered.should match(/1/)
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enju_circulation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.50
4
+ version: 0.0.51
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-02 00:00:00.000000000 Z
12
+ date: 2012-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -299,6 +299,22 @@ dependencies:
299
299
  - - ! '>='
300
300
  - !ruby/object:Gem::Version
301
301
  version: '0'
302
+ - !ruby/object:Gem::Dependency
303
+ name: enju_manifestation_viewer
304
+ requirement: !ruby/object:Gem::Requirement
305
+ none: false
306
+ requirements:
307
+ - - ! '>='
308
+ - !ruby/object:Gem::Version
309
+ version: '0'
310
+ type: :development
311
+ prerelease: false
312
+ version_requirements: !ruby/object:Gem::Requirement
313
+ none: false
314
+ requirements:
315
+ - - ! '>='
316
+ - !ruby/object:Gem::Version
317
+ version: '0'
302
318
  description: Circulation management for Next-L Enju
303
319
  email:
304
320
  - tanabe@mwr.mediacom.keio.ac.jp
@@ -762,10 +778,17 @@ files:
762
778
  - spec/models/user_checkout_stat_spec.rb
763
779
  - spec/models/user_group_has_checkout_type_spec.rb
764
780
  - spec/models/user_reserve_stat_spec.rb
781
+ - spec/requests/accepts_spec.rb
782
+ - spec/routing/accepts_routing_spec.rb
783
+ - spec/routing/baskets_routing_spec.rb
765
784
  - spec/routing/checked_items_routing_spec.rb
766
785
  - spec/spec_helper.rb
767
786
  - spec/support/controller_macros.rb
768
787
  - spec/support/devise.rb
788
+ - spec/views/accepts/edit.html.erb_spec.rb
789
+ - spec/views/accepts/index.html.erb_spec.rb
790
+ - spec/views/accepts/new.html.erb_spec.rb
791
+ - spec/views/accepts/show.html.erb_spec.rb
769
792
  homepage: https://github.com/nabeta/enju_circulation
770
793
  licenses: []
771
794
  post_install_message:
@@ -1034,7 +1057,14 @@ test_files:
1034
1057
  - spec/models/user_checkout_stat_spec.rb
1035
1058
  - spec/models/user_group_has_checkout_type_spec.rb
1036
1059
  - spec/models/user_reserve_stat_spec.rb
1060
+ - spec/requests/accepts_spec.rb
1061
+ - spec/routing/accepts_routing_spec.rb
1062
+ - spec/routing/baskets_routing_spec.rb
1037
1063
  - spec/routing/checked_items_routing_spec.rb
1038
1064
  - spec/spec_helper.rb
1039
1065
  - spec/support/controller_macros.rb
1040
1066
  - spec/support/devise.rb
1067
+ - spec/views/accepts/edit.html.erb_spec.rb
1068
+ - spec/views/accepts/index.html.erb_spec.rb
1069
+ - spec/views/accepts/new.html.erb_spec.rb
1070
+ - spec/views/accepts/show.html.erb_spec.rb