enju_event 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -185,7 +188,9 @@ class EventImportFile < ActiveRecord::Base
185
188
  header = file.first
186
189
  rows = FasterCSV.open(tempfile.path, :headers => header, :col_sep => "\t")
187
190
  end
188
- EventImportResult.create!(:event_import_file => self, :body => header.join("\t"))
191
+ event_import_result = EventImportResult.new
192
+ event_import_result.assign_attributes({:event_import_file_id => self.id, :body => header.join("\t")}, :as => :admin)
193
+ event_import_result.save!
189
194
  tempfile.close(true)
190
195
  file.close
191
196
  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.0.19"
2
+ VERSION = "0.0.20"
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
+ ����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.0.19
4
+ version: 0.0.20
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,6 +504,8 @@ 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
@@ -527,8 +530,16 @@ files:
527
530
  - spec/dummy/solr/conf/spellings.txt
528
531
  - spec/dummy/solr/conf/stopwords.txt
529
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
530
541
  - spec/dummy/solr/data/test/index/segments.gen
531
- - spec/dummy/solr/data/test/index/segments_1
542
+ - spec/dummy/solr/data/test/index/segments_2k
532
543
  - spec/dummy/solr/data/test/spellchecker/segments.gen
533
544
  - spec/dummy/solr/data/test/spellchecker/segments_1
534
545
  - spec/factories/country.rb
@@ -633,6 +644,7 @@ test_files:
633
644
  - spec/dummy/config/locales/en.yml
634
645
  - spec/dummy/config/routes.rb
635
646
  - spec/dummy/config.ru
647
+ - spec/dummy/db/development.sqlite3
636
648
  - spec/dummy/db/migrate/001_create_patrons.rb
637
649
  - spec/dummy/db/migrate/059_create_libraries.rb
638
650
  - spec/dummy/db/migrate/069_create_shelves.rb
@@ -659,6 +671,8 @@ test_files:
659
671
  - spec/dummy/lib/enju_leaf/master_model.rb
660
672
  - spec/dummy/lib/enju_leaf/url_validator.rb
661
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
662
676
  - spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_destroy_file.tsv
663
677
  - spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_import_file_sample1.tsv
664
678
  - spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_import_file_sample2.tsv
@@ -683,8 +697,16 @@ test_files:
683
697
  - spec/dummy/solr/conf/spellings.txt
684
698
  - spec/dummy/solr/conf/stopwords.txt
685
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
686
708
  - spec/dummy/solr/data/test/index/segments.gen
687
- - spec/dummy/solr/data/test/index/segments_1
709
+ - spec/dummy/solr/data/test/index/segments_2k
688
710
  - spec/dummy/solr/data/test/spellchecker/segments.gen
689
711
  - spec/dummy/solr/data/test/spellchecker/segments_1
690
712
  - spec/factories/country.rb