enju_event 0.0.27 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/Rakefile +1 -11
- data/app/controllers/calendar_controller.rb +1 -1
- data/app/controllers/event_categories_controller.rb +1 -1
- data/app/controllers/event_import_files_controller.rb +15 -15
- data/app/controllers/event_import_results_controller.rb +1 -1
- data/app/controllers/events_controller.rb +16 -16
- data/app/controllers/participates_controller.rb +3 -3
- data/app/models/event.rb +2 -4
- data/app/models/event_category.rb +0 -1
- data/app/models/event_import_file.rb +33 -106
- data/app/models/event_import_result.rb +0 -1
- data/app/models/participate.rb +0 -1
- data/app/views/event_categories/index.html.erb +2 -2
- data/app/views/event_import_files/index.html.erb +4 -4
- data/app/views/event_import_files/new.html.erb +2 -0
- data/app/views/event_import_files/show.html.erb +3 -8
- data/app/views/event_import_results/index.html.erb +2 -2
- data/app/views/events/_form.html.erb +1 -1
- data/app/views/events/index.html.erb +8 -8
- data/app/views/events/index.mobile.erb +6 -6
- data/app/views/events/index.rss.builder +2 -2
- data/app/views/participates/index.html.erb +2 -2
- data/config/locales/translation_en.yml +1 -2
- data/config/locales/translation_ja.yml +1 -2
- data/config/routes.rb +0 -3
- data/db/migrate/20120413051535_add_event_fingerprint_to_event_import_file.rb +5 -0
- data/lib/enju_event.rb +0 -17
- data/lib/enju_event/engine.rb +9 -2
- data/lib/enju_event/version.rb +1 -1
- data/spec/dummy/app/models/country.rb +44 -0
- data/spec/dummy/app/models/language.rb +4 -0
- data/spec/dummy/app/models/library.rb +128 -0
- data/spec/dummy/app/models/library_group.rb +86 -0
- data/spec/dummy/app/models/patron.rb +163 -0
- data/spec/dummy/app/models/patron_type.rb +19 -0
- data/spec/dummy/app/models/role.rb +1 -39
- data/spec/dummy/app/models/shelf.rb +54 -0
- data/spec/dummy/app/models/user.rb +10 -61
- data/spec/dummy/app/models/user_group.rb +0 -38
- data/spec/dummy/app/models/user_has_role.rb +0 -1
- data/spec/dummy/config/application.rb +1 -3
- data/spec/dummy/config/initializers/devise.rb +4 -0
- data/spec/dummy/config/initializers/mime_types.rb +1 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/001_create_patrons.rb +10 -1
- data/spec/dummy/db/migrate/20080905191442_create_patron_types.rb +5 -1
- data/spec/dummy/db/migrate/20081025083905_create_languages.rb +5 -1
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +10 -31
- data/spec/dummy/db/schema.rb +20 -494
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/enju_leaf.rb +4 -0
- data/spec/dummy/lib/enju_leaf/import_file.rb +13 -0
- data/spec/dummy/lib/enju_leaf/localized_name.rb +13 -0
- data/spec/dummy/lib/enju_leaf/master_model.rb +41 -0
- data/spec/dummy/lib/enju_leaf/url_validator.rb +10 -0
- data/spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_import_file_sample1.tsv +1 -1
- data/spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_import_file_sample2.tsv +1 -1
- 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/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_1 +0 -0
- data/spec/fixtures/event_import_files.yml +4 -6
- data/spec/models/event_import_file_spec.rb +4 -38
- metadata +123 -329
- data/db/migrate/20120413051535_add_event_import_fingerprint_to_event_import_file.rb +0 -5
- data/db/migrate/20120413170734_add_error_message_to_event_import_file.rb +0 -5
- data/db/migrate/20120415060342_rename_event_import_file_imported_at_to_executed_at.rb +0 -9
- data/spec/controllers/calendar_controller_spec.rb +0 -57
- data/spec/dummy/db/migrate/005_create_manifestations.rb +0 -56
- data/spec/dummy/db/migrate/006_create_items.rb +0 -28
- data/spec/dummy/db/migrate/012_create_owns.rb +0 -12
- data/spec/dummy/db/migrate/015_create_creates.rb +0 -12
- data/spec/dummy/db/migrate/047_create_produces.rb +0 -12
- data/spec/dummy/db/migrate/073_create_carrier_types.rb +0 -11
- data/spec/dummy/db/migrate/112_create_frequencies.rb +0 -12
- data/spec/dummy/db/migrate/117_create_form_of_works.rb +0 -12
- data/spec/dummy/db/migrate/125_create_donates.rb +0 -12
- data/spec/dummy/db/migrate/20080830154109_create_realizes.rb +0 -13
- data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +0 -13
- data/spec/dummy/db/migrate/20081027150907_create_picture_files.rb +0 -15
- data/spec/dummy/db/migrate/20081028083142_create_patron_import_files.rb +0 -22
- data/spec/dummy/db/migrate/20081028083208_create_resource_import_files.rb +0 -22
- data/spec/dummy/db/migrate/20090705133942_add_attachments_picture_to_picture_file.rb +0 -15
- data/spec/dummy/db/migrate/20090705212043_add_attachments_attachment_to_manifestation.rb +0 -15
- data/spec/dummy/db/migrate/20090719201843_create_extents.rb +0 -12
- data/spec/dummy/db/migrate/20090720091106_create_medium_of_performances.rb +0 -12
- data/spec/dummy/db/migrate/20090720091429_create_content_types.rb +0 -12
- data/spec/dummy/db/migrate/20090812151902_create_patron_relationship_types.rb +0 -12
- data/spec/dummy/db/migrate/20091012101112_add_dcndl_schema.rb +0 -27
- data/spec/dummy/db/migrate/20091025080447_create_licenses.rb +0 -12
- data/spec/dummy/db/migrate/20091202124834_create_versions.rb +0 -18
- data/spec/dummy/db/migrate/20091214131723_create_series_statements.rb +0 -13
- data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +0 -15
- data/spec/dummy/db/migrate/20100223121519_rename_series_statement_title_to_original_title.rb +0 -13
- data/spec/dummy/db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb +0 -10
- data/spec/dummy/db/migrate/20100525124311_create_manifestation_relationships.rb +0 -13
- data/spec/dummy/db/migrate/20100606073747_create_patron_relationships.rb +0 -13
- data/spec/dummy/db/migrate/20100607044753_create_manifestation_relationship_types.rb +0 -12
- data/spec/dummy/db/migrate/20100814091104_add_position_to_patron_relationship.rb +0 -11
- data/spec/dummy/db/migrate/20100925043847_create_resource_import_results.rb +0 -15
- data/spec/dummy/db/migrate/20100925074559_create_patron_import_results.rb +0 -12
- data/spec/dummy/db/migrate/20101212070145_add_acquired_at_to_item.rb +0 -9
- data/spec/dummy/db/migrate/20110301035123_add_pub_date_to_manifestation.rb +0 -9
- data/spec/dummy/db/migrate/20110301121550_add_birth_date_and_death_date_to_patron.rb +0 -11
- data/spec/dummy/db/migrate/20110425133109_add_issn_to_series_statement.rb +0 -9
- data/spec/dummy/db/migrate/20110618091240_add_periodical_to_series_statement.rb +0 -9
- data/spec/dummy/db/migrate/20110619064807_add_edition_string_to_manifestation.rb +0 -9
- data/spec/dummy/db/migrate/20110620173525_add_bookstore_id_to_item.rb +0 -11
- data/spec/dummy/db/migrate/20110627034940_create_series_statement_merge_lists.rb +0 -9
- data/spec/dummy/db/migrate/20110627035057_create_series_statement_merges.rb +0 -12
- data/spec/dummy/db/migrate/20110820131417_create_series_has_manifestations.rb +0 -13
- data/spec/dummy/db/migrate/20110916053430_rename_manifestation_number_list_to_number_string.rb +0 -13
- data/spec/dummy/db/migrate/20110916091020_add_volume_number_to_manifestation.rb +0 -13
- data/spec/dummy/db/migrate/20110916103953_add_manifestaiton_id_to_series_statement.rb +0 -10
- data/spec/dummy/db/migrate/20110918161853_rename_series_statement_manifestation_id_to_root_manifestation_id.rb +0 -13
- data/spec/dummy/db/migrate/20110918162329_add_note_to_series_statement.rb +0 -9
- data/spec/dummy/db/migrate/20111009183423_add_ndc_to_manifestation.rb +0 -9
- data/spec/dummy/db/migrate/20111124110059_create_create_types.rb +0 -12
- data/spec/dummy/db/migrate/20111124110319_create_realize_types.rb +0 -12
- data/spec/dummy/db/migrate/20111124110355_create_produce_types.rb +0 -12
- data/spec/dummy/db/migrate/20111124112131_add_create_type_to_create.rb +0 -7
- data/spec/dummy/db/migrate/20120125152919_add_title_subseries_transcription_to_series_statement.rb +0 -6
- data/spec/dummy/db/migrate/20120129020544_add_budget_type_id_to_item.rb +0 -6
- data/spec/dummy/db/migrate/20120319120638_add_content_type_id_to_manifestation.rb +0 -6
- data/spec/dummy/db/migrate/20120410104851_add_year_of_publication_to_manifestation.rb +0 -5
- data/spec/dummy/db/migrate/20120413072700_add_picture_meta_to_picture_file.rb +0 -5
- data/spec/dummy/db/migrate/20120413100352_add_fingerprint_to_picture_file.rb +0 -5
- data/spec/dummy/db/migrate/20120413161340_add_fingerprint_to_resource_import_file.rb +0 -5
- data/spec/dummy/db/migrate/20120413161403_add_fingerprint_to_patron_import_file.rb +0 -5
- data/spec/dummy/db/migrate/20120413170705_add_error_message_to_resource_import_file.rb +0 -5
- data/spec/dummy/db/migrate/20120413170720_add_error_message_to_patron_import_file.rb +0 -5
- data/spec/dummy/db/migrate/20120415060308_rename_resource_import_file_imported_at_to_executed_at.rb +0 -9
- data/spec/dummy/db/migrate/20120415060323_rename_patron_import_file_imported_at_to_executed_at.rb +0 -9
- data/spec/dummy/db/migrate/20120415164821_add_attachment_meta_to_manifestation.rb +0 -5
- data/spec/dummy/db/migrate/20120418081407_add_month_of_publication_to_manifestation.rb +0 -5
- data/spec/dummy/db/migrate/20120602141129_add_edit_mode_to_patron_import_file.rb +0 -5
- data/spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_destroy_file.tsv +0 -4
- data/spec/dummy/private/system/event_import_files/event_imports/000/000/004/original/event_update_file.tsv +0 -4
- data/spec/dummy/private/system/event_imports/4/original/event_destroy_file.tsv +0 -4
- data/spec/dummy/private/system/event_imports/4/original/event_update_file.tsv +0 -4
- data/spec/dummy/solr/data/test/index/_5l.fdt +0 -0
- data/spec/dummy/solr/data/test/index/_5l.fdx +0 -0
- data/spec/dummy/solr/data/test/index/_5l.fnm +0 -4
- data/spec/dummy/solr/data/test/index/_5l.frq +0 -0
- data/spec/dummy/solr/data/test/index/_5l.nrm +0 -1
- data/spec/dummy/solr/data/test/index/_5l.prx +0 -0
- data/spec/dummy/solr/data/test/index/_5l.tii +0 -0
- data/spec/dummy/solr/data/test/index/_5l.tis +0 -0
- data/spec/dummy/solr/data/test/index/_5l_1.del +0 -0
- data/spec/dummy/solr/data/test/index/_5m.fdt +0 -0
- data/spec/dummy/solr/data/test/index/_5m.fdx +0 -0
- data/spec/dummy/solr/data/test/index/_5m.fnm +0 -4
- data/spec/dummy/solr/data/test/index/_5m.frq +0 -0
- data/spec/dummy/solr/data/test/index/_5m.nrm +0 -1
- data/spec/dummy/solr/data/test/index/_5m.prx +0 -0
- data/spec/dummy/solr/data/test/index/_5m.tii +0 -0
- data/spec/dummy/solr/data/test/index/_5m.tis +0 -0
- data/spec/dummy/solr/data/test/index/_5m_1.del +0 -0
- data/spec/dummy/solr/data/test/index/_5n.fdt +0 -0
- data/spec/dummy/solr/data/test/index/_5n.fdx +0 -0
- data/spec/dummy/solr/data/test/index/_5n.fnm +0 -4
- data/spec/dummy/solr/data/test/index/_5n.frq +0 -0
- data/spec/dummy/solr/data/test/index/_5n.nrm +0 -1
- data/spec/dummy/solr/data/test/index/_5n.prx +0 -0
- data/spec/dummy/solr/data/test/index/_5n.tii +0 -0
- data/spec/dummy/solr/data/test/index/_5n.tis +0 -0
- data/spec/dummy/solr/data/test/index/segments_6l +0 -0
data/MIT-LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
|
15
15
|
RDoc::Task.new(:rdoc) do |rdoc|
|
16
16
|
rdoc.rdoc_dir = 'rdoc'
|
17
|
-
rdoc.title = '
|
17
|
+
rdoc.title = 'EnjuSubject'
|
18
18
|
rdoc.options << '--line-numbers'
|
19
19
|
rdoc.rdoc_files.include('README.rdoc')
|
20
20
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
@@ -29,18 +29,8 @@ 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
|
-
|
41
32
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
42
33
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
43
34
|
end
|
44
35
|
|
45
|
-
|
46
36
|
task :default => :spec
|
@@ -23,7 +23,7 @@ class CalendarController < ApplicationController
|
|
23
23
|
date = Time.zone.local(params[:year].to_i, params[:month].to_i, params[:day].to_i) rescue Time.zone.now
|
24
24
|
date_string = date.strftime('%Y/%m/%d')
|
25
25
|
if Event.search do
|
26
|
-
with(:start_at).
|
26
|
+
with(:start_at).less_than date
|
27
27
|
with(:end_at).greater_than date
|
28
28
|
end.results.empty?
|
29
29
|
redirect_to new_event_path(:date => date_string)
|
@@ -2,18 +2,18 @@ class EventImportFilesController < ApplicationController
|
|
2
2
|
load_and_authorize_resource
|
3
3
|
|
4
4
|
# GET /event_import_files
|
5
|
-
# GET /event_import_files.
|
5
|
+
# GET /event_import_files.xml
|
6
6
|
def index
|
7
7
|
@event_import_files = EventImportFile.page(params[:page])
|
8
8
|
|
9
9
|
respond_to do |format|
|
10
10
|
format.html # index.html.erb
|
11
|
-
format.
|
11
|
+
format.xml { render :xml => @event_import_files }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
# GET /event_import_files/1
|
16
|
-
# GET /event_import_files/1.
|
16
|
+
# GET /event_import_files/1.xml
|
17
17
|
def show
|
18
18
|
if @event_import_file.event_import.path
|
19
19
|
unless configatron.uploaded_file.storage == :s3
|
@@ -23,7 +23,7 @@ class EventImportFilesController < ApplicationController
|
|
23
23
|
|
24
24
|
respond_to do |format|
|
25
25
|
format.html # show.html.erb
|
26
|
-
format.
|
26
|
+
format.xml { render :xml => @event_import_file }
|
27
27
|
format.download {
|
28
28
|
if configatron.uploaded_file.storage == :s3
|
29
29
|
redirect_to @event_import_file.event_import.expiring_url(10)
|
@@ -35,13 +35,13 @@ class EventImportFilesController < ApplicationController
|
|
35
35
|
end
|
36
36
|
|
37
37
|
# GET /event_import_files/new
|
38
|
-
# GET /event_import_files/new.
|
38
|
+
# GET /event_import_files/new.xml
|
39
39
|
def new
|
40
40
|
@event_import_file = EventImportFile.new
|
41
41
|
|
42
42
|
respond_to do |format|
|
43
43
|
format.html # new.html.erb
|
44
|
-
format.
|
44
|
+
format.xml { render :xml => @event_import_file }
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -50,7 +50,7 @@ class EventImportFilesController < ApplicationController
|
|
50
50
|
end
|
51
51
|
|
52
52
|
# POST /event_import_files
|
53
|
-
# POST /event_import_files.
|
53
|
+
# POST /event_import_files.xml
|
54
54
|
def create
|
55
55
|
@event_import_file = EventImportFile.new(params[:event_import_file])
|
56
56
|
@event_import_file.user = current_user
|
@@ -59,37 +59,37 @@ class EventImportFilesController < ApplicationController
|
|
59
59
|
if @event_import_file.save
|
60
60
|
flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.event_import_file'))
|
61
61
|
format.html { redirect_to(@event_import_file) }
|
62
|
-
format.
|
62
|
+
format.xml { render :xml => @event_import_file, :status => :created, :location => @event_import_file }
|
63
63
|
else
|
64
64
|
format.html { render :action => "new" }
|
65
|
-
format.
|
65
|
+
format.xml { render :xml => @event_import_file.errors, :status => :unprocessable_entity }
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
# PUT /event_import_files/1
|
71
|
-
# PUT /event_import_files/1.
|
71
|
+
# PUT /event_import_files/1.xml
|
72
72
|
def update
|
73
73
|
respond_to do |format|
|
74
74
|
if @event_import_file.update_attributes(params[:event_import_file])
|
75
75
|
flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.event_import_file'))
|
76
76
|
format.html { redirect_to(@event_import_file) }
|
77
|
-
format.
|
77
|
+
format.xml { head :ok }
|
78
78
|
else
|
79
79
|
format.html { render :action => "edit" }
|
80
|
-
format.
|
80
|
+
format.xml { render :xml => @event_import_file.errors, :status => :unprocessable_entity }
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
85
|
# DELETE /event_import_files/1
|
86
|
-
# DELETE /event_import_files/1.
|
86
|
+
# DELETE /event_import_files/1.xml
|
87
87
|
def destroy
|
88
88
|
@event_import_file.destroy
|
89
89
|
|
90
90
|
respond_to do |format|
|
91
|
-
format.html { redirect_to
|
92
|
-
format.
|
91
|
+
format.html { redirect_to(event_import_files_url) }
|
92
|
+
format.xml { head :ok }
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
@@ -9,7 +9,7 @@ class EventsController < ApplicationController
|
|
9
9
|
after_filter :convert_charset, :only => :index
|
10
10
|
|
11
11
|
# GET /events
|
12
|
-
# GET /events.
|
12
|
+
# GET /events.xml
|
13
13
|
def index
|
14
14
|
@count = {}
|
15
15
|
query = params[:query].to_s.strip
|
@@ -26,7 +26,7 @@ class EventsController < ApplicationController
|
|
26
26
|
with(:library_id).equal_to library.id if library
|
27
27
|
#with(:tag).equal_to tag
|
28
28
|
if date
|
29
|
-
with(:start_at).
|
29
|
+
with(:start_at).less_than Time.zone.parse(date)
|
30
30
|
with(:end_at).greater_than Time.zone.parse(date)
|
31
31
|
end
|
32
32
|
case mode
|
@@ -45,7 +45,7 @@ class EventsController < ApplicationController
|
|
45
45
|
|
46
46
|
respond_to do |format|
|
47
47
|
format.html # index.html.erb
|
48
|
-
format.
|
48
|
+
format.xml { render :xml => @events }
|
49
49
|
format.rss { render :layout => false }
|
50
50
|
format.csv
|
51
51
|
format.atom
|
@@ -54,18 +54,18 @@ class EventsController < ApplicationController
|
|
54
54
|
end
|
55
55
|
|
56
56
|
# GET /events/1
|
57
|
-
# GET /events/1.
|
57
|
+
# GET /events/1.xml
|
58
58
|
def show
|
59
59
|
@event = Event.find(params[:id])
|
60
60
|
|
61
61
|
respond_to do |format|
|
62
62
|
format.html # show.html.erb
|
63
|
-
format.
|
63
|
+
format.xml { render :xml => @event }
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
# GET /events/new
|
68
|
-
# GET /events/new.
|
68
|
+
# GET /events/new.xml
|
69
69
|
def new
|
70
70
|
prepare_options
|
71
71
|
if params[:date]
|
@@ -83,7 +83,7 @@ class EventsController < ApplicationController
|
|
83
83
|
|
84
84
|
respond_to do |format|
|
85
85
|
format.html # new.html.erb
|
86
|
-
format.
|
86
|
+
format.xml { render :xml => @event }
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -94,7 +94,7 @@ class EventsController < ApplicationController
|
|
94
94
|
end
|
95
95
|
|
96
96
|
# POST /events
|
97
|
-
# POST /events.
|
97
|
+
# POST /events.xml
|
98
98
|
def create
|
99
99
|
@event = Event.new(params[:event])
|
100
100
|
@event.set_date
|
@@ -103,17 +103,17 @@ class EventsController < ApplicationController
|
|
103
103
|
if @event.save
|
104
104
|
flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.event'))
|
105
105
|
format.html { redirect_to(@event) }
|
106
|
-
format.
|
106
|
+
format.xml { render :xml => @event, :status => :created, :location => @event }
|
107
107
|
else
|
108
108
|
prepare_options
|
109
109
|
format.html { render :action => "new" }
|
110
|
-
format.
|
110
|
+
format.xml { render :xml => @event.errors, :status => :unprocessable_entity }
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
115
|
# PUT /events/1
|
116
|
-
# PUT /events/1.
|
116
|
+
# PUT /events/1.xml
|
117
117
|
def update
|
118
118
|
@event = Event.find(params[:id])
|
119
119
|
@event.set_date
|
@@ -123,24 +123,24 @@ class EventsController < ApplicationController
|
|
123
123
|
|
124
124
|
flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.event'))
|
125
125
|
format.html { redirect_to(@event) }
|
126
|
-
format.
|
126
|
+
format.xml { head :ok }
|
127
127
|
else
|
128
128
|
prepare_options
|
129
129
|
format.html { render :action => "edit" }
|
130
|
-
format.
|
130
|
+
format.xml { render :xml => @event.errors, :status => :unprocessable_entity }
|
131
131
|
end
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
135
|
# DELETE /events/1
|
136
|
-
# DELETE /events/1.
|
136
|
+
# DELETE /events/1.xml
|
137
137
|
def destroy
|
138
138
|
@event = Event.find(params[:id])
|
139
139
|
@event.destroy
|
140
140
|
|
141
141
|
respond_to do |format|
|
142
|
-
format.html { redirect_to
|
143
|
-
format.
|
142
|
+
format.html { redirect_to(events_url) }
|
143
|
+
format.xml { head :ok }
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -60,7 +60,7 @@ class ParticipatesController < ApplicationController
|
|
60
60
|
if @participate.update_attributes(params[:participate])
|
61
61
|
flash[:notice] = 'Participate was successfully updated.'
|
62
62
|
format.html { redirect_to(@participate) }
|
63
|
-
format.json { head :
|
63
|
+
format.json { head :ok }
|
64
64
|
else
|
65
65
|
format.html { render :action => "edit" }
|
66
66
|
format.json { render :json => @participate.errors, :status => :unprocessable_entity }
|
@@ -74,8 +74,8 @@ class ParticipatesController < ApplicationController
|
|
74
74
|
@participate.destroy
|
75
75
|
|
76
76
|
respond_to do |format|
|
77
|
-
format.html { redirect_to
|
78
|
-
format.json { head :
|
77
|
+
format.html { redirect_to(participates_url) }
|
78
|
+
format.json { head :ok }
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
data/app/models/event.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
class Event < ActiveRecord::Base
|
3
|
-
attr_accessible :library_id, :event_category_id, :name, :note, :start_at,
|
4
|
-
:end_at, :all_day, :display_name
|
5
|
-
|
6
3
|
scope :closing_days, includes(:event_category).where('event_categories.name = ?', 'closed')
|
7
4
|
scope :on, lambda {|datetime| where('start_at >= ? AND start_at < ?', datetime.beginning_of_day, datetime.tomorrow.beginning_of_day + 1)}
|
8
5
|
scope :past, lambda {|datetime| where('end_at <= ?', Time.zone.parse(datetime).beginning_of_day)}
|
@@ -11,6 +8,7 @@ class Event < ActiveRecord::Base
|
|
11
8
|
|
12
9
|
belongs_to :event_category, :validate => true
|
13
10
|
belongs_to :library, :validate => true
|
11
|
+
has_many :attachment_files, :as => :attachable
|
14
12
|
has_many :picture_files, :as => :picture_attachable
|
15
13
|
has_many :participates, :dependent => :destroy
|
16
14
|
has_many :patrons, :through => :participates
|
@@ -49,7 +47,7 @@ class Event < ActiveRecord::Base
|
|
49
47
|
end
|
50
48
|
|
51
49
|
def set_all_day
|
52
|
-
if all_day
|
50
|
+
if self.all_day
|
53
51
|
self.start_at = self.start_at.beginning_of_day
|
54
52
|
self.end_at = self.end_at.end_of_day
|
55
53
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
class EventImportFile < ActiveRecord::Base
|
2
|
-
attr_accessible :event_import, :edit_mode
|
3
2
|
include ImportFile
|
4
|
-
default_scope :order => '
|
3
|
+
default_scope :order => 'id DESC'
|
5
4
|
scope :not_imported, where(:state => 'pending')
|
6
5
|
scope :stucked, where('created_at < ? AND state = ?', 1.hour.ago, 'pending')
|
7
6
|
|
@@ -29,26 +28,15 @@ class EventImportFile < ActiveRecord::Base
|
|
29
28
|
event :sm_fail do
|
30
29
|
transition :started => :failed
|
31
30
|
end
|
32
|
-
|
33
|
-
before_transition any => :started do |patron_import_file|
|
34
|
-
patron_import_file.executed_at = Time.zone.now
|
35
|
-
end
|
36
|
-
|
37
|
-
before_transition any => :completed do |patron_import_file|
|
38
|
-
patron_import_file.error_message = nil
|
39
|
-
end
|
40
31
|
end
|
41
32
|
|
42
33
|
def import_start
|
43
|
-
executed_at = Time.zone.now
|
44
34
|
sm_start!
|
45
35
|
case edit_mode
|
46
36
|
when 'create'
|
47
37
|
import
|
48
38
|
when 'update'
|
49
|
-
modify
|
50
39
|
when 'destroy'
|
51
|
-
remove
|
52
40
|
else
|
53
41
|
import
|
54
42
|
end
|
@@ -57,103 +45,55 @@ class EventImportFile < ActiveRecord::Base
|
|
57
45
|
def import
|
58
46
|
self.reload
|
59
47
|
num = {:imported => 0, :failed => 0}
|
60
|
-
|
61
|
-
check_field(rows.first)
|
62
|
-
row_num = 2
|
48
|
+
record = 2
|
63
49
|
|
50
|
+
rows = open_import_file
|
51
|
+
field = rows.first
|
52
|
+
if [field['name']].reject{|f| f.to_s.strip == ""}.empty?
|
53
|
+
raise "You should specify a name in the first line"
|
54
|
+
end
|
55
|
+
if [field['start_at'], field['end_at']].reject{|field| field.to_s.strip == ""}.empty?
|
56
|
+
raise "You should specify dates in the first line"
|
57
|
+
end
|
58
|
+
#rows.shift
|
64
59
|
rows.each do |row|
|
65
60
|
next if row['dummy'].to_s.strip.present?
|
66
|
-
|
67
|
-
event_import_result.assign_attributes({:event_import_file_id => self.id, :body => row.fields.join("\t")}, :as => :admin)
|
68
|
-
event_import_result.save!
|
61
|
+
import_result = EventImportResult.create!(:event_import_file => self, :body => row.fields.join("\t"))
|
69
62
|
|
70
63
|
event = Event.new
|
71
|
-
event.name = row['name']
|
64
|
+
event.name = row['name']
|
72
65
|
event.note = row['note']
|
73
66
|
event.start_at = row['start_at']
|
74
67
|
event.end_at = row['end_at']
|
75
68
|
category = row['category'].to_s.strip
|
76
|
-
|
77
|
-
|
78
|
-
else
|
79
|
-
event.all_day = true
|
80
|
-
end
|
81
|
-
library = Library.where(:name => row['library']).first
|
69
|
+
event.all_day = true
|
70
|
+
library = Library.where(:name => row['library_short_name']).first
|
82
71
|
library = Library.web if library.blank?
|
83
72
|
event.library = library
|
84
73
|
event_category = EventCategory.where(:name => category).first || EventCategory.where(:name => 'unknown').first
|
85
74
|
event.event_category = event_category
|
86
75
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
76
|
+
begin
|
77
|
+
if event.save!
|
78
|
+
import_result.event = event
|
79
|
+
num[:imported] += 1
|
80
|
+
if record % 50 == 0
|
81
|
+
Sunspot.commit
|
82
|
+
GC.start
|
83
|
+
end
|
93
84
|
end
|
85
|
+
rescue
|
86
|
+
Rails.logger.info("event import failed: column #{record}")
|
87
|
+
num[:failed] += 1
|
94
88
|
end
|
95
|
-
|
96
|
-
|
89
|
+
import_result.save!
|
90
|
+
record += 1
|
97
91
|
end
|
92
|
+
self.update_attribute(:imported_at, Time.zone.now)
|
98
93
|
Sunspot.commit
|
99
94
|
rows.close
|
100
95
|
sm_complete!
|
101
96
|
return num
|
102
|
-
rescue => e
|
103
|
-
self.error_message = "line #{row_num}: #{e.message}"
|
104
|
-
sm_fail!
|
105
|
-
raise e
|
106
|
-
end
|
107
|
-
|
108
|
-
def modify
|
109
|
-
sm_start!
|
110
|
-
rows = open_import_file
|
111
|
-
check_field(rows.first)
|
112
|
-
row_num = 2
|
113
|
-
|
114
|
-
rows.each do |row|
|
115
|
-
next if row['dummy'].to_s.strip.present?
|
116
|
-
event = Event.find(row['id'].to_s.strip)
|
117
|
-
event_category = EventCategory.where(:name => row['category'].to_s.strip).first
|
118
|
-
event.event_category = event_category if event_category
|
119
|
-
library = Library.where(:name => row['library'].to_s.strip).first
|
120
|
-
event.library = library if library
|
121
|
-
event.name = row['name'] if row['name'].to_s.strip.present?
|
122
|
-
event.start_at = row['start_at'] if row['start_at'].to_s.strip.present?
|
123
|
-
event.end_at = row['end_at'] if row['end_at'].to_s.strip.present?
|
124
|
-
event.note = row['end_at'] if row['note'].to_s.strip.present?
|
125
|
-
if row['all_day'].to_s.strip.downcase == 'false'
|
126
|
-
event.all_day = false
|
127
|
-
else
|
128
|
-
event.all_day = true
|
129
|
-
end
|
130
|
-
event.save!
|
131
|
-
row_num += 1
|
132
|
-
end
|
133
|
-
sm_complete!
|
134
|
-
rescue => e
|
135
|
-
self.error_message = "line #{row_num}: #{e.message}"
|
136
|
-
sm_fail!
|
137
|
-
raise e
|
138
|
-
end
|
139
|
-
|
140
|
-
def remove
|
141
|
-
sm_start!
|
142
|
-
rows = open_import_file
|
143
|
-
rows.shift
|
144
|
-
row_num = 2
|
145
|
-
|
146
|
-
rows.each do |row|
|
147
|
-
next if row['dummy'].to_s.strip.present?
|
148
|
-
event = Event.find(row['id'].to_s.strip)
|
149
|
-
event.destroy
|
150
|
-
row_num += 1
|
151
|
-
end
|
152
|
-
sm_complete!
|
153
|
-
rescue => e
|
154
|
-
self.error_message = "line #{row_num}: #{e.message}"
|
155
|
-
sm_fail!
|
156
|
-
raise e
|
157
97
|
end
|
158
98
|
|
159
99
|
def self.import
|
@@ -188,22 +128,11 @@ class EventImportFile < ActiveRecord::Base
|
|
188
128
|
header = file.first
|
189
129
|
rows = FasterCSV.open(tempfile.path, :headers => header, :col_sep => "\t")
|
190
130
|
end
|
191
|
-
|
192
|
-
event_import_result.assign_attributes({:event_import_file_id => self.id, :body => header.join("\t")}, :as => :admin)
|
193
|
-
event_import_result.save!
|
131
|
+
EventImportResult.create!(:event_import_file => self, :body => header.join("\t"))
|
194
132
|
tempfile.close(true)
|
195
133
|
file.close
|
196
134
|
rows
|
197
135
|
end
|
198
|
-
|
199
|
-
def check_field(field)
|
200
|
-
if [field['name']].reject{|f| f.to_s.strip == ""}.empty?
|
201
|
-
raise "You should specify a name in the first line"
|
202
|
-
end
|
203
|
-
if [field['start_at'], field['end_at']].reject{|field| field.to_s.strip == ""}.empty?
|
204
|
-
raise "You should specify dates in the first line"
|
205
|
-
end
|
206
|
-
end
|
207
136
|
end
|
208
137
|
|
209
138
|
# == Schema Information
|
@@ -216,17 +145,15 @@ end
|
|
216
145
|
# size :integer
|
217
146
|
# user_id :integer
|
218
147
|
# note :text
|
219
|
-
#
|
148
|
+
# imported_at :datetime
|
220
149
|
# state :string(255)
|
221
150
|
# event_import_file_name :string(255)
|
222
151
|
# event_import_content_type :string(255)
|
223
152
|
# event_import_file_size :integer
|
224
153
|
# event_import_updated_at :datetime
|
154
|
+
# created_at :datetime
|
155
|
+
# updated_at :datetime
|
225
156
|
# edit_mode :string(255)
|
226
157
|
# event_import_fingerprint :string(255)
|
227
|
-
# created_at :datetime not null
|
228
|
-
# updated_at :datetime not null
|
229
|
-
# event_fingerprint :string(255)
|
230
|
-
# error_message :text
|
231
158
|
#
|
232
159
|
|