enju_bookmark 0.1.2.pre17 → 0.1.2.pre18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/bookmark.rb +12 -12
- data/lib/enju_bookmark/engine.rb +1 -0
- data/lib/enju_bookmark/manifestation.rb +4 -4
- data/lib/enju_bookmark/version.rb +1 -1
- data/spec/controllers/bookmark_stats_controller_spec.rb +4 -4
- data/spec/dummy/config/boot.rb +2 -2
- data/spec/dummy/config/initializers/friendly_id.rb +90 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/005_create_manifestations.rb +0 -1
- data/spec/dummy/db/migrate/029_create_subjects.rb +27 -0
- data/spec/dummy/db/migrate/035_create_reserves.rb +1 -2
- data/spec/dummy/db/migrate/059_create_libraries.rb +5 -1
- data/spec/dummy/db/migrate/069_create_shelves.rb +5 -1
- data/spec/dummy/db/migrate/077_create_user_groups.rb +7 -3
- data/spec/dummy/db/migrate/080_create_library_groups.rb +6 -1
- data/spec/dummy/db/migrate/113_create_events.rb +23 -0
- data/spec/dummy/db/migrate/114_create_event_categories.rb +16 -0
- data/spec/dummy/db/migrate/130_create_request_status_types.rb +5 -1
- data/spec/dummy/db/migrate/131_create_request_types.rb +5 -1
- data/spec/dummy/db/migrate/133_create_agent_merges.rb +15 -0
- data/spec/dummy/db/migrate/134_create_agent_merge_lists.rb +13 -0
- data/spec/dummy/db/migrate/142_create_classifications.rb +19 -0
- data/spec/dummy/db/migrate/144_create_classification_types.rb +16 -0
- data/spec/dummy/db/migrate/145_create_subject_heading_types.rb +16 -0
- data/spec/dummy/db/migrate/146_create_subject_types.rb +16 -0
- data/spec/dummy/db/migrate/149_create_message_templates.rb +18 -0
- data/spec/dummy/db/migrate/154_create_messages.rb +23 -0
- data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +18 -0
- data/spec/dummy/db/migrate/20081212080038_create_manifestation_checkout_stats.rb +0 -1
- data/spec/dummy/db/migrate/20081215094302_create_user_checkout_stats.rb +0 -1
- data/spec/dummy/db/migrate/20081216190724_create_manifestation_reserve_stats.rb +0 -1
- data/spec/dummy/db/migrate/20081220023628_create_user_reserve_stats.rb +0 -1
- data/spec/dummy/db/migrate/20090321130448_add_completed_at_to_user_checkout_stat.rb +0 -4
- data/spec/dummy/db/migrate/20090831220301_create_lending_policies.rb +1 -1
- data/spec/dummy/db/migrate/20100925074559_create_agent_import_results.rb +0 -1
- data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +1 -1
- data/spec/dummy/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +11 -0
- data/spec/dummy/db/migrate/20110913120629_add_lft_and_rgt_to_classification.rb +11 -0
- data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
- data/spec/dummy/db/migrate/{20111201155513_add_devise_to_users.rb → 20111201155456_devise_create_users.rb} +9 -17
- data/spec/dummy/db/migrate/{20100606065209_create_user_has_roles.rb → 20111201163718_create_user_has_roles.rb} +0 -2
- data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +6 -0
- data/spec/dummy/db/migrate/20120224094141_create_delayed_jobs.rb +22 -0
- data/spec/dummy/db/migrate/20120406020752_add_url_to_subject.rb +5 -0
- data/spec/dummy/db/migrate/20130303124821_add_retained_at_to_reserve.rb +5 -0
- data/spec/dummy/db/migrate/20130304015019_add_postponed_at_to_reserve.rb +5 -0
- data/spec/dummy/db/migrate/20130416054135_add_circulation_status_id_to_item.rb +8 -0
- data/spec/dummy/db/migrate/20130504133816_add_manifestation_id_to_subject.rb +6 -0
- data/spec/dummy/db/migrate/20130504143515_add_manifestation_id_to_classification.rb +6 -0
- data/spec/dummy/db/migrate/20130504195916_add_subject_heading_type_id_to_subject.rb +5 -0
- data/spec/dummy/db/migrate/20130519065638_add_lock_version_to_reserve.rb +5 -0
- data/spec/dummy/db/migrate/20130519065837_add_lock_version_to_checkin.rb +5 -0
- data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +1 -1
- data/spec/dummy/db/migrate/20140518050147_create_reserve_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140528045518_create_user_checkout_stat_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140528045539_create_user_reserve_stat_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140528045600_create_manifestation_checkout_stat_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140528045617_create_manifestation_reserve_stat_transitions.rb +14 -0
- data/spec/dummy/db/migrate/20140810061942_add_user_id_to_user_checkout_stat.rb +12 -0
- data/spec/dummy/db/migrate/20140810091231_add_checkout_icalendar_token_to_profile.rb +6 -0
- data/spec/dummy/db/migrate/20140810091417_add_save_checkout_history_to_profile.rb +5 -0
- data/spec/dummy/db/migrate/20140811031145_add_expired_at_to_profile.rb +5 -0
- data/spec/dummy/db/migrate/20140813182425_add_publication_place_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20140822114527_add_error_message_to_resource_import_result.rb +5 -0
- data/spec/dummy/db/migrate/20140823083524_add_extent_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20140823094847_add_dimensions_to_manifestation.rb +5 -0
- data/spec/dummy/db/migrate/20140823095740_rename_manifestation_periodical_to_serial.rb +9 -0
- data/spec/dummy/db/schema.rb +828 -565
- 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_1vs +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002429 +0 -0
- data/spec/dummy/solr/default/data/tlog/{tlog.0000000000000000300 → tlog.0000000000000002430} +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002431 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002432 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002433 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002434 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002435 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002436 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002437 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000002438 +0 -0
- data/spec/fixtures/checkout_types.yml +34 -0
- data/spec/fixtures/circulation_statuses.yml +120 -0
- data/spec/fixtures/manifestations.yml +5 -5
- data/spec/fixtures/users.yml +1 -1
- metadata +145 -49
- data/spec/dummy/db/migrate/041_create_roles.rb +0 -13
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +0 -8
- data/spec/dummy/solr/default/data/index/segments_8m +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000299 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000301 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000302 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000303 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000304 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000305 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000306 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000307 +0 -0
- data/spec/dummy/solr/default/data/tlog/tlog.0000000000000000308 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db479211c5aa5bcee491d61771df0b9b65534259
|
4
|
+
data.tar.gz: 3e33b0aae96bed63858a2cec5c308dc5a854fa00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa7fa8ff67ff51148cf927b5da4cbbff9f9dc5d9f99407b2fe25c5c0b4ce385f53f283c59b2cdc023cbedbcb3f36235e21be47655701cea953dfa867f346a8af
|
7
|
+
data.tar.gz: 6814f8e114f61b0867df640ab89b5eae1683f8594b91dd182cda2a9d4c79e9c4af94db6b4c862bf349311d5eceea2a710b3acf24ed4ec022fd773f139857b6ad
|
data/app/models/bookmark.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
class Bookmark < ActiveRecord::Base
|
3
3
|
attr_accessible :title, :url, :note, :shared, :tag_list
|
4
|
-
scope :bookmarked, lambda {|start_date, end_date|
|
5
|
-
scope :user_bookmarks, lambda {|user| where(:
|
6
|
-
scope :shared, where(:
|
4
|
+
scope :bookmarked, lambda {|start_date, end_date| where('created_at >= ? AND created_at < ?', start_date, end_date)}
|
5
|
+
scope :user_bookmarks, lambda {|user| where(user_id: user.id)}
|
6
|
+
scope :shared, where(shared: true)
|
7
7
|
belongs_to :manifestation, touch: true
|
8
|
-
belongs_to :user #, :
|
8
|
+
belongs_to :user #, counter_cache: true, validate: true
|
9
9
|
|
10
10
|
validates_presence_of :user, :title
|
11
11
|
validates_presence_of :url, on: :create
|
12
12
|
validates_presence_of :manifestation_id, on: :update
|
13
13
|
validates_associated :user, :manifestation
|
14
14
|
validates_uniqueness_of :manifestation_id, scope: :user_id
|
15
|
-
validates :url, url: true, presence: true, length: {:
|
15
|
+
validates :url, url: true, presence: true, length: {maximum: 255}
|
16
16
|
validate :bookmarkable_url?
|
17
|
-
validate :already_bookmarked?, :
|
18
|
-
before_save :create_manifestation, :
|
17
|
+
validate :already_bookmarked?, if: :url_changed?
|
18
|
+
before_save :create_manifestation, if: :url_changed?
|
19
19
|
before_save :replace_space_in_tags
|
20
20
|
|
21
21
|
acts_as_taggable_on :tags
|
@@ -76,7 +76,7 @@ class Bookmark < ActiveRecord::Base
|
|
76
76
|
end
|
77
77
|
unless manifestation
|
78
78
|
normalized_url = Addressable::URI.parse(url).normalize.to_s
|
79
|
-
doc = Nokogiri::HTML(
|
79
|
+
doc = Nokogiri::HTML(Faraday.get(normalized_url).body)
|
80
80
|
# TODO: 日本語以外
|
81
81
|
#charsets = ['iso-2022-jp', 'euc-jp', 'shift_jis', 'iso-8859-1']
|
82
82
|
#if charsets.include?(page.charset.downcase)
|
@@ -96,7 +96,7 @@ class Bookmark < ActiveRecord::Base
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def self.get_canonical_url(url)
|
99
|
-
doc = Nokogiri::HTML(
|
99
|
+
doc = Nokogiri::HTML(Faraday.get(url).body)
|
100
100
|
canonical_url = doc.search("/html/head/link[@rel='canonical']").first['href']
|
101
101
|
# TODO: URLを相対指定している時
|
102
102
|
Addressable::URI.parse(canonical_url).normalize.to_s
|
@@ -126,7 +126,7 @@ class Bookmark < ActiveRecord::Base
|
|
126
126
|
if url.try(:my_host?)
|
127
127
|
manifestation = self.my_host_resource
|
128
128
|
else
|
129
|
-
manifestation = Manifestation.where(:
|
129
|
+
manifestation = Manifestation.where(access_address: url).first if url.present?
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
@@ -144,7 +144,7 @@ class Bookmark < ActiveRecord::Base
|
|
144
144
|
self.manifestation_id = manifestation.id
|
145
145
|
return
|
146
146
|
end
|
147
|
-
manifestation = Manifestation.new(:
|
147
|
+
manifestation = Manifestation.new(access_address: url)
|
148
148
|
manifestation.carrier_type = CarrierType.where(name: 'file').first
|
149
149
|
if title.present?
|
150
150
|
manifestation.original_title = title
|
@@ -170,7 +170,7 @@ class Bookmark < ActiveRecord::Base
|
|
170
170
|
|
171
171
|
def self.manifestations_count(start_date, end_date, manifestation)
|
172
172
|
if manifestation
|
173
|
-
self.bookmarked(start_date, end_date).where(:
|
173
|
+
self.bookmarked(start_date, end_date).where(manifestation_id: manifestation.id).count
|
174
174
|
else
|
175
175
|
0
|
176
176
|
end
|
data/lib/enju_bookmark/engine.rb
CHANGED
@@ -7,11 +7,11 @@ module EnjuBookmark
|
|
7
7
|
module ClassMethods
|
8
8
|
def enju_bookmark_manifestation_model
|
9
9
|
include InstanceMethods
|
10
|
-
has_many :bookmarks, :
|
11
|
-
has_many :users, :
|
10
|
+
has_many :bookmarks, dependent: :destroy, foreign_key: :manifestation_id
|
11
|
+
has_many :users, through: :bookmarks
|
12
12
|
|
13
13
|
searchable do
|
14
|
-
string :tag, :
|
14
|
+
string :tag, multiple: true do
|
15
15
|
bookmarks.map{|bookmark| bookmark.tag_list}.flatten
|
16
16
|
end
|
17
17
|
text :tag do
|
@@ -23,7 +23,7 @@ module EnjuBookmark
|
|
23
23
|
|
24
24
|
module InstanceMethods
|
25
25
|
def bookmarked?(user)
|
26
|
-
return true if user.bookmarks.where(:
|
26
|
+
return true if user.bookmarks.where(url: url).first
|
27
27
|
false
|
28
28
|
end
|
29
29
|
|
@@ -15,7 +15,7 @@ describe BookmarkStatsController do
|
|
15
15
|
|
16
16
|
it "assigns all bookmark_stats as @bookmark_stats" do
|
17
17
|
get :index
|
18
|
-
expect(assigns(:bookmark_stats)).to eq(BookmarkStat.
|
18
|
+
expect(assigns(:bookmark_stats)).to eq(BookmarkStat.page(1))
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -24,7 +24,7 @@ describe BookmarkStatsController do
|
|
24
24
|
|
25
25
|
it "assigns all bookmark_stats as @bookmark_stats" do
|
26
26
|
get :index
|
27
|
-
expect(assigns(:bookmark_stats)).to eq(BookmarkStat.
|
27
|
+
expect(assigns(:bookmark_stats)).to eq(BookmarkStat.page(1))
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -33,14 +33,14 @@ describe BookmarkStatsController do
|
|
33
33
|
|
34
34
|
it "assigns all bookmark_stats as @bookmark_stats" do
|
35
35
|
get :index
|
36
|
-
expect(assigns(:bookmark_stats)).to eq(BookmarkStat.
|
36
|
+
expect(assigns(:bookmark_stats)).to eq(BookmarkStat.page(1))
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "When not logged in" do
|
41
41
|
it "should not assign bookmark_stats as @bookmark_stats" do
|
42
42
|
get :index
|
43
|
-
expect(assigns(:bookmark_stats)).to eq(BookmarkStat.
|
43
|
+
expect(assigns(:bookmark_stats)).to eq(BookmarkStat.page(1))
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
gemfile = File.expand_path('../../../../Gemfile', __FILE__)
|
2
|
+
gemfile = ENV['BUNDLE_GEMFILE'] || File.expand_path('../../../../Gemfile', __FILE__)
|
3
3
|
|
4
4
|
if File.exist?(gemfile)
|
5
5
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
@@ -7,4 +7,4 @@ if File.exist?(gemfile)
|
|
7
7
|
Bundler.setup
|
8
8
|
end
|
9
9
|
|
10
|
-
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
10
|
+
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# FriendlyId Global Configuration
|
2
|
+
#
|
3
|
+
# Use this to set up shared configuration options for your entire application.
|
4
|
+
# Any of the configuration options shown here can also be applied to single
|
5
|
+
# models by passing arguments to the `friendly_id` class method or defining
|
6
|
+
# methods in your model.
|
7
|
+
#
|
8
|
+
# To learn more, check out the guide:
|
9
|
+
#
|
10
|
+
# http://norman.github.io/friendly_id/file.Guide.html
|
11
|
+
|
12
|
+
if Rails::VERSION::MAJOR == 4
|
13
|
+
FriendlyId.defaults do |config|
|
14
|
+
# ## Reserved Words
|
15
|
+
#
|
16
|
+
# Some words could conflict with Rails's routes when used as slugs, or are
|
17
|
+
# undesirable to allow as slugs. Edit this list as needed for your app.
|
18
|
+
config.use :reserved
|
19
|
+
|
20
|
+
config.reserved_words = %w(new edit index session login logout users admin
|
21
|
+
stylesheets assets javascripts images)
|
22
|
+
|
23
|
+
# ## Friendly Finders
|
24
|
+
#
|
25
|
+
# Uncomment this to use friendly finders in all models. By default, if
|
26
|
+
# you wish to find a record by its friendly id, you must do:
|
27
|
+
#
|
28
|
+
# MyModel.friendly.find('foo')
|
29
|
+
#
|
30
|
+
# If you uncomment this, you can do:
|
31
|
+
#
|
32
|
+
# MyModel.find('foo')
|
33
|
+
#
|
34
|
+
# This is significantly more convenient but may not be appropriate for
|
35
|
+
# all applications, so you must explicity opt-in to this behavior. You can
|
36
|
+
# always also configure it on a per-model basis if you prefer.
|
37
|
+
#
|
38
|
+
# Something else to consider is that using the :finders addon boosts
|
39
|
+
# performance because it will avoid Rails-internal code that makes runtime
|
40
|
+
# calls to `Module.extend`.
|
41
|
+
#
|
42
|
+
config.use :finders
|
43
|
+
#
|
44
|
+
# ## Slugs
|
45
|
+
#
|
46
|
+
# Most applications will use the :slugged module everywhere. If you wish
|
47
|
+
# to do so, uncomment the following line.
|
48
|
+
#
|
49
|
+
# config.use :slugged
|
50
|
+
#
|
51
|
+
# By default, FriendlyId's :slugged addon expects the slug column to be named
|
52
|
+
# 'slug', but you can change it if you wish.
|
53
|
+
#
|
54
|
+
# config.slug_column = 'slug'
|
55
|
+
#
|
56
|
+
# When FriendlyId can not generate a unique ID from your base method, it appends
|
57
|
+
# a UUID, separated by a single dash. You can configure the character used as the
|
58
|
+
# separator. If you're upgrading from FriendlyId 4, you may wish to replace this
|
59
|
+
# with two dashes.
|
60
|
+
#
|
61
|
+
# config.sequence_separator = '-'
|
62
|
+
#
|
63
|
+
# ## Tips and Tricks
|
64
|
+
#
|
65
|
+
# ### Controlling when slugs are generated
|
66
|
+
#
|
67
|
+
# As of FriendlyId 5.0, new slugs are generated only when the slug field is
|
68
|
+
# nil, but if you're using a column as your base method can change this
|
69
|
+
# behavior by overriding the `should_generate_new_friendly_id` method that
|
70
|
+
# FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave
|
71
|
+
# more like 4.0.
|
72
|
+
#
|
73
|
+
# config.use Module.new {
|
74
|
+
# def should_generate_new_friendly_id?
|
75
|
+
# slug.blank? || <your_column_name_here>_changed?
|
76
|
+
# end
|
77
|
+
# }
|
78
|
+
#
|
79
|
+
# FriendlyId uses Rails's `parameterize` method to generate slugs, but for
|
80
|
+
# languages that don't use the Roman alphabet, that's not usually suffient. Here
|
81
|
+
# we use the Babosa library to transliterate Russian Cyrillic slugs to ASCII. If
|
82
|
+
# you use this, don't forget to add "babosa" to your Gemfile.
|
83
|
+
#
|
84
|
+
# config.use Module.new {
|
85
|
+
# def normalize_friendly_id(text)
|
86
|
+
# text.to_slug.normalize! :transliterations => [:russian, :latin]
|
87
|
+
# end
|
88
|
+
# }
|
89
|
+
end
|
90
|
+
end
|
Binary file
|
@@ -13,7 +13,6 @@ class CreateManifestations < ActiveRecord::Migration
|
|
13
13
|
t.string :access_address
|
14
14
|
t.integer :language_id, :default => 1, :null => false
|
15
15
|
t.integer :carrier_type_id, :default => 1, :null => false
|
16
|
-
t.integer :extent_id, :default => 1, :null => false
|
17
16
|
t.integer :start_page
|
18
17
|
t.integer :end_page
|
19
18
|
t.integer :height
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class CreateSubjects < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :subjects do |t|
|
4
|
+
t.integer :parent_id
|
5
|
+
t.integer :use_term_id
|
6
|
+
t.string :term
|
7
|
+
t.text :term_transcription
|
8
|
+
t.integer :subject_type_id, :null => false
|
9
|
+
t.text :scope_note
|
10
|
+
t.text :note
|
11
|
+
t.integer :required_role_id, :default => 1, :null => false
|
12
|
+
t.integer :lock_version, :default => 0, :null => false
|
13
|
+
t.datetime :created_at
|
14
|
+
t.datetime :updated_at
|
15
|
+
t.datetime :deleted_at
|
16
|
+
end
|
17
|
+
add_index :subjects, :term
|
18
|
+
add_index :subjects, :parent_id
|
19
|
+
add_index :subjects, :use_term_id
|
20
|
+
add_index :subjects, :subject_type_id
|
21
|
+
add_index :subjects, :required_role_id
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.down
|
25
|
+
drop_table :subjects
|
26
|
+
end
|
27
|
+
end
|
@@ -10,8 +10,7 @@ class CreateReserves < ActiveRecord::Migration
|
|
10
10
|
t.datetime :canceled_at
|
11
11
|
t.datetime :expired_at
|
12
12
|
t.datetime :deleted_at
|
13
|
-
t.
|
14
|
-
t.boolean :expiration_notice_to_agent, :default => false
|
13
|
+
t.boolean :expiration_notice_to_patron, :default => false
|
15
14
|
t.boolean :expiration_notice_to_library, :default => false
|
16
15
|
end
|
17
16
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class CreateLibraries < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def self.up
|
3
3
|
create_table :libraries do |t|
|
4
4
|
t.string :name, :null => false
|
5
5
|
t.text :display_name
|
@@ -25,4 +25,8 @@ class CreateLibraries < ActiveRecord::Migration
|
|
25
25
|
add_index :libraries, :library_group_id
|
26
26
|
add_index :libraries, :name, :unique => true
|
27
27
|
end
|
28
|
+
|
29
|
+
def self.down
|
30
|
+
drop_table :libraries
|
31
|
+
end
|
28
32
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class CreateShelves < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def self.up
|
3
3
|
create_table :shelves do |t|
|
4
4
|
t.string :name, :null => false
|
5
5
|
t.text :display_name
|
@@ -12,4 +12,8 @@ class CreateShelves < ActiveRecord::Migration
|
|
12
12
|
end
|
13
13
|
add_index :shelves, :library_id
|
14
14
|
end
|
15
|
+
|
16
|
+
def self.down
|
17
|
+
drop_table :shelves
|
18
|
+
end
|
15
19
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
class CreateUserGroups < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def self.up
|
3
3
|
create_table :user_groups do |t|
|
4
|
-
t.string :name, :not_null => true
|
5
|
-
t.text :display_name
|
4
|
+
t.string :name, :string, :not_null => true
|
5
|
+
t.text :display_name, :string
|
6
6
|
t.text :note
|
7
7
|
t.integer :position
|
8
8
|
t.timestamps
|
9
9
|
t.datetime :deleted_at
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :user_groups
|
15
|
+
end
|
12
16
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class CreateLibraryGroups < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def self.up
|
3
3
|
create_table :library_groups do |t|
|
4
4
|
t.string :name, :null => false
|
5
5
|
t.text :display_name
|
@@ -11,10 +11,15 @@ class CreateLibraryGroups < ActiveRecord::Migration
|
|
11
11
|
t.text :login_banner
|
12
12
|
t.text :note
|
13
13
|
t.integer :valid_period_for_new_user, :default => 365, :null => false
|
14
|
+
t.boolean :post_to_union_catalog, :default => false, :null => false
|
14
15
|
t.integer :country_id
|
15
16
|
|
16
17
|
t.timestamps
|
17
18
|
end
|
18
19
|
add_index :library_groups, :short_name
|
19
20
|
end
|
21
|
+
|
22
|
+
def self.down
|
23
|
+
drop_table :library_groups
|
24
|
+
end
|
20
25
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateEvents < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :events do |t|
|
4
|
+
t.integer :library_id, :default => 1, :null => false
|
5
|
+
t.integer :event_category_id, :default => 1, :null => false
|
6
|
+
t.string :name
|
7
|
+
t.text :note
|
8
|
+
t.datetime :start_at
|
9
|
+
t.datetime :end_at
|
10
|
+
t.boolean :all_day, :default => false, :null => false
|
11
|
+
t.datetime :deleted_at
|
12
|
+
t.text :display_name
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
add_index :events, :library_id
|
17
|
+
add_index :events, :event_category_id
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.down
|
21
|
+
drop_table :events
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateEventCategories < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :event_categories do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.text :display_name
|
6
|
+
t.text :note
|
7
|
+
t.integer :position
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :event_categories
|
15
|
+
end
|
16
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class CreateRequestStatusTypes < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def self.up
|
3
3
|
create_table :request_status_types do |t|
|
4
4
|
t.string :name, :null => false
|
5
5
|
t.text :display_name
|
@@ -9,4 +9,8 @@ class CreateRequestStatusTypes < ActiveRecord::Migration
|
|
9
9
|
t.timestamps
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :request_status_types
|
15
|
+
end
|
12
16
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class CreateRequestTypes < ActiveRecord::Migration
|
2
|
-
def
|
2
|
+
def self.up
|
3
3
|
create_table :request_types do |t|
|
4
4
|
t.string :name, :null => false
|
5
5
|
t.text :display_name
|
@@ -9,4 +9,8 @@ class CreateRequestTypes < ActiveRecord::Migration
|
|
9
9
|
t.timestamps
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :request_types
|
15
|
+
end
|
12
16
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateAgentMerges < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :agent_merges do |t|
|
4
|
+
t.integer :agent_id, :agent_merge_list_id, :null => false
|
5
|
+
|
6
|
+
t.timestamps
|
7
|
+
end
|
8
|
+
add_index :agent_merges, :agent_id
|
9
|
+
add_index :agent_merges, :agent_merge_list_id
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :agent_merges
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateClassifications < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :classifications do |t|
|
4
|
+
t.integer :parent_id
|
5
|
+
t.string :category, :null => false
|
6
|
+
t.text :note
|
7
|
+
t.integer :classification_type_id, :null => false
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
add_index :classifications, :parent_id
|
12
|
+
add_index :classifications, :category
|
13
|
+
add_index :classifications, :classification_type_id
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.down
|
17
|
+
drop_table :classifications
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateClassificationTypes < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :classification_types do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.text :display_name
|
6
|
+
t.text :note
|
7
|
+
t.integer :position
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :classification_types
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateSubjectHeadingTypes < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :subject_heading_types do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.text :display_name
|
6
|
+
t.text :note
|
7
|
+
t.integer :position
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :subject_heading_types
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateSubjectTypes < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :subject_types do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.text :display_name
|
6
|
+
t.text :note
|
7
|
+
t.integer :position
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :subject_types
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateMessageTemplates < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :message_templates do |t|
|
4
|
+
t.string :status, :null => false
|
5
|
+
t.text :title, :null => false
|
6
|
+
t.text :body, :null => false
|
7
|
+
t.integer :position
|
8
|
+
t.string :locale, :default => I18n.default_locale.to_s
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
add_index :message_templates, :status, :unique => true
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table :message_templates
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateMessages < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :messages, :force => true do |t|
|
4
|
+
t.datetime :read_at
|
5
|
+
t.integer :receiver_id, :sender_id
|
6
|
+
t.string :subject, :null => false
|
7
|
+
t.text :body
|
8
|
+
t.integer :message_request_id
|
9
|
+
t.integer :parent_id
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :messages, :sender_id
|
15
|
+
add_index :messages, :receiver_id
|
16
|
+
add_index :messages, :message_request_id
|
17
|
+
add_index :messages, :parent_id
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.down
|
21
|
+
drop_table :messages
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateMessageRequests < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :message_requests do |t|
|
4
|
+
t.integer :sender_id
|
5
|
+
t.integer :receiver_id
|
6
|
+
t.integer :message_template_id
|
7
|
+
t.datetime :sent_at
|
8
|
+
t.datetime :deleted_at
|
9
|
+
t.text :body
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table :message_requests
|
17
|
+
end
|
18
|
+
end
|