event_calendar_engine 0.1.11 → 0.2.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 (45) hide show
  1. data/Gemfile.lock +39 -35
  2. data/VERSION +1 -1
  3. data/app/controllers/event_revisions_controller.rb +1 -1
  4. data/app/controllers/events_controller.rb +21 -36
  5. data/app/controllers/links_controller.rb +62 -0
  6. data/app/helpers/event_calendar/application_helper.rb +73 -4
  7. data/app/models/event.rb +21 -43
  8. data/app/models/event_instance_methods.rb +40 -9
  9. data/app/models/link.rb +19 -0
  10. data/app/views/event_revisions/_list_group.html.erb +1 -1
  11. data/app/views/events/_details.html.erb +2 -1
  12. data/app/views/events/_event.html.erb +2 -0
  13. data/app/views/events/_event_details.html.erb +22 -17
  14. data/app/views/events/_form.html.erb +47 -3
  15. data/app/views/events/_list_group.html.erb +1 -1
  16. data/app/views/events/_one_day_list_event.html.erb +1 -1
  17. data/app/views/events/edit.html.erb +1 -1
  18. data/app/views/links/_form.html.erb +18 -0
  19. data/app/views/links/_link.html.erb +6 -0
  20. data/app/views/links/_links.html.erb +6 -0
  21. data/app/views/links/create.js.rjs +14 -0
  22. data/app/views/links/edit.html.erb +3 -0
  23. data/app/views/links/new.html.erb +3 -0
  24. data/app/views/links/show.html.erb +3 -0
  25. data/app/views/links/update.js.rjs +15 -0
  26. data/config/routes.rb +1 -56
  27. data/db/migrate/20110204223256_add_presenters_facilitators_to_events.rb +11 -0
  28. data/db/migrate/20110206000427_create_event_calendar_links.rb +23 -0
  29. data/db/schema.rb +18 -1
  30. data/public/javascripts/event_calendar/event_calendar.js +7 -0
  31. data/public/javascripts/event_calendar/event_calendar_behaviors.js +92 -23
  32. data/public/stylesheets/event_calendar/blueprint/screen.css +1 -0
  33. data/spec/controllers/events_controller_spec.rb +4 -2
  34. data/spec/controllers/links_controller_spec.rb +140 -0
  35. data/spec/fixtures/event_calendar_events.yml +12 -2
  36. data/spec/fixtures/event_calendar_events_links.yml +3 -0
  37. data/spec/fixtures/event_calendar_links.yml +4 -0
  38. data/spec/helpers/event_calendar/application_helper_spec.rb +4 -4
  39. data/spec/models/event_instance_methods_spec.rb +58 -0
  40. data/spec/models/event_revision_spec.rb +11 -10
  41. data/spec/models/event_spec.rb +31 -65
  42. data/spec/models/link_spec.rb +31 -0
  43. data/spec/spec_helpers/helpers.rb +15 -0
  44. metadata +29 -6
  45. data/app/views/events/_times.html.erb +0 -5
@@ -2,25 +2,25 @@ module EventInstanceMethods
2
2
  attr_accessor :start_time, :end_time, :start_date, :end_date
3
3
 
4
4
  def start_time
5
- @start_time ||= start_on.present? ? start_on.in_time_zone(timezone) : start_on
5
+ @start_time ||= start_on
6
6
  end
7
7
 
8
8
  def end_time
9
- @end_time ||= end_on.present? ? end_on.in_time_zone(timezone) : end_on
9
+ @end_time ||= end_on
10
10
  end
11
11
 
12
12
  def start_date
13
- @start_date ||= start_on.present? ? start_on.in_time_zone(timezone).to_date : start_on
13
+ @start_date ||= start_on.present? ? start_on.to_date : start_on
14
14
  end
15
15
 
16
16
  def end_date
17
- @end_date ||= end_on.present? ? end_on.in_time_zone(timezone).to_date : end_on
17
+ @end_date ||= end_on.present? ? end_on.to_date : end_on
18
18
  end
19
19
 
20
20
  def start_year
21
21
  start_on.present? ? start_on.in_time_zone(timezone).year : start_on
22
22
  end
23
-
23
+
24
24
  def start_month
25
25
  start_on.present? ? start_on.in_time_zone(timezone).strftime("%B") : start_on
26
26
  end
@@ -29,21 +29,52 @@ module EventInstanceMethods
29
29
  start_on.present? ? start_on.in_time_zone(timezone).day : start_on
30
30
  end
31
31
 
32
+ def start_hour
33
+ start_on.present? ? start_on.hour : start_on
34
+ end
35
+
36
+ def start_min
37
+ start_on.present? ? start_on.min : start_on
38
+ end
39
+
32
40
  def end_year
33
- end_on.present? ? end_on.in_time_zone(timezone).year : end_on
41
+ end_on.present? ? end_on.year : end_on
34
42
  end
35
43
 
36
44
  def end_month
37
45
  end_on.present? ? end_on.in_time_zone(timezone).strftime("%B") : end_on
38
46
  end
39
47
 
48
+ def end_hour
49
+ end_on.present? ? end_on.hour : end_on
50
+ end
51
+
52
+ def end_min
53
+ end_on.present? ? end_on.min : end_on
54
+ end
55
+
40
56
  def end_day
41
57
  end_on.present? ? end_on.in_time_zone(timezone).day : end_on
42
58
  end
43
59
 
44
60
  def one_day?
45
- start_day == end_day &&
46
- start_month == end_month &&
47
- start_year == end_year
61
+ return true if start_on.blank? || end_on.blank?
62
+ start_on.day == end_on.day &&
63
+ start_on.month== end_on.month &&
64
+ start_on.year == end_on.year
65
+ end
66
+
67
+ def date
68
+ one_day? ? one_day_date : multi_day_date
69
+ end
70
+
71
+ def one_day_date
72
+ start_on.in_time_zone(timezone).strftime('%A, %B %d %Y')
73
+ end
74
+
75
+ def multi_day_date
76
+ return one_day_date if end_on.blank?
77
+ "#{start_on.in_time_zone(timezone).strftime('%A, %B %d')} - "+
78
+ "#{end_on.in_time_zone(timezone).strftime('%A, %B %d %Y')}"
48
79
  end
49
80
  end
@@ -0,0 +1,19 @@
1
+ class Link < ActiveRecord::Base
2
+ set_table_name 'event_calendar_links'
3
+
4
+ has_and_belongs_to_many :events, :join_table => 'event_calendar_events_links'
5
+
6
+ before_validation :detect_or_prepend_default_protocol
7
+
8
+ validates_presence_of :name, :url
9
+
10
+ private
11
+ def detect_or_prepend_default_protocol
12
+ self.url = 'http://'+url if scheme.blank? and url.present?
13
+ end
14
+ protected
15
+ public
16
+ def scheme
17
+ url.present? ? URI.parse(url).scheme : ''
18
+ end
19
+ end
@@ -6,7 +6,7 @@
6
6
  <li><%= month %>
7
7
  <ul>
8
8
  <% months_events.each do |event| %>
9
- <li>
9
+ <li class="zoom">
10
10
  <p>
11
11
  <%= link_to event.name, event_revision_path(event) %>
12
12
  <%= link_to 'restore', restore_event_revision_path(event),
@@ -1,4 +1,5 @@
1
1
  <%- unless details.one_day? %>
2
+ <%= render :partial => 'events/multi_day_list_event', :object => details %>
2
3
  <%= textilize(details.location) %>
3
4
  <%= textilize(details.description) %>
4
5
  <%- else -%>
@@ -8,6 +9,6 @@
8
9
  </div>
9
10
 
10
11
  <div class="span-6 last">
11
- <%= render :partial => 'events/times', :object => times_with_zones(details) %>
12
+ <%= event_times(details) %>
12
13
  </div>
13
14
  <%- end -%>
@@ -2,4 +2,6 @@
2
2
  <h1><%= link_to event.name, event_path(event) %> (<em><%= event.event_type %></em>)</h1>
3
3
 
4
4
  <%= render :partial => 'events/event_details', :object => event %>
5
+
6
+ <%= render :partial => 'links/links' if event.current_revision? %>
5
7
  <% end %>
@@ -1,27 +1,32 @@
1
- <p>
2
- <strong>Starts</strong><br />
3
- <%= event_details.start_on.in_time_zone(event_details.timezone).strftime('%A, %B %d %Y') %>
1
+ <p class="zoom">
2
+ <strong>Date:</strong> <%= event_details.date %>
3
+ <%- if event_details.one_day? -%>
4
+ <br />
5
+ <strong>Time:</strong> <%= event_times(event_details) %>
6
+ <%- end -%>
4
7
  </p>
5
- <%- unless event_details.one_day? %>
6
- <% if event_details.end_on %>
7
- <p>
8
- <strong>Ends</strong><br />
9
- <%= event_details.end_on.in_time_zone(event_details.timezone).strftime('%A, %B %d %Y') %>
10
- </p>
11
- <% end %>
12
- <%- else -%>
13
- <%= render :partial => 'events/times', :object => times_with_zones(event_details) %>
14
- <%- end -%>
8
+ <% unless event_details.presenters.blank? %>
9
+ <p class="zoom">
10
+ <strong>Presenters</strong><br>
11
+ <%= textilize_without_paragraph event_details.presenters %>
12
+ </p>
13
+ <% end %>
14
+ <% unless event_details.facilitators.blank? %>
15
+ <p class="zoom">
16
+ <strong>Facilitators</strong><br>
17
+ <%= textilize_without_paragraph event_details.facilitators %>
18
+ </p>
19
+ <% end %>
15
20
  <% unless event_details.location.blank? %>
16
- <p>
17
- <strong>Location</strong><br/>
21
+ <p class="zoom">
22
+ <strong>Location</strong><br>
18
23
  <%= textilize_without_paragraph event_details.location %>
19
24
  </p>
20
25
  <% end %>
21
26
 
22
27
  <% unless event_details.description.blank? %>
23
- <p>
24
- <strong>Description/Other Details</strong><br />
28
+ <p class="zoom">
29
+ <strong>Description/Other Details</strong><br>
25
30
  <%= textilize_without_paragraph event_details.description %>
26
31
  </p>
27
32
  <% end %>
@@ -4,14 +4,58 @@
4
4
  <%= form.inputs do %>
5
5
  <%= form.input :name, :hint => "the name of the event" %>
6
6
  <%= form.input :event_type, :hint => "conference, meeting, training, etc" %>
7
- <%= form.input :start_time, :as => :time, :minute_step => 15 %>
7
+ <li id="event_start_time_input" class="time optional">
8
+ <input id="event_start_time_1i" type="hidden" value="<%= Date.current.year %>" name="event[start_time(1i)]">
9
+ <fieldset>
10
+ <legend class="label">
11
+ <label for="event_start_time_1i">Start time</label>
12
+ </legend>
13
+ <ol>
14
+ <li>
15
+ <label for="event_start_time_4i">Hour</label>
16
+ <select id="event_start_time_4i" name="event[start_time(4i)]">
17
+ <%= options_for_select(hour_options, @event.start_hour) %>
18
+ </select>
19
+ </li>
20
+ <li>
21
+ <label for="event_end_time_5i">Minute</label>
22
+ <select id="event_end_time_5i" name="event[start_time(5i)]">
23
+ <%= options_for_select(minute_options, @event.start_min) %>
24
+ </select>
25
+ </li>
26
+ </ol>
27
+ </fieldset>
28
+ </li>
8
29
  <%= form.input :start_date, :required => false, :as => :string,
9
30
  :input_html => { :value => @event.start_date.to_s } %>
10
- <%= form.input :end_time, :as => :time, :minute_step => 15 %>
31
+ <li id="event_end_time_input" class="time optional">
32
+ <input id="event_end_time_1i" type="hidden" value="<%= Date.current.year %>" name="event[end_time(1i)]">
33
+ <fieldset>
34
+ <legend class="label">
35
+ <label for="event_end_time_1i">End time</label>
36
+ </legend>
37
+ <ol>
38
+ <li>
39
+ <label for="event_end_time_4i">Hour</label>
40
+ <select id="event_end_time_4i" name="event[end_time(4i)]">
41
+ <%= options_for_select(hour_options, @event.end_hour) %>
42
+ </select>
43
+ </li>
44
+ <li>
45
+ <label for="event_end_time_5i">Minute</label>
46
+ <select id="event_end_time_5i" name="event[end_time(5i)]">
47
+ <%= options_for_select(minute_options, @event.end_min) %>
48
+ </select>
49
+ </li>
50
+ </ol>
51
+ </fieldset>
52
+ </li>
11
53
  <%= form.input :end_date, :required => false, :as => :string,
12
54
  :input_html => { :value => @event.end_date.to_s } %>
13
55
  <%= form.input :timezone, :as => :time_zone, :priority_zones => /^(Eastern|Central|Mountain|Pacific) Time/ %>
14
- <%= form.input :location, :required => false, :label => 'Location' %>
56
+ <%= form.input :facilitators, :hint => 'eg Sally Resonant, DSM WRRC' %>
57
+ <%= form.input :presenters, :hint => 'eg Jane Doe, DSM WRRC' %>
58
+ <%= form.input :location, :required => false, :hint => 'eg Portland, Oregon USA or http://some.webinar.org', :label => 'Location' %>
15
59
  <%= form.input :description, :required => false, :label => 'Description' %>
16
60
  <% unless @event.new_record? %>
17
61
  <%= form.input :notes, :required => false, :label => 'Notes' %>
@@ -6,7 +6,7 @@
6
6
  <li><span class="collapsible closed"><%= month %></span>
7
7
  <ul>
8
8
  <% months_events.each do |event| %>
9
- <li>
9
+ <li class="zoom">
10
10
  <p class="collapsible closed"><%= link_to event.name, event_path(event) %> (<%= event.start_on.strftime("%a") %> <%= event.start_day.ordinalize %>)</p>
11
11
  <%- if event.one_day? -%>
12
12
  <%= render :partial => 'events/one_day_list_event', :object => event %>
@@ -1,2 +1,2 @@
1
1
  <p><%= one_day_list_event.start_on.strftime("%A") %> <%= one_day_list_event.start_day.ordinalize %></p>
2
- <%= render :partial => 'events/times', :object => times_with_zones(one_day_list_event) %>
2
+ <p><%= event_times(one_day_list_event) %></p>
@@ -1,3 +1,3 @@
1
- <h1>Editing Event</h1>
1
+ <h1>Editing <%= link_to @event.name, event_path(@event) %> (<em><%= @event.event_type %></em>)</h1>
2
2
 
3
3
  <%= render :partial => "form" if has_authorization?(:update, @event) %>
@@ -0,0 +1,18 @@
1
+ <%-
2
+ if @link.new_record?
3
+ submission_path = event_links_path(@event)
4
+ method = 'post'
5
+ else
6
+ submission_path = event_link_path(@event, @link)
7
+ method = 'put'
8
+ end
9
+ -%>
10
+ <%= semantic_form_for(@link, :html => {:class => 'dynamic', :id => 'link_dynamic_form'}, :url => submission_path, :method => 'put') do |form| %>
11
+ <%= form.inputs do %>
12
+ <input type="hidden" name="_method" value="<%= method %>">
13
+ <%= form.input :name, :hint => "Your External Resource" %>
14
+ <%= form.input :url, :label => 'URL', :hint => "some.domain.tld or http://some.dom..." %>
15
+ <%= form.input :description, :hint => 'Statistics, Analysis and News regarding the sudden and unexpected rise in the population of water molecules.' %>
16
+ <%= form.submit %> <input type="reset" class="cancel" value="Cancel">
17
+ <% end %>
18
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <%= content_tag_for :p, link, :class => 'zoom' do %>
2
+ <%= link_to link.name, link.url, :class => 'link_name' %> <em class="link_url"><%= link.url %></em>
3
+ <%= link_to_edit_link(@event, link, {}, {:class => 'edit fake_button magic'}) %>
4
+ <%= link_to_delete_link(@event, link, {}, {:class => 'fake_button magic'}) %><br>
5
+ <span class="link_description"><%= link.description %></span>
6
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <p><strong>Materials/Resources</strong></p>
2
+ <div id="links" class="links">
3
+ <%= render @event.links.all %>
4
+ <p class="new"><%= link_to 'New Link', new_event_link_path(@event) %></p>
5
+ <%= render :partial => 'links/form' %>
6
+ </div>
@@ -0,0 +1,14 @@
1
+ if @link.valid?
2
+ page << %Q{
3
+ $('div.links > p.new').before('#{escape_javascript(render(@link))}');
4
+ $('#link_dynamic_form').remove();
5
+ $('#link_#{@link.id}').find('.magic').hide();
6
+ }
7
+ else
8
+ page << %Q{
9
+ $('#link_dynamic_form').replaceWith('#{escape_javascript(render({
10
+ :partial => 'links/form'
11
+ }))}');
12
+ $('#link_dynamic_form').attach(Remote.Form);
13
+ }
14
+ end
@@ -0,0 +1,3 @@
1
+ <h1>Editing <%= link_to @event.name, event_path(@event) %> Link <%= link_to @link.name, @link.url %></h1>
2
+
3
+ <%= render :partial => "form" if has_authorization?(:update, @link) %>
@@ -0,0 +1,3 @@
1
+ <h1>Adding Link to <%= link_to @event.name, event_path(@event) %></h1>
2
+
3
+ <%= render :partial => "form" if has_authorization?(:update, @link) %>
@@ -0,0 +1,3 @@
1
+ <h1><%= link_to @event.name, event_path(@event) %> Link</h1>
2
+
3
+ <%= render @link %>
@@ -0,0 +1,15 @@
1
+ if @link.valid?
2
+ page << %Q{
3
+ // $('#link_dynamic_form').insertAfter('div.links > p.new');
4
+ $('#link_dynamic_form').remove();
5
+ $('#link_#{@link.id}').replaceWith('#{escape_javascript(render(@link))}');
6
+ $('#link_#{@link.id}').find('.magic').hide();
7
+ }
8
+ else
9
+ page << %Q{
10
+ $('#link_dynamic_form').replaceWith('#{escape_javascript(render({
11
+ :partial => 'links/form'
12
+ }))}');
13
+ $('#link_dynamic_form').attach(Remote.Form);
14
+ }
15
+ end
data/config/routes.rb CHANGED
@@ -2,66 +2,11 @@ Rails.application.routes.draw do
2
2
  root :to => "events#index"
3
3
  resources :events do
4
4
  resources :attendees
5
+ resources :links
5
6
  end
6
7
  resources :event_revisions do
7
8
  member do
8
9
  post :restore
9
10
  end
10
11
  end
11
- # The priority is based upon order of creation:
12
- # first created -> highest priority.
13
-
14
- # Sample of regular route:
15
- # match 'products/:id' => 'catalog#view'
16
- # Keep in mind you can assign values other than :controller and :action
17
-
18
- # Sample of named route:
19
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
20
- # This route can be invoked with purchase_url(:id => product.id)
21
-
22
- # Sample resource route (maps HTTP verbs to controller actions automatically):
23
- # resources :products
24
-
25
- # Sample resource route with options:
26
- # resources :products do
27
- # member do
28
- # get 'short'
29
- # post 'toggle'
30
- # end
31
- #
32
- # collection do
33
- # get 'sold'
34
- # end
35
- # end
36
-
37
- # Sample resource route with sub-resources:
38
- # resources :products do
39
- # resources :comments, :sales
40
- # resource :seller
41
- # end
42
-
43
- # Sample resource route with more complex sub-resources
44
- # resources :products do
45
- # resources :comments
46
- # resources :sales do
47
- # get 'recent', :on => :collection
48
- # end
49
- # end
50
-
51
- # Sample resource route within a namespace:
52
- # namespace :admin do
53
- # # Directs /admin/products/* to Admin::ProductsController
54
- # # (app/controllers/admin/products_controller.rb)
55
- # resources :products
56
- # end
57
-
58
- # You can have the root of your site routed with "root"
59
- # just remember to delete public/index.html.
60
- # root :to => "welcome#index"
61
-
62
- # See how all your routes lay out with "rake routes"
63
-
64
- # This is a legacy wild controller route that's not recommended for RESTful applications.
65
- # Note: This route will make all actions in every controller accessible via GET requests.
66
- # match ':controller(/:action(/:id(.:format)))'
67
12
  end
@@ -0,0 +1,11 @@
1
+ class AddPresentersFacilitatorsToEvents < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :event_calendar_events, :presenters, :text
4
+ add_column :event_calendar_events, :facilitators, :text
5
+ end
6
+
7
+ def self.down
8
+ remove_column :event_calendar_events, :facilitators
9
+ remove_column :event_calendar_events, :presenters
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ class CreateEventCalendarLinks < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :event_calendar_links do |t|
4
+ t.string :name
5
+ t.string :url
6
+ t.text :description
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ create_table :event_calendar_events_links, :id => false do |t|
12
+ t.integer :event_id
13
+ t.integer :link_id
14
+ end
15
+
16
+ add_index :event_calendar_events_links, [:event_id, :link_id]
17
+ end
18
+
19
+ def self.down
20
+ drop_table :event_calendar_links
21
+ drop_table :event_calendar_events_links
22
+ end
23
+ end