event_calendar_engine 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. data/Gemfile +23 -0
  2. data/Gemfile.lock +161 -0
  3. data/README +1 -0
  4. data/Rakefile +39 -0
  5. data/VERSION +1 -0
  6. data/app/controllers/application_controller.rb +4 -0
  7. data/app/controllers/attendees_controller.rb +53 -0
  8. data/app/controllers/event_calendar/application_controller.rb +5 -0
  9. data/app/controllers/event_revisions_controller.rb +26 -0
  10. data/app/controllers/events_controller.rb +129 -0
  11. data/app/helpers/event_calendar/application_helper.rb +118 -0
  12. data/app/helpers/events_helper.rb +2 -0
  13. data/app/models/attendee.rb +6 -0
  14. data/app/models/deletable_instance_methods.rb +7 -0
  15. data/app/models/event.rb +124 -0
  16. data/app/models/event_revision.rb +9 -0
  17. data/app/models/participant.rb +23 -0
  18. data/app/models/participator.rb +20 -0
  19. data/app/views/attendees/index.html.erb +14 -0
  20. data/app/views/attendees/new.html.erb +13 -0
  21. data/app/views/event-calendar-shared/_flash.html.erb +7 -0
  22. data/app/views/event-calendar-shared/_main_menu.html.erb +3 -0
  23. data/app/views/event-calendar-shared/_navigation.html.erb +15 -0
  24. data/app/views/event_revisions/index.html.erb +31 -0
  25. data/app/views/event_revisions/show.html.erb +5 -0
  26. data/app/views/events/_browse_event_revisions.html.erb +19 -0
  27. data/app/views/events/_event.html.erb +10 -0
  28. data/app/views/events/_event_details.html.erb +26 -0
  29. data/app/views/events/_form.html.erb +36 -0
  30. data/app/views/events/attendees.html.erb +29 -0
  31. data/app/views/events/edit.html.erb +3 -0
  32. data/app/views/events/index.html.erb +41 -0
  33. data/app/views/events/new.html.erb +3 -0
  34. data/app/views/events/search.html.erb +11 -0
  35. data/app/views/events/show.html.erb +30 -0
  36. data/app/views/layouts/application.html.erb +49 -0
  37. data/config/application.rb +42 -0
  38. data/config/blueprint_settings.yml +10 -0
  39. data/config/boot.rb +13 -0
  40. data/config/cucumber.yml +8 -0
  41. data/config/database.example.yml +22 -0
  42. data/config/environment.rb +5 -0
  43. data/config/environments/development.rb +26 -0
  44. data/config/environments/production.rb +49 -0
  45. data/config/environments/test.rb +38 -0
  46. data/config/initializers/backtrace_silencers.rb +7 -0
  47. data/config/initializers/formtastic.rb +55 -0
  48. data/config/initializers/inflections.rb +10 -0
  49. data/config/initializers/mime_types.rb +5 -0
  50. data/config/initializers/secret_token.rb +9 -0
  51. data/config/initializers/session_store.rb +10 -0
  52. data/config/locales/en.yml +5 -0
  53. data/config/routes.rb +67 -0
  54. data/db/migrate/20101011142543_create_events.rb +19 -0
  55. data/db/migrate/20101011172027_create_attendees.rb +16 -0
  56. data/db/migrate/20101011200048_make_events_revisable.rb +25 -0
  57. data/db/schema.rb +45 -0
  58. data/db/seeds.rb +7 -0
  59. data/lib/event_calendar.rb +3 -0
  60. data/lib/event_calendar/engine.rb +25 -0
  61. data/lib/generators/event_calendar/install/USAGE +5 -0
  62. data/lib/generators/event_calendar/install/install_generator.rb +19 -0
  63. data/lib/generators/event_calendar/install/templates/event_calendar.rake +169 -0
  64. data/lib/tasks/blueprint.rake +25 -0
  65. data/lib/tasks/cucumber.rake +53 -0
  66. data/public/404.html +26 -0
  67. data/public/422.html +26 -0
  68. data/public/500.html +26 -0
  69. data/public/favicon.ico +0 -0
  70. data/public/images/rails.png +0 -0
  71. data/public/javascripts/event_calendar.js +62 -0
  72. data/public/javascripts/event_calendar_behaviors.js +131 -0
  73. data/public/javascripts/fullcalendar.js +3965 -0
  74. data/public/javascripts/jquery-ui-1.7.2.custom.min.js +298 -0
  75. data/public/javascripts/jquery.clonePosition.js +27 -0
  76. data/public/javascripts/jquery.js +154 -0
  77. data/public/javascripts/jquery.qtip-1.0.0-rc3.js +2149 -0
  78. data/public/javascripts/jquery.string.1.0-min.js +6 -0
  79. data/public/javascripts/jquery.tablesorter.min.js +2 -0
  80. data/public/javascripts/lowpro.jquery.js +224 -0
  81. data/public/javascripts/rails.js +132 -0
  82. data/public/robots.txt +5 -0
  83. data/public/stylesheets/blueprint/grid.css +280 -0
  84. data/public/stylesheets/blueprint/icons/cross.png +0 -0
  85. data/public/stylesheets/blueprint/icons/doc.png +0 -0
  86. data/public/stylesheets/blueprint/icons/email.png +0 -0
  87. data/public/stylesheets/blueprint/icons/external.png +0 -0
  88. data/public/stylesheets/blueprint/icons/feed.png +0 -0
  89. data/public/stylesheets/blueprint/icons/im.png +0 -0
  90. data/public/stylesheets/blueprint/icons/key.png +0 -0
  91. data/public/stylesheets/blueprint/icons/pdf.png +0 -0
  92. data/public/stylesheets/blueprint/icons/tick.png +0 -0
  93. data/public/stylesheets/blueprint/icons/visited.png +0 -0
  94. data/public/stylesheets/blueprint/icons/xls.png +0 -0
  95. data/public/stylesheets/blueprint/ie.css +36 -0
  96. data/public/stylesheets/blueprint/plugins/buttons/icons/cross.png +0 -0
  97. data/public/stylesheets/blueprint/plugins/buttons/icons/key.png +0 -0
  98. data/public/stylesheets/blueprint/plugins/buttons/icons/tick.png +0 -0
  99. data/public/stylesheets/blueprint/plugins/buttons/readme.txt +32 -0
  100. data/public/stylesheets/blueprint/plugins/buttons/screen.css +97 -0
  101. data/public/stylesheets/blueprint/plugins/fancy-type/readme.txt +14 -0
  102. data/public/stylesheets/blueprint/plugins/fancy-type/screen.css +71 -0
  103. data/public/stylesheets/blueprint/plugins/link-icons/icons/doc.png +0 -0
  104. data/public/stylesheets/blueprint/plugins/link-icons/icons/email.png +0 -0
  105. data/public/stylesheets/blueprint/plugins/link-icons/icons/external.png +0 -0
  106. data/public/stylesheets/blueprint/plugins/link-icons/icons/feed.png +0 -0
  107. data/public/stylesheets/blueprint/plugins/link-icons/icons/im.png +0 -0
  108. data/public/stylesheets/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  109. data/public/stylesheets/blueprint/plugins/link-icons/icons/visited.png +0 -0
  110. data/public/stylesheets/blueprint/plugins/link-icons/icons/xls.png +0 -0
  111. data/public/stylesheets/blueprint/plugins/link-icons/readme.txt +18 -0
  112. data/public/stylesheets/blueprint/plugins/link-icons/screen.css +40 -0
  113. data/public/stylesheets/blueprint/plugins/rtl/readme.txt +10 -0
  114. data/public/stylesheets/blueprint/plugins/rtl/screen.css +110 -0
  115. data/public/stylesheets/blueprint/plugins/silksprite/sprite.css +1 -0
  116. data/public/stylesheets/blueprint/plugins/silksprite/sprites.png +0 -0
  117. data/public/stylesheets/blueprint/print.css +29 -0
  118. data/public/stylesheets/blueprint/readme.txt +12 -0
  119. data/public/stylesheets/blueprint/screen.css +429 -0
  120. data/public/stylesheets/error_messages.css +65 -0
  121. data/public/stylesheets/formtastic.css +131 -0
  122. data/public/stylesheets/formtastic_changes.css +14 -0
  123. data/public/stylesheets/fullcalendar.css +574 -0
  124. data/public/stylesheets/fullcalendar_changes.css +0 -0
  125. data/public/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  126. data/public/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  127. data/public/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  128. data/public/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  129. data/public/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  130. data/public/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  131. data/public/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  132. data/public/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  133. data/public/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
  134. data/public/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  135. data/public/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
  136. data/public/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
  137. data/public/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  138. data/public/stylesheets/smoothness/jquery-ui-1.7.2.custom.css +406 -0
  139. data/public/stylesheets/tablesorter/blue/asc.gif +0 -0
  140. data/public/stylesheets/tablesorter/blue/bg.gif +0 -0
  141. data/public/stylesheets/tablesorter/blue/desc.gif +0 -0
  142. data/public/stylesheets/tablesorter/blue/style.css +39 -0
  143. data/public/stylesheets/text_and_colors.css +49 -0
  144. data/spec/controllers/attendees_controller_spec.rb +27 -0
  145. data/spec/controllers/event_revisions_controller_spec.rb +86 -0
  146. data/spec/controllers/events_controller_spec.rb +168 -0
  147. data/spec/fixtures/event_calendar_events.yml +8 -0
  148. data/spec/models/deletable_instance_methods_spec.rb +61 -0
  149. data/spec/models/event_revision_spec.rb +36 -0
  150. data/spec/models/event_spec.rb +139 -0
  151. data/spec/spec_helper.rb +27 -0
  152. data/spec/spec_helpers/mocks.rb +6 -0
  153. data/vendor/plugins/searchable_by/MIT-LICENSE +20 -0
  154. data/vendor/plugins/searchable_by/README +55 -0
  155. data/vendor/plugins/searchable_by/Rakefile +23 -0
  156. data/vendor/plugins/searchable_by/init.rb +2 -0
  157. data/vendor/plugins/searchable_by/install.rb +1 -0
  158. data/vendor/plugins/searchable_by/lib/searchable_by.rb +137 -0
  159. data/vendor/plugins/searchable_by/tasks/searchable_by_tasks.rake +4 -0
  160. data/vendor/plugins/searchable_by/test/boot.rb +21 -0
  161. data/vendor/plugins/searchable_by/test/database.yml +22 -0
  162. data/vendor/plugins/searchable_by/test/fixtures/companies.yml +10 -0
  163. data/vendor/plugins/searchable_by/test/fixtures/company.rb +5 -0
  164. data/vendor/plugins/searchable_by/test/fixtures/employee.rb +5 -0
  165. data/vendor/plugins/searchable_by/test/fixtures/employees.yml +28 -0
  166. data/vendor/plugins/searchable_by/test/fixtures/schema.rb +18 -0
  167. data/vendor/plugins/searchable_by/test/helper.rb +12 -0
  168. data/vendor/plugins/searchable_by/test/lib/activerecord_test_case.rb +43 -0
  169. data/vendor/plugins/searchable_by/test/lib/activerecord_test_connector.rb +75 -0
  170. data/vendor/plugins/searchable_by/test/lib/load_fixtures.rb +9 -0
  171. data/vendor/plugins/searchable_by/test/searchable_by_test.rb +73 -0
  172. data/vendor/plugins/searchable_by/uninstall.rb +1 -0
  173. metadata +606 -0
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', "3.0.3"
4
+
5
+ gem 'sqlite3-ruby', :require => 'sqlite3'
6
+
7
+ gem 'RedCloth'
8
+ gem 'prarupa'
9
+ gem 'will_paginate', '~> 3.0.pre2'
10
+ gem 'formtastic'
11
+ gem 'acts_as_revisable', {
12
+ :git => "git://github.com/inertialbit/acts_as_revisable.git",
13
+ :branch => 'rails3'
14
+ }
15
+
16
+ group :development, :test do
17
+ gem 'engineer'
18
+ gem 'rspec-rails'
19
+ gem 'cucumber-rails'
20
+ gem 'capybara'
21
+ gem 'acts_as_fu'
22
+ gem 'rcov'
23
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,161 @@
1
+ GIT
2
+ remote: git://github.com/inertialbit/acts_as_revisable.git
3
+ revision: 4f4cba5de4faf87c9196afde9b4e16fa83915ef8
4
+ branch: rails3
5
+ specs:
6
+ acts_as_revisable (1.1.2)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ RedCloth (4.2.3)
12
+ abstract (1.0.0)
13
+ actionmailer (3.0.3)
14
+ actionpack (= 3.0.3)
15
+ mail (~> 2.2.9)
16
+ actionpack (3.0.3)
17
+ activemodel (= 3.0.3)
18
+ activesupport (= 3.0.3)
19
+ builder (~> 2.1.2)
20
+ erubis (~> 2.6.6)
21
+ i18n (~> 0.4)
22
+ rack (~> 1.2.1)
23
+ rack-mount (~> 0.6.13)
24
+ rack-test (~> 0.5.6)
25
+ tzinfo (~> 0.3.23)
26
+ activemodel (3.0.3)
27
+ activesupport (= 3.0.3)
28
+ builder (~> 2.1.2)
29
+ i18n (~> 0.4)
30
+ activerecord (3.0.3)
31
+ activemodel (= 3.0.3)
32
+ activesupport (= 3.0.3)
33
+ arel (~> 2.0.2)
34
+ tzinfo (~> 0.3.23)
35
+ activeresource (3.0.3)
36
+ activemodel (= 3.0.3)
37
+ activesupport (= 3.0.3)
38
+ activesupport (3.0.3)
39
+ acts_as_fu (0.0.7.2)
40
+ activerecord
41
+ sqlite3-ruby
42
+ arel (2.0.4)
43
+ builder (2.1.2)
44
+ capybara (0.4.0)
45
+ celerity (>= 0.7.9)
46
+ culerity (>= 0.2.4)
47
+ mime-types (>= 1.16)
48
+ nokogiri (>= 1.3.3)
49
+ rack (>= 1.0.0)
50
+ rack-test (>= 0.5.4)
51
+ selenium-webdriver (>= 0.0.27)
52
+ xpath (~> 0.1.2)
53
+ celerity (0.8.4)
54
+ childprocess (0.1.4)
55
+ ffi (~> 0.6.3)
56
+ cucumber (0.9.4)
57
+ builder (~> 2.1.2)
58
+ diff-lcs (~> 1.1.2)
59
+ gherkin (~> 2.2.9)
60
+ json (~> 1.4.6)
61
+ term-ansicolor (~> 1.0.5)
62
+ cucumber-rails (0.3.2)
63
+ cucumber (>= 0.8.0)
64
+ culerity (0.2.12)
65
+ diff-lcs (1.1.2)
66
+ engineer (0.2.3)
67
+ jeweler (>= 1.4.0)
68
+ erubis (2.6.6)
69
+ abstract (>= 1.0.0)
70
+ ffi (0.6.3)
71
+ rake (>= 0.8.7)
72
+ formtastic (1.2.1)
73
+ actionpack (>= 2.3.7)
74
+ activesupport (>= 2.3.7)
75
+ i18n (>= 0.4.0)
76
+ gherkin (2.2.9)
77
+ json (~> 1.4.6)
78
+ term-ansicolor (~> 1.0.5)
79
+ git (1.2.5)
80
+ i18n (0.4.2)
81
+ jeweler (1.5.1)
82
+ bundler (~> 1.0.0)
83
+ git (>= 1.2.5)
84
+ rake
85
+ json (1.4.6)
86
+ json_pure (1.4.6)
87
+ mail (2.2.10)
88
+ activesupport (>= 2.3.6)
89
+ i18n (~> 0.4.1)
90
+ mime-types (~> 1.16)
91
+ treetop (~> 1.4.8)
92
+ mime-types (1.16)
93
+ nokogiri (1.4.4)
94
+ polyglot (0.3.1)
95
+ prarupa (0.1.2)
96
+ RedCloth (~> 4.2)
97
+ rdiscount (~> 1.6)
98
+ rack (1.2.1)
99
+ rack-mount (0.6.13)
100
+ rack (>= 1.0.0)
101
+ rack-test (0.5.6)
102
+ rack (>= 1.0)
103
+ rails (3.0.3)
104
+ actionmailer (= 3.0.3)
105
+ actionpack (= 3.0.3)
106
+ activerecord (= 3.0.3)
107
+ activeresource (= 3.0.3)
108
+ activesupport (= 3.0.3)
109
+ bundler (~> 1.0)
110
+ railties (= 3.0.3)
111
+ railties (3.0.3)
112
+ actionpack (= 3.0.3)
113
+ activesupport (= 3.0.3)
114
+ rake (>= 0.8.7)
115
+ thor (~> 0.14.4)
116
+ rake (0.8.7)
117
+ rcov (0.9.9)
118
+ rdiscount (1.6.5)
119
+ rspec (2.1.0)
120
+ rspec-core (~> 2.1.0)
121
+ rspec-expectations (~> 2.1.0)
122
+ rspec-mocks (~> 2.1.0)
123
+ rspec-core (2.1.0)
124
+ rspec-expectations (2.1.0)
125
+ diff-lcs (~> 1.1.2)
126
+ rspec-mocks (2.1.0)
127
+ rspec-rails (2.1.0)
128
+ rspec (~> 2.1.0)
129
+ rubyzip (0.9.4)
130
+ selenium-webdriver (0.1.0)
131
+ childprocess (= 0.1.4)
132
+ ffi (~> 0.6.3)
133
+ json_pure
134
+ rubyzip
135
+ sqlite3-ruby (1.3.2)
136
+ term-ansicolor (1.0.5)
137
+ thor (0.14.6)
138
+ treetop (1.4.9)
139
+ polyglot (>= 0.3.1)
140
+ tzinfo (0.3.23)
141
+ will_paginate (3.0.pre2)
142
+ xpath (0.1.2)
143
+ nokogiri (~> 1.3)
144
+
145
+ PLATFORMS
146
+ ruby
147
+
148
+ DEPENDENCIES
149
+ RedCloth
150
+ acts_as_fu
151
+ acts_as_revisable!
152
+ capybara
153
+ cucumber-rails
154
+ engineer
155
+ formtastic
156
+ prarupa
157
+ rails (= 3.0.3)
158
+ rcov
159
+ rspec-rails
160
+ sqlite3-ruby
161
+ will_paginate (~> 3.0.pre2)
data/README ADDED
@@ -0,0 +1 @@
1
+ Basic versioned event management
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ EventCalendar::Application.load_tasks
8
+
9
+ excluded_files = %w(config/database.yml)
10
+
11
+ Engineer::Tasks.new do |gem|
12
+ gem.name = "event_calendar_engine"
13
+ gem.summary = %Q{Simple versioned event management for Rails 3.}
14
+ gem.description = %Q{Provides basic event management features with versioned history of changes.}
15
+ gem.email = ["jason.lapier@gmail.com", "jeremiah@inertialbit.net"]
16
+ gem.homepage = "http://github.com/inertialbit/event_calendar"
17
+ gem.authors = ["Jason LaPier", "Jeremiah Heller"]
18
+ gem.require_path = 'lib'
19
+ gem.files = FileList[
20
+ "[A-Z]*",
21
+ "{app,config,lib,public,vendor}/**/*",
22
+ "db/**/*.rb"
23
+ ]
24
+ gem.test_files = FileList["spec/**/*"]
25
+ excluded_files.each{|f| gem.files.exclude(f)}
26
+
27
+ # Include Bundler dependencies
28
+ Bundler.definition.dependencies.each do |dependency|
29
+ next if dependency.name == "engineer"
30
+
31
+ if (dependency.groups & [:default, :production]).any?
32
+ gem.add_dependency dependency.name, *dependency.requirement.as_list
33
+ else
34
+ gem.add_development_dependency dependency.name, *dependency.requirement.as_list
35
+ end
36
+ end
37
+
38
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
39
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,4 @@
1
+ # stub to allow for standalone mode
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery
4
+ end
@@ -0,0 +1,53 @@
1
+ class AttendeesController < EventCalendar::ApplicationController
2
+
3
+ before_filter :load_event
4
+
5
+ rescue_from ActiveRecord::RecordInvalid, :with => :invalid_record
6
+
7
+ include ActionView::Helpers::TextHelper # for pluralize in #create
8
+
9
+ private
10
+ def invalid_record(e)
11
+ if action_name == 'create'
12
+ flash.now[:notice] = "A processing error occurred while attempting "+
13
+ "to create the selected attendees."
14
+
15
+
16
+ @events = Event.all
17
+ @participants = Participant.types.collect do |type|
18
+ type.send(:find, :all)
19
+ end.flatten
20
+ render :new
21
+ end
22
+ end
23
+ def load_all_participants
24
+ @participants = Participant.types.collect do |type|
25
+ type.send(:find, :all)
26
+ end.flatten
27
+ end
28
+ def load_event
29
+ if params[:event_id]
30
+ @event = Event.includes(:attendees).find(params[:event_id])
31
+ else
32
+ redirect_to(events_path, {
33
+ :notice => "Which event does the new attendee apply to?"
34
+ })
35
+ end
36
+ end
37
+ protected
38
+ public
39
+ def index
40
+ # load_event in before_filter
41
+ end
42
+ def new
43
+ @attendee = Attendee.new
44
+ @events = Event.includes(:attendees).all
45
+ load_all_participants
46
+ end
47
+ def create
48
+ attendees = Participator.create!(params[:attendee])
49
+ redirect_to(events_path, {
50
+ :notice => "Created #{pluralize(attendees.count, 'Attendee')}!"
51
+ })
52
+ end
53
+ end
@@ -0,0 +1,5 @@
1
+ class EventCalendar::ApplicationController < ApplicationController
2
+ private
3
+ protected
4
+ public
5
+ end
@@ -0,0 +1,26 @@
1
+ class EventRevisionsController < EventCalendar::ApplicationController
2
+
3
+ def index
4
+ if params[:id]
5
+ redirect_to(event_revision_path(params[:id]))
6
+ else
7
+ @deleted_events = EventRevision.deleted
8
+ end
9
+ end
10
+
11
+ def show
12
+ @event_revision = EventRevision.find params[:id]
13
+ end
14
+
15
+
16
+ def restore
17
+ @event_revision = EventRevision.find(params[:id])
18
+ if @event_revision.restore
19
+ flash[:notice] = "Event <em>#{@event_revision.name}</em> restored.".html_safe
20
+ redirect_to(event_path(@event_revision))
21
+ else
22
+ flash[:error] = "There was an error restoring the event."
23
+ redirect_to(event_revisions_path)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,129 @@
1
+ class EventsController < EventCalendar::ApplicationController
2
+
3
+ # before_filter :load_and_authorize_current_user, :except => [:index, :show]
4
+
5
+ # GET /events
6
+ # GET /events.xml
7
+ def index
8
+ @events = Event.find :all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.xml { render :xml => @events }
13
+ format.js do
14
+ json = @events.map do |e|
15
+ e.to_hash_for_calendar(event_path(e))
16
+ end
17
+ render :json => json.to_json
18
+ end
19
+ end
20
+ end
21
+
22
+ def search
23
+ # TODO render a search results page instead of a calendar
24
+ @events = Event.search(params[:q],
25
+ :narrow_fields => params[:fields] ? params[:fields].keys : nil).paginate :page => params[:page]
26
+ end
27
+
28
+ # GET /events/1
29
+ # GET /events/1.xml
30
+ def show
31
+ # @event = Event.find(params[:id], :include => :file_attachments)
32
+ @event = Event.find(params[:id])
33
+
34
+ respond_to do |format|
35
+ format.html # show.html.erb
36
+ format.xml { render :xml => @event }
37
+ end
38
+ end
39
+
40
+ # GET /events/new
41
+ # GET /events/new.xml
42
+ def new
43
+ @event = Event.new
44
+
45
+ respond_to do |format|
46
+ format.html # new.html.erb
47
+ format.xml { render :xml => @event }
48
+ end
49
+ end
50
+
51
+ # GET /events/1/edit
52
+ def edit
53
+ @event = Event.find(params[:id])
54
+ end
55
+
56
+ # POST /events
57
+ # POST /events.xml
58
+ def create
59
+ @event = Event.new(params[:event])
60
+ # @event.modified_by_user = current_user
61
+
62
+ respond_to do |format|
63
+ if @event.save
64
+ flash[:notice] = 'Event was successfully created.'
65
+ format.html { redirect_to(event_path(@event)) }
66
+ format.xml { render :xml => @event, :status => :created, :location => @event }
67
+ else
68
+ format.html { render :action => "new" }
69
+ format.xml { render :xml => @event.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ # PUT /events/1
75
+ # PUT /events/1.xml
76
+ def update
77
+ @event = Event.find(params[:id])
78
+
79
+ respond_to do |format|
80
+ # if @event.update_attributes(params[:event].merge(:modified_by_user => current_user))
81
+ if @event.update_attributes(params[:event])
82
+ flash[:notice] = 'Event was successfully updated.'
83
+ format.html { redirect_to(@event) }
84
+ format.xml { head :ok }
85
+ else
86
+ format.html { render :action => "edit" }
87
+ format.xml { render :xml => @event.errors, :status => :unprocessable_entity }
88
+ end
89
+ end
90
+ end
91
+
92
+ # DELETE /events/1
93
+ # DELETE /events/1.xml
94
+ def destroy
95
+ @event = Event.find(params[:id])
96
+ @event.destroy
97
+
98
+ respond_to do |format|
99
+ format.html { redirect_to(events_path) }
100
+ format.xml { head :ok }
101
+ end
102
+ end
103
+
104
+ # def drop_contact
105
+ # @event = Event.find(params[:id])
106
+ # if @event.drop_attendees(params[:contact_ids] || params[:contact_id])
107
+ # flash[:notice] = "Contact(s) removed from #{@event.name} roster."
108
+ # else
109
+ # flash[:warning] = "Failed to remove contact(s) from #{@event.name} roster. (#{@event.errors.full_messages.join('; ')}"
110
+ # end
111
+ # redirect_to @event
112
+ # end
113
+
114
+ # def add_attendees
115
+ # @event = Event.find(params[:id])
116
+ # @contacts_not_in_group = Contact.find(:all, :order => 'last_name, first_name',
117
+ # :conditions => 'last_name IS NOT NULL AND last_name != ""') - @event.contacts
118
+ # end
119
+
120
+ # def add_contacts
121
+ # @event = Event.find(params[:id])
122
+ # if @event.add_attendees(params[:contact_ids])
123
+ # flash[:notice] = "Contacts(s) added to #{@event.name}."
124
+ # else
125
+ # flash[:warning] = "Failed to add contact(s) to #{@event.name}. (#{@event.errors.full_messages.join('; ')}"
126
+ # end
127
+ # redirect_to @event
128
+ # end
129
+ end