enju_news 0.1.0.pre3 → 0.1.0.pre4
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.
- checksums.yaml +4 -4
- data/app/models/news_post.rb +6 -1
- data/lib/enju_news/engine.rb +1 -1
- data/lib/enju_news/version.rb +1 -1
- data/spec/cassette_library/NewsFeed/should_fetch_feeds.yml +496 -872
- data/spec/cassette_library/NewsFeed/should_get_content.yml +463 -806
- data/spec/cassette_library/NewsFeed/should_not_get_content_if_the_feed_is_invalid.yml +35 -68
- data/spec/cassette_library/NewsFeed/should_reload_content.yml +463 -806
- data/spec/dummy/app/controllers/application_controller.rb +2 -48
- data/spec/dummy/app/models/user.rb +5 -91
- data/spec/dummy/config/application.rb +1 -2
- data/spec/dummy/config/application.yml +42 -0
- data/spec/dummy/config/initializers/devise.rb +2 -0
- data/spec/dummy/db/migrate/059_create_libraries.rb +28 -0
- data/spec/dummy/db/migrate/069_create_shelves.rb +15 -0
- data/spec/dummy/db/migrate/080_create_library_groups.rb +1 -3
- data/spec/dummy/db/migrate/120_create_baskets.rb +12 -0
- data/spec/dummy/db/migrate/124_create_bookstores.rb +17 -0
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +12 -0
- data/spec/dummy/db/migrate/131_create_request_types.rb +12 -0
- data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +17 -0
- data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +14 -0
- data/spec/dummy/db/migrate/20081023092436_create_search_engines.rb +17 -0
- data/spec/dummy/db/migrate/20091202124834_create_versions.rb +18 -0
- data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100314190054_add_opening_hour_to_library.rb +9 -0
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +0 -8
- data/spec/dummy/db/migrate/20120105074911_add_isil_to_library.rb +5 -0
- data/spec/dummy/db/migrate/20120129014038_create_budget_types.rb +12 -0
- data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +14 -0
- data/spec/dummy/db/migrate/20120510140958_add_closed_to_shelf.rb +5 -0
- data/spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb +26 -0
- data/spec/dummy/db/migrate/20130412083556_add_latitude_and_longitude_to_library.rb +6 -0
- data/spec/dummy/db/schema.rb +185 -15
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/factories/library.rb +13 -0
- data/spec/factories/user.rb +33 -11
- data/spec/fixtures/libraries.yml +102 -0
- data/spec/fixtures/user_groups.yml +45 -0
- data/spec/spec_helper.rb +16 -17
- metadata +96 -53
- data/lib/generators/enju_news/views_generator.rb +0 -18
- data/spec/dummy/app/models/library_group.rb +0 -86
- data/spec/dummy/app/models/role.rb +0 -46
- data/spec/dummy/app/models/user_group.rb +0 -40
- data/spec/dummy/app/models/user_has_role.rb +0 -5
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/lib/master_model.rb +0 -19
- data/spec/dummy/lib/url_validator.rb +0 -10
@@ -1,52 +1,6 @@
|
|
1
1
|
class ApplicationController < ActionController::Base
|
2
2
|
protect_from_forgery
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
private
|
8
|
-
def render_403
|
9
|
-
return if performed?
|
10
|
-
if user_signed_in?
|
11
|
-
respond_to do |format|
|
12
|
-
format.html {render :template => 'page/403', :status => 403}
|
13
|
-
format.xml {render :template => 'page/403', :status => 403}
|
14
|
-
format.json
|
15
|
-
end
|
16
|
-
else
|
17
|
-
respond_to do |format|
|
18
|
-
format.html {redirect_to new_user_session_url}
|
19
|
-
format.xml {render :template => 'page/403', :status => 403}
|
20
|
-
format.json
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def render_404
|
26
|
-
return if performed?
|
27
|
-
respond_to do |format|
|
28
|
-
format.html {render :template => 'page/404', :status => 404}
|
29
|
-
format.mobile {render :template => 'page/404', :status => 404}
|
30
|
-
format.xml {render :template => 'page/404', :status => 404}
|
31
|
-
format.json
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def access_denied
|
36
|
-
raise CanCan::AccessDenied
|
37
|
-
end
|
38
|
-
|
39
|
-
def current_ability
|
40
|
-
@current_ability ||= Ability.new(current_user, request.remote_ip)
|
41
|
-
end
|
42
|
-
|
43
|
-
def move_position(resource, direction, redirect = true)
|
44
|
-
if ['higher', 'lower'].include?(direction)
|
45
|
-
resource.send("move_#{direction}")
|
46
|
-
if redirect
|
47
|
-
redirect_to url_for(:controller => resource.class.to_s.pluralize.underscore)
|
48
|
-
return
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
4
|
+
enju_leaf
|
5
|
+
enju_library
|
52
6
|
end
|
@@ -1,94 +1,8 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
class User < ActiveRecord::Base
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
:recoverable, :rememberable, :trackable, :validatable
|
3
|
+
devise :database_authenticatable, #:registerable,
|
4
|
+
:recoverable, :rememberable, :trackable, #, :validatable
|
5
|
+
:lockable, :lock_strategy => :none, :unlock_strategy => :none
|
6
6
|
|
7
|
-
|
8
|
-
attr_accessible :email, :password, :password_confirmation, :remember_me
|
9
|
-
|
10
|
-
has_one :patron
|
11
|
-
has_one :user_has_role
|
12
|
-
has_one :role, :through => :user_has_role
|
13
|
-
belongs_to :user_group
|
14
|
-
belongs_to :required_role, :class_name => 'Role', :foreign_key => 'required_role_id'
|
15
|
-
has_many :checkouts, :dependent => :nullify
|
16
|
-
has_many :reserves, :dependent => :destroy
|
17
|
-
has_many :reserved_manifestations, :through => :reserves, :source => :manifestation
|
18
|
-
has_many :checkout_stat_has_users
|
19
|
-
has_many :user_checkout_stats, :through => :checkout_stat_has_users
|
20
|
-
has_many :reserve_stat_has_users
|
21
|
-
has_many :user_reserve_stats, :through => :reserve_stat_has_users
|
22
|
-
has_many :baskets, :dependent => :destroy
|
23
|
-
belongs_to :library
|
24
|
-
|
25
|
-
before_destroy :check_item_before_destroy
|
26
|
-
|
27
|
-
extend FriendlyId
|
28
|
-
friendly_id :username
|
29
|
-
|
30
|
-
def check_item_before_destroy
|
31
|
-
# TODO: 貸出記録を残す場合
|
32
|
-
if checkouts.size > 0
|
33
|
-
raise 'This user has items still checked out.'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def reset_checkout_icalendar_token
|
38
|
-
self.checkout_icalendar_token = Devise.friendly_token
|
39
|
-
end
|
40
|
-
|
41
|
-
def delete_checkout_icalendar_token
|
42
|
-
self.checkout_icalendar_token = nil
|
43
|
-
end
|
44
|
-
|
45
|
-
def checked_item_count
|
46
|
-
checkout_count = {}
|
47
|
-
CheckoutType.all.each do |checkout_type|
|
48
|
-
# 資料種別ごとの貸出中の冊数を計算
|
49
|
-
checkout_count[:"#{checkout_type.name}"] = self.checkouts.count_by_sql(["
|
50
|
-
SELECT count(item_id) FROM checkouts
|
51
|
-
WHERE item_id IN (
|
52
|
-
SELECT id FROM items
|
53
|
-
WHERE checkout_type_id = ?
|
54
|
-
)
|
55
|
-
AND user_id = ? AND checkin_id IS NULL", checkout_type.id, self.id]
|
56
|
-
)
|
57
|
-
end
|
58
|
-
return checkout_count
|
59
|
-
end
|
60
|
-
|
61
|
-
def reached_reservation_limit?(manifestation)
|
62
|
-
return true if self.user_group.user_group_has_checkout_types.available_for_carrier_type(manifestation.carrier_type).where(:user_group_id => self.user_group.id).collect(&:reservation_limit).max.to_i <= self.reserves.waiting.size
|
63
|
-
false
|
64
|
-
end
|
65
|
-
|
66
|
-
def has_role?(role_in_question)
|
67
|
-
return false unless role
|
68
|
-
return true if role.name == role_in_question
|
69
|
-
case role.name
|
70
|
-
when 'Administrator'
|
71
|
-
return true
|
72
|
-
when 'Librarian'
|
73
|
-
return true if role_in_question == 'User'
|
74
|
-
else
|
75
|
-
false
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
if defined?(EnjuMessage)
|
80
|
-
has_many :sent_messages, :foreign_key => 'sender_id', :class_name => 'Message'
|
81
|
-
has_many :received_messages, :foreign_key => 'receiver_id', :class_name => 'Message'
|
82
|
-
|
83
|
-
def send_message(status, options = {})
|
84
|
-
MessageRequest.transaction do
|
85
|
-
request = MessageRequest.new
|
86
|
-
request.sender = User.find(1)
|
87
|
-
request.receiver = self
|
88
|
-
request.message_template = MessageTemplate.localized_template(status, self.locale)
|
89
|
-
request.save_message_body(options)
|
90
|
-
request.sm_send_message!
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
7
|
+
enju_leaf_user_model
|
94
8
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
enju:
|
3
|
+
web_hostname: localhost
|
4
|
+
web_port_number: 3000
|
5
|
+
|
6
|
+
family_name_first: true
|
7
|
+
max_number_of_results: 500
|
8
|
+
write_search_log_to_file: true
|
9
|
+
csv_charset_conversion: true
|
10
|
+
|
11
|
+
# Choose a locale from 'ca', 'de', 'fr', 'jp', 'uk', 'us'
|
12
|
+
#AMAZON_AWS_HOSTNAME = 'ecs.amazonaws.com'
|
13
|
+
amazon:
|
14
|
+
aws_hostname: ecs.amazonaws.jp
|
15
|
+
hostname: www.amazon.co.jp
|
16
|
+
access_key: REPLACE_WITH_YOUR_AMAZON_ACCESS_KEY
|
17
|
+
secret_access_key: REPLACE_WITH_YOUR_AMAZON_SECRET_ACCESS_KEY
|
18
|
+
|
19
|
+
# :google, :amazon
|
20
|
+
book_jacket:
|
21
|
+
source: :google
|
22
|
+
unknown_resource:
|
23
|
+
|
24
|
+
# :mozshot, :simpleapi, :heartrails, :thumbalizr
|
25
|
+
screenshot:
|
26
|
+
generator: :mozshot
|
27
|
+
|
28
|
+
uploaded_file:
|
29
|
+
storage: :local
|
30
|
+
|
31
|
+
manifestation:
|
32
|
+
facet:
|
33
|
+
pub_year_range_interval: 10
|
34
|
+
|
35
|
+
development:
|
36
|
+
<<: *defaults
|
37
|
+
|
38
|
+
test:
|
39
|
+
<<: *defaults
|
40
|
+
|
41
|
+
production:
|
42
|
+
<<: *defaults
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# Use this hook to configure devise mailer, warden hooks and so forth.
|
2
2
|
# Many of these configuration options can be set straight in your model.
|
3
3
|
Devise.setup do |config|
|
4
|
+
config.secret_key = 'fec5f62c0fcb0abca683a6883e13f49bdbda4229692b980e0df8fb891d6cb2ee2e1c6d32e07ea60a7d132e742e4b7eb0589134b8d0c3315e99ed4f02da51433b'
|
5
|
+
|
4
6
|
# ==> Mailer Configuration
|
5
7
|
# Configure the e-mail address which will be shown in Devise::Mailer,
|
6
8
|
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class CreateLibraries < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :libraries do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.text :display_name
|
6
|
+
t.string :short_display_name, :null => false
|
7
|
+
t.string :zip_code
|
8
|
+
t.text :street
|
9
|
+
t.text :locality
|
10
|
+
t.text :region
|
11
|
+
t.string :telephone_number_1
|
12
|
+
t.string :telephone_number_2
|
13
|
+
t.string :fax_number
|
14
|
+
t.text :note
|
15
|
+
t.integer :call_number_rows, :default => 1, :null => false
|
16
|
+
t.string :call_number_delimiter, :default => "|", :null => false
|
17
|
+
t.integer :library_group_id, :default => 1, :null => false
|
18
|
+
t.integer :users_count, :default => 0, :null => false
|
19
|
+
t.integer :position
|
20
|
+
t.integer :country_id
|
21
|
+
|
22
|
+
t.timestamps
|
23
|
+
t.datetime :deleted_at
|
24
|
+
end
|
25
|
+
add_index :libraries, :library_group_id
|
26
|
+
add_index :libraries, :name, :unique => true
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateShelves < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :shelves do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.text :display_name
|
6
|
+
t.text :note
|
7
|
+
t.integer :library_id, :default => 1, :null => false
|
8
|
+
t.integer :items_count, :default => 0, :null => false
|
9
|
+
t.integer :position
|
10
|
+
t.timestamps
|
11
|
+
t.datetime :deleted_at
|
12
|
+
end
|
13
|
+
add_index :shelves, :library_id
|
14
|
+
end
|
15
|
+
end
|
@@ -6,12 +6,10 @@ class CreateLibraryGroups < ActiveRecord::Migration
|
|
6
6
|
t.string :short_name, :null => false
|
7
7
|
t.string :email
|
8
8
|
t.text :my_networks
|
9
|
-
t.boolean :use_dsbl, :default => false, :null => false
|
10
|
-
t.text :dsbl_list
|
11
9
|
t.text :login_banner
|
12
10
|
t.text :note
|
13
|
-
t.integer :valid_period_for_new_user, :default => 365, :null => false
|
14
11
|
t.integer :country_id
|
12
|
+
t.integer :position
|
15
13
|
|
16
14
|
t.timestamps
|
17
15
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateBookstores < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :bookstores do |t|
|
4
|
+
t.text :name, :null => false
|
5
|
+
t.string :zip_code
|
6
|
+
t.text :address
|
7
|
+
t.text :note
|
8
|
+
t.string :telephone_number
|
9
|
+
t.string :fax_number
|
10
|
+
t.string :url
|
11
|
+
t.integer :position
|
12
|
+
t.datetime :deleted_at
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateSubscriptions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :subscriptions do |t|
|
4
|
+
t.text :title, :null => false
|
5
|
+
t.text :note
|
6
|
+
#t.integer :subscription_list_id, :integer
|
7
|
+
t.integer :user_id
|
8
|
+
t.integer :order_list_id
|
9
|
+
t.datetime :deleted_at
|
10
|
+
t.integer :subscribes_count, :default => 0, :null => false
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
add_index :subscriptions, :user_id
|
15
|
+
add_index :subscriptions, :order_list_id
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateSubscribes < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :subscribes do |t|
|
4
|
+
t.integer :subscription_id, :null => false
|
5
|
+
t.integer :work_id, :null => false
|
6
|
+
t.datetime :start_at, :null => false
|
7
|
+
t.datetime :end_at, :null => false
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
add_index :subscribes, :subscription_id
|
12
|
+
add_index :subscribes, :work_id
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateSearchEngines < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :search_engines do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.text :display_name
|
6
|
+
t.string :url, :null => false
|
7
|
+
t.text :base_url, :null => false
|
8
|
+
t.text :http_method, :null => false
|
9
|
+
t.text :query_param, :null => false
|
10
|
+
t.text :additional_param
|
11
|
+
t.text :note
|
12
|
+
t.integer :position
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateVersions < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :versions do |t|
|
4
|
+
t.string :item_type, :null => false
|
5
|
+
t.integer :item_id, :null => false
|
6
|
+
t.string :event, :null => false
|
7
|
+
t.string :whodunnit
|
8
|
+
t.text :object
|
9
|
+
t.datetime :created_at
|
10
|
+
end
|
11
|
+
add_index :versions, [:item_type, :item_id]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
remove_index :versions, [:item_type, :item_id]
|
16
|
+
drop_table :versions
|
17
|
+
end
|
18
|
+
end
|
@@ -1,14 +1,6 @@
|
|
1
1
|
class CreateUsers < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
create_table :users do |t|
|
4
|
-
t.integer :user_group_id
|
5
|
-
t.integer :required_role_id
|
6
|
-
t.string :username
|
7
|
-
t.text :note
|
8
|
-
t.string :locale
|
9
|
-
t.string :user_number
|
10
|
-
t.integer :library_id
|
11
|
-
t.datetime :locked_at
|
12
4
|
|
13
5
|
t.timestamps
|
14
6
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateAccepts < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :accepts do |t|
|
4
|
+
t.integer :basket_id
|
5
|
+
t.integer :item_id
|
6
|
+
t.integer :librarian_id
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
add_index :accepts, :basket_id
|
12
|
+
add_index :accepts, :item_id
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class AddAdditionalAttributesToUser < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :users, :username, :string
|
4
|
+
add_column :users, :user_number, :string
|
5
|
+
add_column :users, :state, :string
|
6
|
+
add_column :users, :locale, :string
|
7
|
+
add_column :users, :deleted_at, :datetime
|
8
|
+
add_column :users, :expired_at, :datetime
|
9
|
+
add_column :users, :library_id, :integer, :default => 1, :null => false
|
10
|
+
add_column :users, :required_role_id, :integer, :default => 1, :null => false
|
11
|
+
add_column :users, :user_group_id, :integer, :default => 1, :null => false
|
12
|
+
add_column :users, :note, :text
|
13
|
+
add_column :users, :keyword_list, :text
|
14
|
+
|
15
|
+
add_column :users, :failed_attempts, :integer
|
16
|
+
add_column :users, :unlock_token, :string
|
17
|
+
add_column :users, :locked_at, :datetime
|
18
|
+
|
19
|
+
add_column :users, :confirmed_at, :datetime
|
20
|
+
|
21
|
+
add_index :users, :username, :unique => true
|
22
|
+
add_index :users, :user_group_id
|
23
|
+
add_index :users, :user_number, :unique => true
|
24
|
+
add_index :users, :unlock_token, :unique => true
|
25
|
+
end
|
26
|
+
end
|