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.
Files changed (30) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/Rakefile +10 -0
  3. data/app/models/event.rb +3 -0
  4. data/app/models/event_category.rb +1 -0
  5. data/app/models/event_import_file.rb +9 -4
  6. data/app/models/event_import_result.rb +1 -0
  7. data/app/models/participate.rb +1 -0
  8. data/lib/enju_event/engine.rb +1 -1
  9. data/lib/enju_event/version.rb +1 -1
  10. data/spec/dummy/db/development.sqlite3 +0 -0
  11. data/spec/dummy/db/test.sqlite3 +0 -0
  12. data/spec/dummy/private/system/event_import_files/event_imports/000/000/001/original/event_import_file_sample1.tsv +5 -0
  13. data/spec/dummy/private/system/event_import_files/event_imports/000/000/001/original/event_import_file_sample2.tsv +3 -0
  14. data/spec/dummy/private/system/event_imports/4/original/event_destroy_file.tsv +4 -0
  15. data/spec/dummy/private/system/event_imports/4/original/event_import_file_sample1.tsv +1 -1
  16. data/spec/dummy/private/system/event_imports/4/original/event_import_file_sample2.tsv +1 -1
  17. data/spec/dummy/private/system/event_imports/4/original/event_update_file.tsv +4 -0
  18. data/spec/dummy/solr/data/test/index/_2s.fdt +0 -0
  19. data/spec/dummy/solr/data/test/index/_2s.fdx +0 -0
  20. data/spec/dummy/solr/data/test/index/_2s.fnm +4 -0
  21. data/spec/dummy/solr/data/test/index/_2s.frq +0 -0
  22. data/spec/dummy/solr/data/test/index/_2s.nrm +1 -0
  23. data/spec/dummy/solr/data/test/index/_2s.prx +0 -0
  24. data/spec/dummy/solr/data/test/index/_2s.tii +0 -0
  25. data/spec/dummy/solr/data/test/index/_2s.tis +0 -0
  26. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  27. data/spec/dummy/solr/data/test/index/segments_2k +0 -0
  28. data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
  29. metadata +30 -4
  30. data/spec/dummy/solr/data/test/index/segments_1 +0 -0
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2011 YOURNAME
1
+ Copyright 2012 YOURNAME
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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 EventCategory < ActiveRecord::Base
2
+ attr_accessible :name, :display_name, :note
2
3
  include MasterModel
3
4
  default_scope :order => "position"
4
5
  has_many :events
@@ -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
- import_result = EventImportResult.create!(:event_import_file => self, :body => row.fields.join("\t"))
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
- import_result.event = event
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
- import_result.save!
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
- EventImportResult.create!(:event_import_file => self, :body => header.join("\t"))
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)
@@ -1,4 +1,5 @@
1
1
  class Participate < ActiveRecord::Base
2
+ attr_accessible :patron_id, :event_id
2
3
  belongs_to :patron
3
4
  belongs_to :event
4
5
 
@@ -15,6 +15,6 @@ require "nkf"
15
15
  require "acts_as_list"
16
16
 
17
17
  module EnjuEvent
18
- class Engine < Rails::Engine
18
+ class Engine < ::Rails::Engine
19
19
  end
20
20
  end
@@ -1,3 +1,3 @@
1
1
  module EnjuEvent
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
Binary file
Binary file
@@ -0,0 +1,5 @@
1
+ "name" "category" "library_shortname" "start_at" "end_at" "dummy"
2
+ "イベント名" "カテゴリ。休館日の場合はclosed" "図書館名" "開始日" "終了日" "インポート省略"
3
+ "hogehoge" "おはなし会" "kamata" "2009-04-01" "2009-04-03"
4
+ "hogehoge" "hachioji"
5
+ "休館日" "closed" "kamata" "2011-04-01" "2011-04-03"
@@ -0,0 +1,3 @@
1
+ "name" "library_shortname" "start_at" "end_at"
2
+ "���{��̍Â���" "kamata" "2011-03-26" "2011-03-27"
3
+ "���{��̍Â���2" "kamata" "2011-03-26" "2011-03-27"
@@ -0,0 +1,4 @@
1
+ id dummy
2
+ 1
3
+ 2
4
+ 3 この行は無視される
@@ -1,4 +1,4 @@
1
- "name" "category" "library_shortname" "start_at" "end_at" "dummy"
1
+ "name" "category" "library" "start_at" "end_at" "dummy"
2
2
  "イベント名" "カテゴリ。休館日の場合はclosed" "図書館名" "開始日" "終了日" "インポート省略"
3
3
  "hogehoge" "おはなし会" "kamata" "2009-04-01" "2009-04-03"
4
4
  "hogehoge" "hachioji"
@@ -1,3 +1,3 @@
1
- "name" "library_shortname" "start_at" "end_at"
1
+ "name" "library" "start_at" "end_at"
2
2
  "���{��̍Â���" "kamata" "2011-03-26" "2011-03-27"
3
3
  "���{��̍Â���2" "kamata" "2011-03-26" "2011-03-27"
@@ -0,0 +1,4 @@
1
+ id name category library start_at end_at all_day note dummy
2
+ 1 変更後のイベント名 kamata 2012-04-01 2012-04-02
3
+ 2 mita 2012-04-03 FALSE
4
+ 3 変更後のイベント名 この行は無視される
@@ -0,0 +1,4 @@
1
+ ����idtype
2
+ class_name created_at_d updated_at_drequired_role_id_ipatron_type_id_i name_text
3
+ position_idisplay_name_text address_text library_id_i
4
+ start_at_dend_at_d note_text
@@ -0,0 +1 @@
1
+ NRM�xxvx|u|||||||||||||||||||||||||�|ut�u��|||||
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.6
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-25 00:00:00.000000000 Z
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/segments_1
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/segments_1
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