Permalink
Browse files

fixed views for event_calendar namespacing

  • Loading branch information...
jlapier committed Nov 23, 2011
1 parent 9c1dd96 commit 65f0a5715a6fed4cf899c75c7fc8d6c351cb4cb7
@@ -30,7 +30,6 @@ class ApplicationController < ActionController::Base
# returns false for anonymous requests to non public resources
# returns result from can? for authenticated requests to non public resources
def has_authorization?(*args)
- puts "in has auth"
return true if public_resource?(*args)
return false unless current_user
@@ -2,7 +2,7 @@ module EventCalendar
class EventsController < ApplicationController
# before_filter :load_and_authorize_current_user, :except => [:index, :show]
- before_filter :parse_dates_from_params, :only => [:create, :update]
+ before_filter :merge_params, :parse_dates_from_params, :only => [:create, :update]
cache_sweeper :event_sweeper
include EventsHelper
@@ -26,6 +26,10 @@ def events_to_json
end
json.to_json
end
+
+ def merge_params
+ params[:event].merge!(params[:event_calendar_event]) if params[:event_calendar_event]
+ end
def parse_dates_from_params
params[:event].delete :"start_time(1i)"
@@ -8,7 +8,7 @@ def link
@link ||= if params[:id].present?
EventCalendar::Link.find(params[:id])
else
- event.links.build(params[:link])
+ event.links.build(params[:link] || params[:event_calendar_link])
end
end
def load_resources
@@ -150,7 +150,7 @@ def link_to_events(wrapper_options={}, link_options={})
end
def link_to_event_revisions(wrapper_options={}, link_options={})
- return unless has_authorization?(:read, EventRevision.new)
+ return unless has_authorization?(:read, EventCalendar::EventRevision.new)
link_wrapper(event_calendar_event_revisions_path, {
:no_wrapper => true
}.merge!(wrapper_options), {
@@ -243,27 +243,23 @@ def links_to_edit_and_delete_event(event, wrapper_options={}, link_options={})
def form_for_browse_event_revisions(event)
return unless has_authorization?(:update, event)
- render :partial => 'events/browse_event_revisions', :locals => {
+ render :partial => '/event_calendar/events/browse_event_revisions', :locals => {
:event => event
}
end
def render_event_navigation(event=nil)
- render :partial => 'event-calendar-shared/navigation', :locals => {
+ render :partial => '/event_calendar/event-calendar-shared/navigation', :locals => {
:event => event
}
end
def render_event_main_menu
- render :partial => 'event-calendar-shared/main_menu'
+ render :partial => '/event_calendar/event-calendar-shared/main_menu'
end
def render_flash
- render :partial => 'event-calendar-shared/flash', :object => flash
- end
-
- def event_calendar_asset_prefix
- 'event_calendar/'
+ render :partial => '/event_calendar/event-calendar-shared/flash', :object => flash
end
def event_calendar_javascript_includes
@@ -272,10 +268,5 @@ def event_calendar_javascript_includes
"event_calendar_behaviors.js",
"event_calendar.js"
]
- unless Rails.env == 'production'
- list.unshift("#{event_calendar_asset_prefix}jquery")
- else
- list.unshift("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js")
- end
end
end
@@ -1,3 +1,5 @@
+# TODO: it would be better to load events via javascript than cache them in a page
+# otherwise you have to expire cache every day anyway
class EventSweeper < ActionController::Caching::Sweeper
observe EventCalendar::Event
@@ -14,10 +16,10 @@ def after_destroy(event)
end
def expire_content_page_caches
- expire_fragment :controller => 'content_pages', :action => 'home'
+ expire_fragment :controller => '/content_pages', :action => 'home'
ContentPage.find(:all).each do |content_page|
- expire_fragment :controller => 'content_pages', :action => 'show', :id => content_page
- expire_fragment :controller => 'content_pages', :action => 'show', :id => content_page.id.to_i
+ expire_fragment :controller => '/content_pages', :action => 'show', :id => content_page
+ expire_fragment :controller => '/content_pages', :action => 'show', :id => content_page.id.to_i
end
end
end
@@ -10,6 +10,6 @@
<div style="clear:both"></div>
-<%= render :partial => 'events/list' %>
+<%= render :partial => '/event_calendar/events/list' %>
<div style="clear:both"></div>
@@ -1,5 +1,5 @@
<%= tag_for_record :tr, event_revision, :style => 'background-color: #f5c6d7' do %>
- <td><%= link_to event_revision.name, event_revision_path(event_revision) %></td>
+ <td><%= link_to event_revision.name, event_calendar_event_revision_path(event_revision) %></td>
<td><%= truncate(event_revision.location, :length => 100) %></td>
<td><%= truncate(event_revision.description, :length => 100) %></td>
<td></td>
@@ -8,7 +8,7 @@
<% months_events.each do |event| %>
<li>
<%= event_one_liner(event) %>
- <%= link_to 'restore', restore_event_revision_path(event),
+ <%= link_to 'restore', restore_event_calendar_event_revision_path(event),
:confirm => 'Are you sure you want to restore this deleted event?',
:method => "post",
:class => 'fake_button' %>
@@ -1,2 +1,2 @@
<h2>Deleted Events (<em><%= @deleted_events.count %></em>)</h2>
-<%= render :partial => 'event_revisions/list_group', :locals => {:events => @deleted_events} %>
+<%= render :partial => '/event_calendar/event_revisions/list_group', :locals => {:events => @deleted_events} %>
@@ -8,4 +8,4 @@
<p style="float: right;" class="fake_button">Revision <%= @event_revision.revision_number %></p>
-<%= render :partial => 'events/event', :object => @event_revision %>
+<%= render :partial => '/event_calendar/events/event', :object => @event_revision %>
@@ -3,7 +3,7 @@
<% if event.revisions.empty? %>
<p><em>This is the first version of this event.</em></p>
<% else %>
- <%= form_tag event_revisions_path, :method => :get do %>
+ <%= form_tag event_calendar_event_revisions_path, :method => :get do %>
<select name="id">
<% event.revisions.each do |evr| %>
<option value="<%= evr.id %>">
@@ -16,4 +16,4 @@
<% end %>
<% end %>
-<p>current version modified on <%= event.updated_at %></p>
+<p>current version modified on <%= event.updated_at %></p>
@@ -1,15 +1,11 @@
-this is the right partial
<% unless event.nil? %>
<%= div_for_record(event) do -%>
-<p>hello!</p>
<p style="float: right;">
<%= links_to_edit_and_delete_event(event, {}, {:class => 'fake_button'}) if event.current_revision? %>
</p>
<h1><%= link_to_events({:no_wrapper => true}, {:link_text => "Events"}) %>: <%= event.name %> (<em><%= event.event_type %></em>)</h1>
<div style="clear:both"></div>
- okay now event details partial
- <%= render :partial => 'event_details', :object => event %>
- do I ever get here?
+ <%= render :partial => 'event_calendar/events/event_details', :object => event %>
<%- if event.current_revision? && (event.links.count > 0 || event.file_attachments.count > 0) -%>
<p><strong>Materials/Resources</strong></p>
<%- end -%>
@@ -71,12 +71,12 @@
<% content_for :javascript do %>
<script type="text/javascript">
$(document).ready(function() {
- $('#event_event_type').attach(SelectPopper, <%= "#{EventCalendar::Event.existing_event_types.to_json}".html_safe %>);
+ $('#event_calendar_event_event_type').attach(SelectPopper, <%= "#{EventCalendar::Event.existing_event_types.to_json}".html_safe %>);
$('form.formtastic fieldset ol li.text textarea').attach(TextareaExpander, 40, 300);
- $('#event_start_date').datepicker();
- $('#event_end_date').datepicker();
+ $('#event_calendar_event_start_date').datepicker();
+ $('#event_calendar_event_end_date').datepicker();
});
</script>
@@ -1,6 +1,6 @@
<div class="span-18 last">
<h2>Current Events (<em><%= @current_events.count %></em>)</h2>
- <%= render :partial => 'list_group', :locals => {:events => @current_events} %>
+ <%= render :partial => '/event_calendar/events/list_group', :locals => {:events => @current_events} %>
<h2>Past Events (<em><%= @past_events.count %></em>)</h2>
- <%= render :partial => 'list_group', :locals => {:events => @past_events} %>
+ <%= render :partial => '/event_calendar/events/list_group', :locals => {:events => @past_events} %>
</div>
@@ -1,5 +1,5 @@
<div id="links" class="links">
- <%= render @event.links.all %>
+ <%= render :partial => '/event_calendar/links/link', :collection => @event.links.all %>
<%= link_to_new_link(@event, {:class => 'new'}) %>
- <%= render :partial => 'event_calendar/links/form' %>
+ <%= render :partial => '/event_calendar/links/form' %>
</div>
@@ -1,14 +1,16 @@
if @link.valid?
page << %Q{
- $('div.links > p.new').before('#{escape_javascript(render(@link))}');
+ $('div.links > p.new').before('#{escape_javascript(render({
+ :partial => '/event_calendar/links/link', :locals => {:link => @link}
+ }))}');
$('#link_dynamic_form').remove();
$('#link_#{@link.id}').find('.magic').hide();
}
else
page << %Q{
$('#link_dynamic_form').replaceWith('#{escape_javascript(render({
- :partial => 'links/form'
+ :partial => '/event_calendar/links/form'
}))}');
$('#link_dynamic_form').attach(Remote.Form);
}
-end
+end
@@ -44,14 +44,14 @@ Feature: Event calendar
Scenario: update a multi day event
Given I am on the event page for "Editable Event"
- And I follow "update" within "div.event"
+ And I follow "update" within "div.event_calendar_event"
And I fill in "Name" with "Updated Event"
And I press "Update Event"
Then I should see "Event was successfully updated."
Scenario: update a single day event
Given I am on the event page for "Linkable Event"
- And I follow "update" within "div.event"
+ And I follow "update" within "div.event_calendar_event"
And I fill in "Start date" with "02/23/2011"
And I fill in "End date" with "02/23/2011"
And I select "Pacific Time (US & Canada)" from "Timezone"
@@ -61,7 +61,7 @@ Feature: Event calendar
Scenario: delete an event
Given I am on the event page for "Editable Event"
- And I follow "delete" within "div.event"
+ And I follow "delete" within "div.event_calendar_event"
Then I should be on the events page
Scenario: deleting then restoring an event
@@ -79,4 +79,4 @@ Feature: Event calendar
When I follow "restore"
Then I should be on the event page for "Restorable Event"
And I should see "Date: Friday, February 04 2011"
- And I should see "Time: 09:00 AM - 10:00 AM Eastern / 08:00 AM - 09:00 AM Central / 07:00 AM - 08:00 AM Mountain / 06:00 AM - 07:00 AM Pacific"
+ And I should see "Time: 09:00 AM - 10:00 AM Eastern / 08:00 AM - 09:00 AM Central / 07:00 AM - 08:00 AM Mountain / 06:00 AM - 07:00 AM Pacific"
View
@@ -15,7 +15,13 @@ def path_to(page_name)
'/login'
when /the event page for "(.*)"/
- event_path(Event.find_by_name($1))
+ event_calendar_event_path(EventCalendar::Event.find_by_name($1))
+
+ when /the new event page/
+ '/event_calendar/events/new'
+
+ when /the events page/
+ '/event_calendar/events'
when /the edit link page for "(.*)" "(.*)"/
event = Event.find_by_name($1)
@@ -26,6 +32,9 @@ def path_to(page_name)
when /the manage events page/
'/dashboard/event_calendar'
+
+ when /the event revisions page/
+ '/event_calendar/event_revisions'
when /the edit blog post page for "(.*)"/
p = Blog::Post.find_by_title($1)
View
@@ -53,7 +53,7 @@ def list_events_to_html(options = {})
if event.end_on and event.end_on.to_date != event.start_on.to_date
date_string += " - " + (event.start_on.month == event.end_on.month ? event.end_on.strftime('%d') : event.end_on.strftime('%B %d'))
end
- out += "<li><a href=\"/events/#{event.id}\">#{date_string}: #{event.name}</a></li>"
+ out += "<li><a href=\"/event_calendar/events/#{event.id}\">#{date_string}: #{event.name}</a></li>"
end
end
@@ -175,7 +175,7 @@ def mini_calendar_to_html(options={})
$('#minicalendar').fullCalendar({
header: { left: 'prev,next', right: 'title' },
editable: false,
- events: '/events',
+ events: '/event_calendar/events',
eventMouseover: function(event, jsEvent, view) {
$(jsEvent.target).attr('title', event.title);
}
@@ -201,7 +201,7 @@ def calendar_to_html(options={})
$('#calendar').fullCalendar({
header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' },
editable: false,
- events: '/events',
+ events: '/event_calendar/events',
height: #{options[:height]},
aspectRatio: 1,
eventMouseover: updateEventDescription
@@ -93,7 +93,6 @@ def mock_content_page(stubs={}, new_mock = false)
ContentPage.stub!(:new).and_return(mock_content_page)
mock_content_page.stub(:save).and_return(false)
post :create, :content_page => {}
- puts flash
response.should render_template('new')
end
end
@@ -189,7 +189,7 @@ class DummyClass
$('#calendar').fullCalendar({
header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' },
editable: false,
- events: '/events',
+ events: '/event_calendar/events',
height: 500,
aspectRatio: 1,
eventMouseover: updateEventDescription

0 comments on commit 65f0a57

Please sign in to comment.