enju_event 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +36 -0
- data/app/controllers/calendar_controller.rb +34 -0
- data/app/controllers/event_categories_controller.rb +18 -0
- data/app/controllers/event_import_files_controller.rb +95 -0
- data/app/controllers/event_import_results_controller.rb +15 -0
- data/app/controllers/events_controller.rb +152 -0
- data/app/controllers/participates_controller.rb +81 -0
- data/app/helpers/calendar_helper.rb +31 -0
- data/app/models/event.rb +87 -0
- data/app/models/event_category.rb +23 -0
- data/app/models/event_import_file.rb +166 -0
- data/app/models/event_import_result.rb +23 -0
- data/app/models/participate.rb +25 -0
- data/app/views/calendar/index.html.erb +45 -0
- data/app/views/event_categories/_form.html.erb +19 -0
- data/app/views/event_categories/edit.html.erb +13 -0
- data/app/views/event_categories/index.html.erb +46 -0
- data/app/views/event_categories/new.html.erb +12 -0
- data/app/views/event_categories/show.html.erb +29 -0
- data/app/views/event_import_files/edit.html.erb +25 -0
- data/app/views/event_import_files/index.html.erb +40 -0
- data/app/views/event_import_files/new.html.erb +37 -0
- data/app/views/event_import_files/show.html.erb +64 -0
- data/app/views/event_import_results/index.csv.erb +3 -0
- data/app/views/event_import_results/index.html.erb +50 -0
- data/app/views/event_import_results/show.html.erb +33 -0
- data/app/views/events/_all_day.html.erb +24 -0
- data/app/views/events/_form.html.erb +44 -0
- data/app/views/events/edit.html.erb +14 -0
- data/app/views/events/index.atom.builder +10 -0
- data/app/views/events/index.csv.erb +4 -0
- data/app/views/events/index.html.erb +105 -0
- data/app/views/events/index.ics.erb +13 -0
- data/app/views/events/index.mobile.erb +49 -0
- data/app/views/events/index.rss.builder +34 -0
- data/app/views/events/new.html.erb +17 -0
- data/app/views/events/show.html.erb +50 -0
- data/app/views/events/show.mobile.erb +42 -0
- data/app/views/participates/edit.html.erb +28 -0
- data/app/views/participates/index.html.erb +30 -0
- data/app/views/participates/new.html.erb +27 -0
- data/app/views/participates/show.html.erb +24 -0
- data/config/routes.rb +10 -0
- data/db/fixtures/event_categories.yml +13 -0
- data/db/migrate/113_create_events.rb +23 -0
- data/db/migrate/114_create_event_categories.rb +16 -0
- data/db/migrate/20081028093607_create_event_import_files.rb +29 -0
- data/db/migrate/20090519203307_create_participates.rb +17 -0
- data/db/migrate/20100925074639_create_event_import_results.rb +15 -0
- data/lib/enju_event.rb +5 -0
- data/lib/enju_event/engine.rb +18 -0
- data/lib/enju_event/version.rb +3 -0
- data/lib/tasks/enju_event_tasks.rake +5 -0
- data/spec/controllers/event_categories_controller_spec.rb +483 -0
- data/spec/controllers/event_import_files_controller_spec.rb +321 -0
- data/spec/controllers/events_controller_spec.rb +506 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +99 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/notifier.rb +28 -0
- data/spec/dummy/app/models/ability.rb +39 -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 +8 -0
- data/spec/dummy/app/models/shelf.rb +54 -0
- data/spec/dummy/app/models/user.rb +43 -0
- data/spec/dummy/app/models/user_group.rb +2 -0
- data/spec/dummy/app/models/user_has_role.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/page/403.html.erb +9 -0
- data/spec/dummy/app/views/page/403.mobile.erb +5 -0
- data/spec/dummy/app/views/page/403.xml.erb +4 -0
- data/spec/dummy/app/views/page/404.html.erb +9 -0
- data/spec/dummy/app/views/page/404.mobile.erb +5 -0
- data/spec/dummy/app/views/page/404.xml.erb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +209 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +7 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +60 -0
- data/spec/dummy/db/migrate/001_create_patrons.rb +62 -0
- data/spec/dummy/db/migrate/059_create_libraries.rb +34 -0
- data/spec/dummy/db/migrate/069_create_shelves.rb +19 -0
- data/spec/dummy/db/migrate/080_create_library_groups.rb +25 -0
- data/spec/dummy/db/migrate/20080905191442_create_patron_types.rb +16 -0
- data/spec/dummy/db/migrate/20081025083905_create_languages.rb +27 -0
- data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100222124420_add_allow_bookmark_external_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20100527113752_create_delayed_jobs.rb +21 -0
- data/spec/dummy/db/migrate/20110115022329_add_position_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20110222073537_add_url_to_library_group.rb +9 -0
- data/spec/dummy/db/migrate/20111020063828_remove_dsbl_from_library_group.rb +11 -0
- data/spec/dummy/db/migrate/20111201121844_create_roles.rb +12 -0
- data/spec/dummy/db/migrate/20111201155456_create_users.rb +14 -0
- data/spec/dummy/db/migrate/20111201155513_add_devise_to_users.rb +31 -0
- data/spec/dummy/db/migrate/20111201163342_create_user_groups.rb +12 -0
- data/spec/dummy/db/migrate/20111201163718_create_user_has_roles.rb +10 -0
- data/spec/dummy/db/schema.rb +293 -0
- 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/log/sunspot-solr-test.log +222 -0
- data/spec/dummy/log/test.log +145759 -0
- data/spec/dummy/private/system/event_imports/4/original/event_import_file_sample1.tsv +5 -0
- data/spec/dummy/private/system/event_imports/4/original/event_import_file_sample2.tsv +3 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/solr/conf/admin-extra.html +31 -0
- data/spec/dummy/solr/conf/elevate.xml +36 -0
- data/spec/dummy/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/spec/dummy/solr/conf/protwords.txt +21 -0
- data/spec/dummy/solr/conf/schema.xml +238 -0
- data/spec/dummy/solr/conf/scripts.conf +24 -0
- data/spec/dummy/solr/conf/solrconfig.xml +934 -0
- data/spec/dummy/solr/conf/spellings.txt +2 -0
- data/spec/dummy/solr/conf/stopwords.txt +58 -0
- data/spec/dummy/solr/conf/synonyms.txt +31 -0
- data/spec/dummy/solr/data/test/index/segments.gen +0 -0
- data/spec/dummy/solr/data/test/index/segments_1 +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments.gen +0 -0
- data/spec/dummy/solr/data/test/spellchecker/segments_1 +0 -0
- data/spec/factories/event.rb +7 -0
- data/spec/factories/event_category.rb +5 -0
- data/spec/factories/library.rb +13 -0
- data/spec/factories/user.rb +34 -0
- data/spec/fixtures/event_categories.yml +55 -0
- data/spec/fixtures/event_import_files.yml +49 -0
- data/spec/fixtures/event_import_results.yml +24 -0
- data/spec/fixtures/events.yml +142 -0
- data/spec/fixtures/languages.yml +1901 -0
- data/spec/fixtures/libraries.yml +108 -0
- data/spec/fixtures/library_groups.yml +34 -0
- data/spec/fixtures/patron_types.yml +35 -0
- data/spec/fixtures/patrons.yml +338 -0
- data/spec/fixtures/roles.yml +21 -0
- data/spec/fixtures/shelves.yml +46 -0
- data/spec/fixtures/user_groups.yml +25 -0
- data/spec/fixtures/user_has_roles.yml +41 -0
- data/spec/fixtures/users.yml +69 -0
- data/spec/models/event_category_spec.rb +21 -0
- data/spec/models/event_import_file_spec.rb +62 -0
- data/spec/models/event_import_result_spec.rb +20 -0
- data/spec/models/event_spec.rb +39 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/controller_macros.rb +48 -0
- data/spec/support/devise.rb +4 -0
- metadata +541 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'EnjuSubject'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
Bundler::GemHelper.install_tasks
|
28
|
+
|
29
|
+
require 'rspec/core'
|
30
|
+
require 'rspec/core/rake_task'
|
31
|
+
|
32
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
33
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
34
|
+
end
|
35
|
+
|
36
|
+
task :default => :spec
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class CalendarController < ApplicationController
|
2
|
+
helper_method :get_library, :get_libraries
|
3
|
+
|
4
|
+
def index
|
5
|
+
params[:month] ||= Time.zone.now.month
|
6
|
+
params[:year] ||= Time.zone.now.year
|
7
|
+
@month = params[:month].to_i || Time.zone.now.month
|
8
|
+
@year = params[:year].to_i || Time.zone.now.year
|
9
|
+
|
10
|
+
#@shown_month = Date.civil(@year, @month)
|
11
|
+
@shown_month = Time.zone.local(@year, @month, 1) rescue Time.zone.now
|
12
|
+
|
13
|
+
# TODO: Solrを使って取得
|
14
|
+
if get_library
|
15
|
+
@event_strips = Event.at(@library).event_strips_for_month(@shown_month)
|
16
|
+
else
|
17
|
+
@event_strips = Event.event_strips_for_month(@shown_month)
|
18
|
+
end
|
19
|
+
get_libraries
|
20
|
+
end
|
21
|
+
|
22
|
+
def show
|
23
|
+
date = Time.zone.local(params[:year].to_i, params[:month].to_i, params[:day].to_i) rescue Time.zone.now
|
24
|
+
date_string = date.strftime('%Y/%m/%d')
|
25
|
+
if Event.search do
|
26
|
+
with(:start_at).less_than date
|
27
|
+
with(:end_at).greater_than date
|
28
|
+
end.results.empty?
|
29
|
+
redirect_to new_event_path(:date => date_string)
|
30
|
+
else
|
31
|
+
redirect_to events_path(:date => date_string)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class EventCategoriesController < InheritedResources::Base
|
2
|
+
respond_to :html, :xml
|
3
|
+
load_and_authorize_resource
|
4
|
+
|
5
|
+
def update
|
6
|
+
@event_category = EventCategory.find(params[:id])
|
7
|
+
if params[:position]
|
8
|
+
@event_category.insert_at(params[:position])
|
9
|
+
redirect_to event_categories_url
|
10
|
+
return
|
11
|
+
end
|
12
|
+
update!
|
13
|
+
end
|
14
|
+
|
15
|
+
def index
|
16
|
+
@event_categories = @event_categories.page(params[:page])
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
class EventImportFilesController < ApplicationController
|
2
|
+
load_and_authorize_resource
|
3
|
+
|
4
|
+
# GET /event_import_files
|
5
|
+
# GET /event_import_files.xml
|
6
|
+
def index
|
7
|
+
@event_import_files = EventImportFile.page(params[:page])
|
8
|
+
|
9
|
+
respond_to do |format|
|
10
|
+
format.html # index.html.erb
|
11
|
+
format.xml { render :xml => @event_import_files }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /event_import_files/1
|
16
|
+
# GET /event_import_files/1.xml
|
17
|
+
def show
|
18
|
+
if @event_import_file.event_import.path
|
19
|
+
unless configatron.uploaded_file.storage == :s3
|
20
|
+
file = @event_import_file.event_import.path
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
respond_to do |format|
|
25
|
+
format.html # show.html.erb
|
26
|
+
format.xml { render :xml => @event_import_file }
|
27
|
+
format.download {
|
28
|
+
if configatron.uploaded_file.storage == :s3
|
29
|
+
redirect_to @event_import_file.event_import.expiring_url(10)
|
30
|
+
else
|
31
|
+
send_file file, :filename => @event_import_file.event_import_file_name, :type => 'application/octet-stream'
|
32
|
+
end
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# GET /event_import_files/new
|
38
|
+
# GET /event_import_files/new.xml
|
39
|
+
def new
|
40
|
+
@event_import_file = EventImportFile.new
|
41
|
+
|
42
|
+
respond_to do |format|
|
43
|
+
format.html # new.html.erb
|
44
|
+
format.xml { render :xml => @event_import_file }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# GET /event_import_files/1/edit
|
49
|
+
def edit
|
50
|
+
end
|
51
|
+
|
52
|
+
# POST /event_import_files
|
53
|
+
# POST /event_import_files.xml
|
54
|
+
def create
|
55
|
+
@event_import_file = EventImportFile.new(params[:event_import_file])
|
56
|
+
@event_import_file.user = current_user
|
57
|
+
|
58
|
+
respond_to do |format|
|
59
|
+
if @event_import_file.save
|
60
|
+
flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.event_import_file'))
|
61
|
+
format.html { redirect_to(@event_import_file) }
|
62
|
+
format.xml { render :xml => @event_import_file, :status => :created, :location => @event_import_file }
|
63
|
+
else
|
64
|
+
format.html { render :action => "new" }
|
65
|
+
format.xml { render :xml => @event_import_file.errors, :status => :unprocessable_entity }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# PUT /event_import_files/1
|
71
|
+
# PUT /event_import_files/1.xml
|
72
|
+
def update
|
73
|
+
respond_to do |format|
|
74
|
+
if @event_import_file.update_attributes(params[:event_import_file])
|
75
|
+
flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.event_import_file'))
|
76
|
+
format.html { redirect_to(@event_import_file) }
|
77
|
+
format.xml { head :ok }
|
78
|
+
else
|
79
|
+
format.html { render :action => "edit" }
|
80
|
+
format.xml { render :xml => @event_import_file.errors, :status => :unprocessable_entity }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# DELETE /event_import_files/1
|
86
|
+
# DELETE /event_import_files/1.xml
|
87
|
+
def destroy
|
88
|
+
@event_import_file.destroy
|
89
|
+
|
90
|
+
respond_to do |format|
|
91
|
+
format.html { redirect_to(event_import_files_url) }
|
92
|
+
format.xml { head :ok }
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class EventImportResultsController < InheritedResources::Base
|
2
|
+
respond_to :html, :xml, :csv
|
3
|
+
load_and_authorize_resource
|
4
|
+
has_scope :file_id
|
5
|
+
actions :index, :show, :destroy
|
6
|
+
|
7
|
+
def index
|
8
|
+
@event_import_file = EventImportFile.where(:id => params[:event_import_file_id]).first
|
9
|
+
if @event_import_file
|
10
|
+
@event_import_results = @event_import_file.event_import_results.page(params[:page])
|
11
|
+
else
|
12
|
+
@event_import_results = @event_import_results.page(params[:page])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
class EventsController < ApplicationController
|
3
|
+
load_and_authorize_resource
|
4
|
+
before_filter :get_library, :get_patron
|
5
|
+
before_filter :get_libraries, :except => :destroy
|
6
|
+
before_filter :prepare_options
|
7
|
+
before_filter :store_page, :only => :index
|
8
|
+
after_filter :solr_commit, :only => [:create, :update, :destroy]
|
9
|
+
after_filter :convert_charset, :only => :index
|
10
|
+
|
11
|
+
# GET /events
|
12
|
+
# GET /events.xml
|
13
|
+
def index
|
14
|
+
@count = {}
|
15
|
+
query = params[:query].to_s.strip
|
16
|
+
@query = query.dup
|
17
|
+
query = query.gsub(' ', ' ')
|
18
|
+
tag = params[:tag].to_s if params[:tag].present?
|
19
|
+
date = params[:date].to_s if params[:date].present?
|
20
|
+
mode = params[:mode]
|
21
|
+
|
22
|
+
search = Sunspot.new_search(Event)
|
23
|
+
library = @library
|
24
|
+
search.build do
|
25
|
+
fulltext query if query.present?
|
26
|
+
with(:library_id).equal_to library.id if library
|
27
|
+
#with(:tag).equal_to tag
|
28
|
+
if date
|
29
|
+
with(:start_at).less_than Time.zone.parse(date)
|
30
|
+
with(:end_at).greater_than Time.zone.parse(date)
|
31
|
+
end
|
32
|
+
case mode
|
33
|
+
when 'upcoming'
|
34
|
+
with(:start_at).greater_than Time.zone.now.beginning_of_day
|
35
|
+
when 'past'
|
36
|
+
with(:start_at).less_than Time.zone.now.beginning_of_day
|
37
|
+
end
|
38
|
+
order_by(:start_at, :desc)
|
39
|
+
end
|
40
|
+
|
41
|
+
page = params[:page] || 1
|
42
|
+
search.query.paginate(page.to_i, Event.per_page)
|
43
|
+
@events = search.execute!.results
|
44
|
+
@count[:query_result] = @events.total_entries
|
45
|
+
|
46
|
+
respond_to do |format|
|
47
|
+
format.html # index.html.erb
|
48
|
+
format.xml { render :xml => @events }
|
49
|
+
format.rss { render :layout => false }
|
50
|
+
format.csv
|
51
|
+
format.atom
|
52
|
+
format.ics
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# GET /events/1
|
57
|
+
# GET /events/1.xml
|
58
|
+
def show
|
59
|
+
@event = Event.find(params[:id])
|
60
|
+
|
61
|
+
respond_to do |format|
|
62
|
+
format.html # show.html.erb
|
63
|
+
format.xml { render :xml => @event }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# GET /events/new
|
68
|
+
# GET /events/new.xml
|
69
|
+
def new
|
70
|
+
prepare_options
|
71
|
+
if params[:date]
|
72
|
+
begin
|
73
|
+
date = Time.zone.parse(params[:date])
|
74
|
+
rescue ArgumentError
|
75
|
+
date = Time.zone.now.beginning_of_day
|
76
|
+
flash[:notice] = t('page.invalid_date')
|
77
|
+
end
|
78
|
+
else
|
79
|
+
date = Time.zone.now.beginning_of_day
|
80
|
+
end
|
81
|
+
@event = Event.new(:start_at => date, :end_at => date)
|
82
|
+
@event.library = @library
|
83
|
+
|
84
|
+
respond_to do |format|
|
85
|
+
format.html # new.html.erb
|
86
|
+
format.xml { render :xml => @event }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# GET /events/1/edit
|
91
|
+
def edit
|
92
|
+
@event = Event.find(params[:id])
|
93
|
+
prepare_options
|
94
|
+
end
|
95
|
+
|
96
|
+
# POST /events
|
97
|
+
# POST /events.xml
|
98
|
+
def create
|
99
|
+
@event = Event.new(params[:event])
|
100
|
+
@event.set_date
|
101
|
+
|
102
|
+
respond_to do |format|
|
103
|
+
if @event.save
|
104
|
+
flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.event'))
|
105
|
+
format.html { redirect_to(@event) }
|
106
|
+
format.xml { render :xml => @event, :status => :created, :location => @event }
|
107
|
+
else
|
108
|
+
prepare_options
|
109
|
+
format.html { render :action => "new" }
|
110
|
+
format.xml { render :xml => @event.errors, :status => :unprocessable_entity }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# PUT /events/1
|
116
|
+
# PUT /events/1.xml
|
117
|
+
def update
|
118
|
+
@event = Event.find(params[:id])
|
119
|
+
@event.set_date
|
120
|
+
|
121
|
+
respond_to do |format|
|
122
|
+
if @event.update_attributes(params[:event])
|
123
|
+
|
124
|
+
flash[:notice] = t('controller.successfully_updated', :model => t('activerecord.models.event'))
|
125
|
+
format.html { redirect_to(@event) }
|
126
|
+
format.xml { head :ok }
|
127
|
+
else
|
128
|
+
prepare_options
|
129
|
+
format.html { render :action => "edit" }
|
130
|
+
format.xml { render :xml => @event.errors, :status => :unprocessable_entity }
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
# DELETE /events/1
|
136
|
+
# DELETE /events/1.xml
|
137
|
+
def destroy
|
138
|
+
@event = Event.find(params[:id])
|
139
|
+
@event.destroy
|
140
|
+
|
141
|
+
respond_to do |format|
|
142
|
+
format.html { redirect_to(events_url) }
|
143
|
+
format.xml { head :ok }
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
private
|
148
|
+
def prepare_options
|
149
|
+
@event_categories = EventCategory.all
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
class ParticipatesController < ApplicationController
|
2
|
+
load_and_authorize_resource
|
3
|
+
|
4
|
+
# GET /participates
|
5
|
+
# GET /participates.json
|
6
|
+
def index
|
7
|
+
@participates = Participate.page(params[:page])
|
8
|
+
|
9
|
+
respond_to do |format|
|
10
|
+
format.html # index.html.erb
|
11
|
+
format.json { render :json => @participates }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /participates/1
|
16
|
+
# GET /participates/1.json
|
17
|
+
def show
|
18
|
+
respond_to do |format|
|
19
|
+
format.html # show.html.erb
|
20
|
+
format.json { render :json => @participate }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET /participates/new
|
25
|
+
# GET /participates/new.json
|
26
|
+
def new
|
27
|
+
@participate = Participate.new
|
28
|
+
|
29
|
+
respond_to do |format|
|
30
|
+
format.html # new.html.erb
|
31
|
+
format.json { render :json => @participate }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# GET /participates/1/edit
|
36
|
+
def edit
|
37
|
+
end
|
38
|
+
|
39
|
+
# POST /participates
|
40
|
+
# POST /participates.json
|
41
|
+
def create
|
42
|
+
@participate = Participate.new(params[:participate])
|
43
|
+
|
44
|
+
respond_to do |format|
|
45
|
+
if @participate.save
|
46
|
+
flash[:notice] = 'Participate was successfully created.'
|
47
|
+
format.html { redirect_to(@participate) }
|
48
|
+
format.json { render :json => @participate, :status => :created, :location => @participate }
|
49
|
+
else
|
50
|
+
format.html { render :action => "new" }
|
51
|
+
format.json { render :json => @participate.errors, :status => :unprocessable_entity }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# PUT /participates/1
|
57
|
+
# PUT /participates/1.json
|
58
|
+
def update
|
59
|
+
respond_to do |format|
|
60
|
+
if @participate.update_attributes(params[:participate])
|
61
|
+
flash[:notice] = 'Participate was successfully updated.'
|
62
|
+
format.html { redirect_to(@participate) }
|
63
|
+
format.json { head :ok }
|
64
|
+
else
|
65
|
+
format.html { render :action => "edit" }
|
66
|
+
format.json { render :json => @participate.errors, :status => :unprocessable_entity }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# DELETE /participates/1
|
72
|
+
# DELETE /participates/1.json
|
73
|
+
def destroy
|
74
|
+
@participate.destroy
|
75
|
+
|
76
|
+
respond_to do |format|
|
77
|
+
format.html { redirect_to(participates_url) }
|
78
|
+
format.json { head :ok }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|