enju_inventory 0.1.11.pre10 → 0.1.11.pre11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +8 -1
- data/app/controllers/inventories_controller.rb +5 -54
- data/app/controllers/inventory_files_controller.rb +7 -2
- data/app/models/inventory.rb +0 -1
- data/app/models/inventory_file.rb +9 -9
- data/config/routes.rb +1 -1
- data/lib/enju_inventory/version.rb +1 -1
- data/spec/controllers/inventories_controller_spec.rb +0 -80
- data/spec/controllers/inventory_files_controller_spec.rb +4 -4
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config/boot.rb +2 -2
- data/spec/dummy/config/database.yml +23 -18
- data/spec/dummy/db/migrate/005_create_manifestations.rb +0 -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/20110627035057_create_series_statement_merges.rb +1 -1
- data/spec/dummy/db/migrate/20140519170214_create_resource_import_file_transitions.rb +5 -1
- data/spec/dummy/db/migrate/20140519171220_create_import_request_transitions.rb +5 -1
- data/spec/dummy/db/migrate/20140524020735_create_agent_import_file_transitions.rb +5 -1
- data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +5 -1
- data/spec/dummy/db/migrate/20140614141500_create_resource_export_file_transitions.rb +5 -1
- data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +5 -1
- 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/migrate/20141003181336_add_full_name_transcription_to_profile.rb +5 -0
- data/spec/dummy/db/migrate/20141003182825_add_date_of_birth_to_profile.rb +5 -0
- data/spec/dummy/db/schema.rb +403 -383
- data/spec/fixtures/users.yml +1 -1
- data/spec/spec_helper.rb +2 -0
- metadata +61 -19
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/private/system/inventory_files/inventories/000/000/001/original/inventory_file_sample.tsv +0 -7
- data/spec/dummy/private/system/inventory_files/inventories/000/000/004/original/inventory_file_sample.tsv +0 -7
- data/spec/dummy/script/rails +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7782a89c54218e1d5d7ae05c185feff459645059
|
4
|
+
data.tar.gz: 349a375293e71197ac9bcb104d10abbb1f739295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ac04b9924e66a97e0079fbcf1b24aa86a5a8b56b6dab6250199268671b08de00741efbf9717cbdb617857a7e159695eda3915d3db1398a6e354c147e09b003b
|
7
|
+
data.tar.gz: 07d91952250199a5b5cb730d4cfbf4878a308c04acd5c1375a67396b1cdcf2c0103f2e19ba986b144c22b3cbe80f3d4944571982cb1af43e6e0f30e6d1bb1051
|
data/README.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
1
|
= EnjuInventory
|
2
|
+
{<img src="https://secure.travis-ci.org/next-l/enju_inventory.png?branch=1.1" alt="Build Status" />}[http://travis-ci.org/next-l/enju_inventory]
|
3
|
+
{<img src="https://coveralls.io/repos/next-l/enju_inventory/badge.png?branch=1.1" alt="Coverage Status" />}[https://coveralls.io/r/next-l/enju_inventory?branch=1.1]
|
4
|
+
{<img src="https://hakiri.io/github/next-l/enju_inventory/1.1.svg" alt="security" />}[https://hakiri.io/github/next-l/enju_inventory/1.1]
|
2
5
|
|
3
|
-
This project rocks and uses MIT-LICENSE.
|
6
|
+
This project rocks and uses MIT-LICENSE.
|
7
|
+
|
8
|
+
== 製作者・貢献者 (Authors and contributors)
|
9
|
+
* {TANABE, Kosuke}[https://github.com/nabeta] ({@nabeta}[https://twitter.com/nabeta])
|
10
|
+
* {Project Next-L}[http://www.next-l.jp] ({@ProjectNextL}[https://twitter.com/ProjectNextL])
|
@@ -20,59 +20,10 @@ class InventoriesController < ApplicationController
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
respond_to do |format|
|
29
|
-
format.html # new.html.erb
|
30
|
-
format.json { render json: @inventory }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# GET /inventories/1/edit
|
35
|
-
def edit
|
36
|
-
end
|
37
|
-
|
38
|
-
# POST /inventories
|
39
|
-
# POST /inventories.json
|
40
|
-
def create
|
41
|
-
@inventory = Inventory.new(params[:inventory])
|
42
|
-
|
43
|
-
respond_to do |format|
|
44
|
-
if @inventory.save
|
45
|
-
format.html { redirect_to @inventory, notice: t('controller.successfully_created', model: t('activerecord.models.inventory')) }
|
46
|
-
format.json { render json: @inventory, status: :created, location: @inventory }
|
47
|
-
else
|
48
|
-
format.html { render action: "new" }
|
49
|
-
format.json { render json: @inventory.errors, status: :unprocessable_entity }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# PUT /inventories/1
|
55
|
-
# PUT /inventories/1.json
|
56
|
-
def update
|
57
|
-
respond_to do |format|
|
58
|
-
if @inventory.update_attributes(params[:inventory])
|
59
|
-
format.html { redirect_to @inventory, notice: t('controller.successfully_updated', model: t('activerecord.models.inventory')) }
|
60
|
-
format.json { head :no_content }
|
61
|
-
else
|
62
|
-
format.html { render action: "edit" }
|
63
|
-
format.json { render json: @inventory.errors, status: :unprocessable_entity }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
# DELETE /inventories/1
|
69
|
-
# DELETE /inventories/1.json
|
70
|
-
def destroy
|
71
|
-
@inventory.destroy
|
72
|
-
|
73
|
-
respond_to do |format|
|
74
|
-
format.html { redirect_to inventories_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.inventory')) }
|
75
|
-
format.json { head :no_content }
|
76
|
-
end
|
23
|
+
private
|
24
|
+
def inventory_params
|
25
|
+
params.require(:inventory).permit(
|
26
|
+
:item_id, :inventory_id, :note
|
27
|
+
)
|
77
28
|
end
|
78
29
|
end
|
@@ -39,7 +39,7 @@ class InventoryFilesController < ApplicationController
|
|
39
39
|
# POST /inventory_files
|
40
40
|
# POST /inventory_files.json
|
41
41
|
def create
|
42
|
-
@inventory_file = InventoryFile.new(
|
42
|
+
@inventory_file = InventoryFile.new(inventory_file_params)
|
43
43
|
@inventory_file.user = current_user
|
44
44
|
|
45
45
|
respond_to do |format|
|
@@ -59,7 +59,7 @@ class InventoryFilesController < ApplicationController
|
|
59
59
|
# PUT /inventory_files/1.json
|
60
60
|
def update
|
61
61
|
respond_to do |format|
|
62
|
-
if @inventory_file.update_attributes(
|
62
|
+
if @inventory_file.update_attributes(inventory_file_params)
|
63
63
|
flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.inventory_file'))
|
64
64
|
format.html { redirect_to(@inventory_file) }
|
65
65
|
format.json { head :no_content }
|
@@ -80,4 +80,9 @@ class InventoryFilesController < ApplicationController
|
|
80
80
|
format.json { head :no_content }
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
private
|
85
|
+
def inventory_file_params
|
86
|
+
params.require(:inventory_file).permit(:inventory, :note)
|
87
|
+
end
|
83
88
|
end
|
data/app/models/inventory.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
class InventoryFile < ActiveRecord::Base
|
2
|
-
|
3
|
-
has_many :
|
4
|
-
has_many :items, :through => :inventories
|
2
|
+
has_many :inventories, dependent: :destroy
|
3
|
+
has_many :items, through: :inventories
|
5
4
|
belongs_to :user
|
6
5
|
validates_presence_of :user
|
7
6
|
|
8
7
|
if Setting.uploaded_file.storage == :s3
|
9
|
-
has_attached_file :inventory,
|
10
|
-
:
|
8
|
+
has_attached_file :inventory, storage: :s3,
|
9
|
+
s3_credentials: Setting.amazon,
|
10
|
+
s3_permissions: :private
|
11
11
|
else
|
12
12
|
has_attached_file :inventory,
|
13
|
-
:
|
13
|
+
path: ":rails_root/private/system/:class/:attachment/:id_partition/:style/:filename"
|
14
14
|
end
|
15
|
-
validates_attachment_content_type :inventory, :
|
15
|
+
validates_attachment_content_type :inventory, content_type: ['text/csv', 'text/plain', 'text/tab-separated-values']
|
16
16
|
validates_attachment_presence :inventory
|
17
17
|
|
18
18
|
paginates_per 10
|
@@ -22,9 +22,9 @@ class InventoryFile < ActiveRecord::Base
|
|
22
22
|
file = File.open(self.inventory.path)
|
23
23
|
reader = file.read
|
24
24
|
reader.split.each do |row|
|
25
|
-
item = Item.where(:
|
25
|
+
item = Item.where(item_identifier: row.to_s.strip).first
|
26
26
|
if item
|
27
|
-
unless self.items.where(:
|
27
|
+
unless self.items.where(id: item.id).select('items.id').first
|
28
28
|
self.items << item
|
29
29
|
end
|
30
30
|
end
|
data/config/routes.rb
CHANGED
@@ -82,84 +82,4 @@ describe InventoriesController do
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
|
-
|
86
|
-
describe "GET new" do
|
87
|
-
describe "When logged in as Administrator" do
|
88
|
-
login_fixture_admin
|
89
|
-
|
90
|
-
it "assigns the requested inventory as @inventory" do
|
91
|
-
get :new
|
92
|
-
expect(assigns(:inventory)).not_to be_valid
|
93
|
-
expect(response).to be_success
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "When logged in as Librarian" do
|
98
|
-
login_fixture_librarian
|
99
|
-
|
100
|
-
it "should not assign the requested inventory as @inventory" do
|
101
|
-
get :new
|
102
|
-
expect(assigns(:inventory)).not_to be_valid
|
103
|
-
expect(response).to be_success
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "When logged in as User" do
|
108
|
-
login_fixture_user
|
109
|
-
|
110
|
-
it "should not assign the requested inventory as @inventory" do
|
111
|
-
get :new
|
112
|
-
expect(assigns(:inventory)).not_to be_valid
|
113
|
-
expect(response).to be_forbidden
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe "When not logged in" do
|
118
|
-
it "should not assign the requested inventory as @inventory" do
|
119
|
-
get :new
|
120
|
-
expect(assigns(:inventory)).not_to be_valid
|
121
|
-
expect(response).to redirect_to(new_user_session_url)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe "GET edit" do
|
127
|
-
describe "When logged in as Administrator" do
|
128
|
-
login_fixture_admin
|
129
|
-
|
130
|
-
it "assigns the requested inventory as @inventory" do
|
131
|
-
inventory = inventories(:inventory_00001)
|
132
|
-
get :edit, :id => inventory.id
|
133
|
-
expect(assigns(:inventory)).to eq(inventory)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe "When logged in as Librarian" do
|
138
|
-
login_fixture_librarian
|
139
|
-
|
140
|
-
it "assigns the requested inventory as @inventory" do
|
141
|
-
inventory = inventories(:inventory_00001)
|
142
|
-
get :edit, :id => inventory.id
|
143
|
-
expect(assigns(:inventory)).to eq(inventory)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
describe "When logged in as User" do
|
148
|
-
login_fixture_user
|
149
|
-
|
150
|
-
it "assigns the requested inventory as @inventory" do
|
151
|
-
inventory = inventories(:inventory_00001)
|
152
|
-
get :edit, :id => inventory.id
|
153
|
-
expect(response).to be_forbidden
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe "When not logged in" do
|
158
|
-
it "should not assign the requested inventory as @inventory" do
|
159
|
-
inventory = inventories(:inventory_00001)
|
160
|
-
get :edit, :id => inventory.id
|
161
|
-
expect(response).to redirect_to(new_user_session_url)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
85
|
end
|
@@ -194,7 +194,7 @@ describe InventoryFilesController do
|
|
194
194
|
login_fixture_admin
|
195
195
|
|
196
196
|
it "should update inventory_file" do
|
197
|
-
put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { }
|
197
|
+
put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { note: "test" }
|
198
198
|
expect(response).to redirect_to inventory_file_url(assigns(:inventory_file))
|
199
199
|
end
|
200
200
|
end
|
@@ -203,7 +203,7 @@ describe InventoryFilesController do
|
|
203
203
|
login_fixture_librarian
|
204
204
|
|
205
205
|
it "should update inventory_file" do
|
206
|
-
put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { }
|
206
|
+
put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { note: "test" }
|
207
207
|
expect(response).to redirect_to inventory_file_url(assigns(:inventory_file))
|
208
208
|
end
|
209
209
|
end
|
@@ -212,14 +212,14 @@ describe InventoryFilesController do
|
|
212
212
|
login_fixture_user
|
213
213
|
|
214
214
|
it "should not update inventory_file" do
|
215
|
-
put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { }
|
215
|
+
put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { note: "test" }
|
216
216
|
expect(response).to be_forbidden
|
217
217
|
end
|
218
218
|
end
|
219
219
|
|
220
220
|
describe "When not logged in" do
|
221
221
|
it "should not update inventory_file" do
|
222
|
-
put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { }
|
222
|
+
put :update, :id => inventory_files(:inventory_file_00003).id, :inventory_file => { note: "test" }
|
223
223
|
expect(response).to redirect_to new_user_session_url
|
224
224
|
end
|
225
225
|
end
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts "== Installing dependencies =="
|
12
|
+
system "gem install bundler --conservative"
|
13
|
+
system "bundle check || bundle install"
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system "bin/rake db:setup"
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system "rm -f log/*"
|
25
|
+
system "rm -rf tmp/cache"
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system "touch tmp/restart.txt"
|
29
|
+
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__)
|
@@ -1,25 +1,30 @@
|
|
1
|
-
|
2
|
-
# gem install sqlite3
|
3
|
-
#
|
4
|
-
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
-
# gem 'sqlite3'
|
6
|
-
development:
|
1
|
+
sqlite: &sqlite
|
7
2
|
adapter: sqlite3
|
8
|
-
database: db
|
3
|
+
database: db/<%= Rails.env %>.sqlite3
|
4
|
+
|
5
|
+
mysql: &mysql
|
6
|
+
adapter: mysql2
|
7
|
+
username: root
|
8
|
+
password:
|
9
|
+
database: enju_<%= Rails.env %>
|
10
|
+
|
11
|
+
postgresql: &postgresql
|
12
|
+
adapter: postgresql
|
13
|
+
username: postgres
|
14
|
+
password:
|
15
|
+
database: enju_<%= Rails.env %>
|
16
|
+
|
17
|
+
defaults: &defaults
|
9
18
|
pool: 5
|
10
19
|
timeout: 5000
|
20
|
+
host: localhost
|
21
|
+
<<: *<%= ENV['DB'] || "sqlite" %>
|
22
|
+
|
23
|
+
development:
|
24
|
+
<<: *defaults
|
11
25
|
|
12
|
-
# Warning: The database defined as "test" will be erased and
|
13
|
-
# re-generated from your development database when you run "rake".
|
14
|
-
# Do not set this db to the same as development or production.
|
15
26
|
test:
|
16
|
-
|
17
|
-
database: db/test.sqlite3
|
18
|
-
pool: 5
|
19
|
-
timeout: 5000
|
27
|
+
<<: *defaults
|
20
28
|
|
21
29
|
production:
|
22
|
-
|
23
|
-
database: db/production.sqlite3
|
24
|
-
pool: 5
|
25
|
-
timeout: 5000
|
30
|
+
<<: *defaults
|
@@ -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,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
|