enju_event 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/Rakefile +10 -0
- data/app/models/event.rb +3 -0
- data/app/models/event_category.rb +1 -0
- data/app/models/event_import_file.rb +9 -4
- data/app/models/event_import_result.rb +1 -0
- data/app/models/participate.rb +1 -0
- data/lib/enju_event/engine.rb +1 -1
- data/lib/enju_event/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/private/system/event_import_files/event_imports/000/000/001/original/event_import_file_sample1.tsv +5 -0
- data/spec/dummy/private/system/event_import_files/event_imports/000/000/001/original/event_import_file_sample2.tsv +3 -0
- data/spec/dummy/private/system/event_imports/4/original/event_destroy_file.tsv +4 -0
- data/spec/dummy/private/system/event_imports/4/original/event_import_file_sample1.tsv +1 -1
- data/spec/dummy/private/system/event_imports/4/original/event_import_file_sample2.tsv +1 -1
- data/spec/dummy/private/system/event_imports/4/original/event_update_file.tsv +4 -0
- data/spec/dummy/solr/data/test/index/_2s.fdt +0 -0
- data/spec/dummy/solr/data/test/index/_2s.fdx +0 -0
- data/spec/dummy/solr/data/test/index/_2s.fnm +4 -0
- data/spec/dummy/solr/data/test/index/_2s.frq +0 -0
- data/spec/dummy/solr/data/test/index/_2s.nrm +1 -0
- data/spec/dummy/solr/data/test/index/_2s.prx +0 -0
- data/spec/dummy/solr/data/test/index/_2s.tii +0 -0
- data/spec/dummy/solr/data/test/index/_2s.tis +0 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_2k +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
- metadata +30 -4
- data/spec/dummy/solr/data/test/index/segments_1 +0 -0
data/MIT-LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -29,8 +29,18 @@ Bundler::GemHelper.install_tasks
|
|
29
29
|
require 'rspec/core'
|
30
30
|
require 'rspec/core/rake_task'
|
31
31
|
|
32
|
+
require 'rake/testtask'
|
33
|
+
|
34
|
+
Rake::TestTask.new(:test) do |t|
|
35
|
+
t.libs << 'lib'
|
36
|
+
t.libs << 'test'
|
37
|
+
t.pattern = 'test/**/*_test.rb'
|
38
|
+
t.verbose = false
|
39
|
+
end
|
40
|
+
|
32
41
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
33
42
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
34
43
|
end
|
35
44
|
|
45
|
+
|
36
46
|
task :default => :spec
|
data/app/models/event.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
class Event < ActiveRecord::Base
|
3
|
+
attr_accessible :library_id, :event_category_id, :name, :note, :start_at,
|
4
|
+
:event_at, :all_day, :display_name
|
5
|
+
|
3
6
|
scope :closing_days, includes(:event_category).where('event_categories.name = ?', 'closed')
|
4
7
|
scope :on, lambda {|datetime| where('start_at >= ? AND start_at < ?', datetime.beginning_of_day, datetime.tomorrow.beginning_of_day + 1)}
|
5
8
|
scope :past, lambda {|datetime| where('end_at <= ?', Time.zone.parse(datetime).beginning_of_day)}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
class EventImportFile < ActiveRecord::Base
|
2
|
+
attr_accessible :event_import
|
2
3
|
include ImportFile
|
3
4
|
default_scope :order => 'id DESC'
|
4
5
|
scope :not_imported, where(:state => 'pending')
|
@@ -62,7 +63,9 @@ class EventImportFile < ActiveRecord::Base
|
|
62
63
|
|
63
64
|
rows.each do |row|
|
64
65
|
next if row['dummy'].to_s.strip.present?
|
65
|
-
|
66
|
+
event_import_result = EventImportResult.new
|
67
|
+
event_import_result.assign_attributes({:event_import_file_id => self.id, :body => row.fields.join("\t")}, :as => :admin)
|
68
|
+
event_import_result.save!
|
66
69
|
|
67
70
|
event = Event.new
|
68
71
|
event.name = row['name'].to_s.strip
|
@@ -82,14 +85,14 @@ class EventImportFile < ActiveRecord::Base
|
|
82
85
|
event.event_category = event_category
|
83
86
|
|
84
87
|
if event.save!
|
85
|
-
|
88
|
+
event_import_result.event = event
|
86
89
|
num[:imported] += 1
|
87
90
|
if row_num % 50 == 0
|
88
91
|
Sunspot.commit
|
89
92
|
GC.start
|
90
93
|
end
|
91
94
|
end
|
92
|
-
|
95
|
+
event_import_result.save!
|
93
96
|
row_num += 1
|
94
97
|
end
|
95
98
|
Sunspot.commit
|
@@ -179,7 +182,9 @@ class EventImportFile < ActiveRecord::Base
|
|
179
182
|
file = CSV.open(tempfile, :col_sep => "\t")
|
180
183
|
header = file.first
|
181
184
|
rows = CSV.open(tempfile, :headers => header, :col_sep => "\t")
|
182
|
-
|
185
|
+
event_import_result = EventImportResult.new
|
186
|
+
event_import_result.assign_attributes({:event_import_file_id => self.id, :body => header.join("\t")}, :as => :admin)
|
187
|
+
event_import_result.save!
|
183
188
|
tempfile.close(true)
|
184
189
|
file.close
|
185
190
|
rows
|
@@ -1,4 +1,5 @@
|
|
1
1
|
class EventImportResult < ActiveRecord::Base
|
2
|
+
attr_accessible :event_id, :event_import_file_id, :body, :as => :admin
|
2
3
|
default_scope :order => 'event_import_results.id'
|
3
4
|
scope :file_id, proc{|file_id| {:conditions => {:event_import_file_id => file_id}}}
|
4
5
|
scope :failed, where(:event_id => nil)
|
data/app/models/participate.rb
CHANGED
data/lib/enju_event/engine.rb
CHANGED
data/lib/enju_event/version.rb
CHANGED
Binary file
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
NRM�xxvx|u|||||||||||||||||||||||||�|ut�u��|||||
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enju_event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
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-05-
|
12
|
+
date: 2012-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -477,6 +477,7 @@ files:
|
|
477
477
|
- spec/dummy/config/locales/en.yml
|
478
478
|
- spec/dummy/config/routes.rb
|
479
479
|
- spec/dummy/config.ru
|
480
|
+
- spec/dummy/db/development.sqlite3
|
480
481
|
- spec/dummy/db/migrate/001_create_patrons.rb
|
481
482
|
- spec/dummy/db/migrate/059_create_libraries.rb
|
482
483
|
- spec/dummy/db/migrate/069_create_shelves.rb
|
@@ -503,12 +504,16 @@ files:
|
|
503
504
|
- spec/dummy/lib/enju_leaf/master_model.rb
|
504
505
|
- spec/dummy/lib/enju_leaf/url_validator.rb
|
505
506
|
- spec/dummy/lib/enju_leaf.rb
|
507
|
+
- spec/dummy/private/system/event_import_files/event_imports/000/000/001/original/event_import_file_sample1.tsv
|
508
|
+
- spec/dummy/private/system/event_import_files/event_imports/000/000/001/original/event_import_file_sample2.tsv
|
506
509
|
- spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_destroy_file.tsv
|
507
510
|
- spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_import_file_sample1.tsv
|
508
511
|
- spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_import_file_sample2.tsv
|
509
512
|
- spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_update_file.tsv
|
513
|
+
- spec/dummy/private/system/event_imports/4/original/event_destroy_file.tsv
|
510
514
|
- spec/dummy/private/system/event_imports/4/original/event_import_file_sample1.tsv
|
511
515
|
- spec/dummy/private/system/event_imports/4/original/event_import_file_sample2.tsv
|
516
|
+
- spec/dummy/private/system/event_imports/4/original/event_update_file.tsv
|
512
517
|
- spec/dummy/public/404.html
|
513
518
|
- spec/dummy/public/422.html
|
514
519
|
- spec/dummy/public/500.html
|
@@ -525,8 +530,16 @@ files:
|
|
525
530
|
- spec/dummy/solr/conf/spellings.txt
|
526
531
|
- spec/dummy/solr/conf/stopwords.txt
|
527
532
|
- spec/dummy/solr/conf/synonyms.txt
|
533
|
+
- spec/dummy/solr/data/test/index/_2s.fdt
|
534
|
+
- spec/dummy/solr/data/test/index/_2s.fdx
|
535
|
+
- spec/dummy/solr/data/test/index/_2s.fnm
|
536
|
+
- spec/dummy/solr/data/test/index/_2s.frq
|
537
|
+
- spec/dummy/solr/data/test/index/_2s.nrm
|
538
|
+
- spec/dummy/solr/data/test/index/_2s.prx
|
539
|
+
- spec/dummy/solr/data/test/index/_2s.tii
|
540
|
+
- spec/dummy/solr/data/test/index/_2s.tis
|
528
541
|
- spec/dummy/solr/data/test/index/segments.gen
|
529
|
-
- spec/dummy/solr/data/test/index/
|
542
|
+
- spec/dummy/solr/data/test/index/segments_2k
|
530
543
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
531
544
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
532
545
|
- spec/factories/country.rb
|
@@ -631,6 +644,7 @@ test_files:
|
|
631
644
|
- spec/dummy/config/locales/en.yml
|
632
645
|
- spec/dummy/config/routes.rb
|
633
646
|
- spec/dummy/config.ru
|
647
|
+
- spec/dummy/db/development.sqlite3
|
634
648
|
- spec/dummy/db/migrate/001_create_patrons.rb
|
635
649
|
- spec/dummy/db/migrate/059_create_libraries.rb
|
636
650
|
- spec/dummy/db/migrate/069_create_shelves.rb
|
@@ -657,12 +671,16 @@ test_files:
|
|
657
671
|
- spec/dummy/lib/enju_leaf/master_model.rb
|
658
672
|
- spec/dummy/lib/enju_leaf/url_validator.rb
|
659
673
|
- spec/dummy/lib/enju_leaf.rb
|
674
|
+
- spec/dummy/private/system/event_import_files/event_imports/000/000/001/original/event_import_file_sample1.tsv
|
675
|
+
- spec/dummy/private/system/event_import_files/event_imports/000/000/001/original/event_import_file_sample2.tsv
|
660
676
|
- spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_destroy_file.tsv
|
661
677
|
- spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_import_file_sample1.tsv
|
662
678
|
- spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_import_file_sample2.tsv
|
663
679
|
- spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_update_file.tsv
|
680
|
+
- spec/dummy/private/system/event_imports/4/original/event_destroy_file.tsv
|
664
681
|
- spec/dummy/private/system/event_imports/4/original/event_import_file_sample1.tsv
|
665
682
|
- spec/dummy/private/system/event_imports/4/original/event_import_file_sample2.tsv
|
683
|
+
- spec/dummy/private/system/event_imports/4/original/event_update_file.tsv
|
666
684
|
- spec/dummy/public/404.html
|
667
685
|
- spec/dummy/public/422.html
|
668
686
|
- spec/dummy/public/500.html
|
@@ -679,8 +697,16 @@ test_files:
|
|
679
697
|
- spec/dummy/solr/conf/spellings.txt
|
680
698
|
- spec/dummy/solr/conf/stopwords.txt
|
681
699
|
- spec/dummy/solr/conf/synonyms.txt
|
700
|
+
- spec/dummy/solr/data/test/index/_2s.fdt
|
701
|
+
- spec/dummy/solr/data/test/index/_2s.fdx
|
702
|
+
- spec/dummy/solr/data/test/index/_2s.fnm
|
703
|
+
- spec/dummy/solr/data/test/index/_2s.frq
|
704
|
+
- spec/dummy/solr/data/test/index/_2s.nrm
|
705
|
+
- spec/dummy/solr/data/test/index/_2s.prx
|
706
|
+
- spec/dummy/solr/data/test/index/_2s.tii
|
707
|
+
- spec/dummy/solr/data/test/index/_2s.tis
|
682
708
|
- spec/dummy/solr/data/test/index/segments.gen
|
683
|
-
- spec/dummy/solr/data/test/index/
|
709
|
+
- spec/dummy/solr/data/test/index/segments_2k
|
684
710
|
- spec/dummy/solr/data/test/spellchecker/segments.gen
|
685
711
|
- spec/dummy/solr/data/test/spellchecker/segments_1
|
686
712
|
- spec/factories/country.rb
|
Binary file
|