Re-enable a "show" page for Calendar Events. Fixes #CNVS-1229
Testing Notes: =========== * Create a user-created event in the calendar. When the event is clicked, the title in the popup now actually goes to a show page. * Create an event in the context of a course (select the course in the right-side of the calendar, disable others). * Masquerade as a student in the course. Visit the Calendar. * Select the event, verify that the "title" is a link and works. * Should show the calendar event in the context of the course (sidebar) * Click an event title and view the show page. If the user has permissions to edit the event, an edit and delete link should show on the right. * Editing the event should work and correctly update the event. * Deleting an event on the "show" page should work without error. * Creating and editing an event on the dedicated page should redirect back to the calendar. NOTE: When viewing your own event, there is no sidebar on either side since it is viewed in the context of a user and not a course. Change-Id: Ic8ed6f84bd75c30c8e35297399b281ac62205ba9 Reviewed-on: https://gerrit.instructure.com/16370 Reviewed-by: Jon Willesen <jonw@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: Marc LeGendre <marc@instructure.com>
This commit is contained in:
parent
01f102fab1
commit
35b601d70a
|
@ -150,7 +150,7 @@ define [
|
|||
else if @event.object?.available_slots > 0
|
||||
params.availableSlotsText = @event.object.available_slots
|
||||
|
||||
params.showEventLink = params.can_edit and params.fullDetailsURL()
|
||||
params.showEventLink = params.fullDetailsURL()
|
||||
params.showEventLink or= params.isAppointmentGroupEvent()
|
||||
@popover = new Popover(jsEvent, eventDetailsTemplate(params))
|
||||
|
||||
|
|
|
@ -31,12 +31,13 @@ class CalendarEventsController < ApplicationController
|
|||
return
|
||||
end
|
||||
if authorized_action(@event, @current_user, :read)
|
||||
if @domain_root_account.enable_scheduler? # no read-only view for calendar2
|
||||
return redirect_to calendar_url_for(@event.effective_context, :event => @event) unless @event.grants_right?(@current_user, session, :update)
|
||||
# If param specifies to open event on calendar, redirect to view
|
||||
if params[:calendar] == '1'
|
||||
return redirect_to calendar_url_for(@event.effective_context, :event => @event)
|
||||
end
|
||||
log_asset_access(@event, "calendar", "calendar")
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new' }
|
||||
format.html
|
||||
format.json { render :json => @event.to_json(:permissions => {:user => @current_user, :session => session}) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
#
|
||||
# Copyright (C) 2011 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
module CalendarEventsHelper
|
||||
|
||||
# Return the user to a "return_to" path or to the calendar with specific dates used.
|
||||
#
|
||||
# ==== Options
|
||||
# * <tt>:context</tt> - The context to use (i.e. course) for focusing/limiting the
|
||||
# events for display.
|
||||
# * <tt>:event</tt> - A CalendarEvent instance from which the event's dates should
|
||||
# be used to specify which month/year to display.
|
||||
#
|
||||
def return_to_calendar(options = {})
|
||||
cal_options = {}
|
||||
event = options.delete(:event)
|
||||
if event
|
||||
cal_options[:anchor] = {:month => (event.try_rescue(:start_at).try_rescue(:month)),
|
||||
:year => (event.try_rescue(:start_at).try_rescue(:year))}.to_json
|
||||
end
|
||||
# Use a explicit "return_to" option first, absent that, use calendar_url_for
|
||||
clean_return_to(
|
||||
params[:return_to] && params[:return_to].match(/calendar/) && params[:return_to]) ||
|
||||
calendar_url_for(options[:context], cal_options)
|
||||
end
|
||||
|
||||
end
|
|
@ -66,15 +66,11 @@
|
|||
<div><%= f.text_area :description, :style => 'width: 100%;' %></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn cancel_button"><%= t '#buttons.cancel', "Cancel" %></button>
|
||||
<button type="submit" class="btn btn-primary submit_button"><%= calendar_event.new_record? ? t('buttons.create', "Create Event") : t('buttons.update', "Update Event") %></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn cancel_button"><%= t '#buttons.cancel', "Cancel" %></button>
|
||||
<button type="submit" class="btn btn-primary submit_button"><%= calendar_event.new_record? ? t('buttons.create', "Create Event") : t('buttons.update', "Update Event") %></button>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<%
|
||||
content_for :page_title, @event.title || t(:page_title, "New Calendar Event")
|
||||
return_to_url = clean_return_to(params[:return_to] && params[:return_to].match(/calendar/) && params[:return_to]) || calendar_url_for(@context, :anchor => {:month => (@event.try_rescue(:start_at).try_rescue(:month)), :year => (@event.try_rescue(:start_at).try_rescue(:year))}.to_json)
|
||||
return_to_url = return_to_calendar(:context => @context, :event => @event)
|
||||
|
||||
if @domain_root_account.enable_scheduler?
|
||||
event_attrs = {
|
||||
|
|
|
@ -1 +1,18 @@
|
|||
<%= render :partial => 'full_calendar_event' %>
|
||||
<% content_for :right_side do %>
|
||||
<% return_to_url = return_to_calendar(:event => @event) %>
|
||||
<a class="base_calendar_url" href="<%= calendar_url_for() %>" style="display: none;"> </a>
|
||||
<div id="sidebar_content" class="rs-margin-all">
|
||||
<ul class="page-action-list">
|
||||
<li><a class="return_url calendar_url" href="<%= return_to_url %>"><i class="icon-arrow-left" aria-hidden='true'></i> <%= t 'links.back_to_calendar', "Back to Calendar" %></a></li>
|
||||
<% if can_do(@event, @current_user, :update) %>
|
||||
<li><a href="#" class="edit_calendar_event_link"><i class="icon-edit" aria-hidden='true'></i> <%= t 'links.edit', "Edit Calendar Event"%></a></li>
|
||||
<% unless @event.new_record? %>
|
||||
<li><a href="<%= context_url(@context, :context_calendar_event_url, @event.id) %>" class="delete_event_link"><i class="icon-trash" aria-hidden='true'></i> <%= t 'links.delete', "Delete the Event" %></a></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render :partial => 'shared/wiki_sidebar' %>
|
||||
<% end %>
|
||||
|
||||
<%= render :partial => 'full_calendar_event', :object => @event %>
|
|
@ -168,9 +168,7 @@ $(function($) {
|
|||
}
|
||||
$(".calendar_url").attr('href', base_url + "#" + $.encodeToHex(JSON.stringify(json)));
|
||||
|
||||
if ($full_calendar_event_holder.hasClass('editing')) {
|
||||
window.location.href = $(".calendar_url").attr('href');
|
||||
}
|
||||
window.location.href = $(".calendar_url").attr('href');
|
||||
},
|
||||
error: function(data) {
|
||||
$full_calendar_event_holder.loadingImage('remove');
|
||||
|
|
|
@ -40,26 +40,16 @@ describe CalendarEventsController do
|
|||
assigns[:event].should eql(@event)
|
||||
end
|
||||
|
||||
it "should redirect if calendar2 is enabled and the user can't edit" do
|
||||
it "should render show page" do
|
||||
Account.default.update_attribute(:settings, {:enable_scheduler => true})
|
||||
course_with_student_logged_in(:active_all => true)
|
||||
course_event
|
||||
get 'show', :course_id => @course.id, :id => @event.id
|
||||
response.should be_redirect
|
||||
response.redirected_to.should include "include_contexts=#{@course.asset_string}"
|
||||
assigns[:event].should_not be_nil
|
||||
# make sure that the show.html.erb template is rendered
|
||||
response.rendered[:template].should eql 'calendar_events/show.html.erb'
|
||||
end
|
||||
|
||||
it "should redirect to the effective calendar if calendar2 is enabled and the user can't edit" do
|
||||
Account.default.update_attribute(:settings, {:enable_scheduler => true})
|
||||
course_with_student_logged_in(:active_all => true)
|
||||
parent_event = @course.calendar_events.build(:title => "something", :child_event_data => {"0" => {:start_at => Time.now, :end_at => 1.hour.from_now, :context_code => @course.default_section.asset_string}})
|
||||
parent_event.updating_user = @teacher
|
||||
parent_event.save!
|
||||
event = parent_event.child_events.first
|
||||
get 'show', :course_section_id => @course.default_section.id, :id => event.id
|
||||
response.should be_redirect
|
||||
response.redirected_to.should include "include_contexts=#{@course.asset_string}" # goes to course calendar
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET 'new'" do
|
||||
|
|
|
@ -535,14 +535,29 @@ describe "calendar2" do
|
|||
details.text.should include(@course.default_section.name)
|
||||
end
|
||||
|
||||
it "should redirect to the calendar and show the selected event" do
|
||||
event = make_event(:context => @course, :start => 2.months.from_now, :title => "future event")
|
||||
get "/courses/#{@course.id}/calendar_events/#{event.id}"
|
||||
it "should display title link and go to event details page" do
|
||||
make_event(:context => @course, :start => 0.days.from_now, :title => "future event")
|
||||
get "/calendar2"
|
||||
wait_for_ajaximations
|
||||
|
||||
popup_title = f('.details_title')
|
||||
popup_title.should be_displayed
|
||||
popup_title.text.should == "future event"
|
||||
# click the event in the calendar
|
||||
f('.fc-event-title').click
|
||||
popover = f('#popover-0')
|
||||
popover.should be_displayed
|
||||
expect_new_page_load { popover.find_element(:css, '.view_event_link').click }
|
||||
wait_for_ajaximations
|
||||
|
||||
page_title = f('.title')
|
||||
page_title.should be_displayed
|
||||
page_title.text.should == 'future event'
|
||||
end
|
||||
|
||||
it "should not redirect but load the event details page" do
|
||||
event = make_event(:context => @course, :start => 2.months.from_now, :title => "future event")
|
||||
get "/courses/#{@course.id}/calendar_events/#{event.id}"
|
||||
page_title = f('.title')
|
||||
page_title.should be_displayed
|
||||
page_title.text.should == 'future event'
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -563,7 +578,7 @@ describe "calendar2" do
|
|||
# Use event to open to a specific and testable month
|
||||
event = calendar_event_model(:title => 'Test Event', :start_at => date, :end_at => (date + 1.hour))
|
||||
|
||||
get "/courses/#{@course.id}/calendar_events/#{event.id}"
|
||||
get "/courses/#{@course.id}/calendar_events/#{event.id}?calendar=1"
|
||||
wait_for_ajaximations
|
||||
fj('#calendar-app h2').text.should == 'Julio 2012'
|
||||
fj('#calendar-app .fc-sun').text.should == 'Domingo'
|
||||
|
|
|
@ -140,28 +140,6 @@ describe "calendar" do
|
|||
f("##{date_holder_id} #event_assignment_#{second_assignment.id}").should_not be_displayed
|
||||
end
|
||||
|
||||
it "should allow editing event details repeatedly" do
|
||||
calendar_event_model(:title => "ev", :start_at => "2012-04-02")
|
||||
@event.all_day.should be_true
|
||||
|
||||
get "/courses/#{@course.id}/calendar_events/#{@event.id}"
|
||||
f(".edit_calendar_event_link").click
|
||||
replace_content(f("#calendar_event_title"), "edit1")
|
||||
submit_form("#edit_calendar_event_form")
|
||||
wait_for_ajax_requests
|
||||
|
||||
keep_trying_until { fj(".edit_calendar_event_link").should be_displayed } #using fj to bypass selenium cache
|
||||
fj(".edit_calendar_event_link").click
|
||||
replace_content(f("input[name=start_date]"), "2012-04-05")
|
||||
replace_content(f("#calendar_event_title"), "edit2")
|
||||
submit_form("#edit_calendar_event_form")
|
||||
wait_for_ajax_requests
|
||||
|
||||
@event.reload
|
||||
@event.title.should == "edit2"
|
||||
@event.all_day.should be_true
|
||||
@event.start_at.should == Time.zone.parse("2012-04-05")
|
||||
end
|
||||
end
|
||||
|
||||
context "student view" do
|
||||
|
|
Loading…
Reference in New Issue