@@ -29,69 +24,4 @@
<%= calendar_event && calendar_event.description && !calendar_event.description.empty? ? user_content(calendar_event.description) : t(:no_content, "No Content") %>
<%= @context.id if @context && @context.is_a?(Course) %>
- <% if can_do(calendar_event, @current_user, :update_content) %>
- <% url = calendar_event.new_record? ? context_url(@context, :context_calendar_events_url) : context_url(@context, :context_calendar_event_url, calendar_event.id) %>
- <%= form_for calendar_event, :url => url, :html => {:method => (calendar_event.new_record? ? 'POST' : 'PUT'), :style => 'display: none;', :id => 'edit_calendar_event_form', :class => (calendar_event.new_record? ? 'new_event' : '')} do |f| %>
-
-
-
- <%= t '#buttons.cancel', "Cancel" %>
- <%= calendar_event.new_record? ? t('buttons.create', "Create Event") : t('buttons.update', "Update Event") %>
-
- <% end %>
- <% end %>
diff --git a/app/views/calendar_events/new.html.erb b/app/views/calendar_events/new.html.erb
index 01f649792aa..cc492e137f2 100644
--- a/app/views/calendar_events/new.html.erb
+++ b/app/views/calendar_events/new.html.erb
@@ -2,37 +2,17 @@
content_for :page_title, @event.title || t(:page_title, "New Calendar Event")
return_to_url = return_to_calendar(:context => @context, :event => @event)
- if @domain_root_account.enable_scheduler?
- event_attrs = {
- :id => @event.id,
- :context_code => @context.asset_string,
- :return_to_url => return_to_url
- }
- if @context.is_a? Course
- event_attrs[:sections_url] = context_url(@context, :api_v1_context_sections_url)
- end
- js_env :CALENDAR_EVENT => event_attrs
+ event_attrs = {
+ :id => @event.id,
+ :context_code => @context.asset_string,
+ :return_to_url => return_to_url
+ }
+ if @context.is_a? Course
+ event_attrs[:sections_url] = context_url(@context, :api_v1_context_sections_url)
+ end
+ js_env :CALENDAR_EVENT => event_attrs
- js_bundle :edit_calendar_event
- jammit_css :tinymce, :edit_calendar_event_full
- content_for :right_side, render(:partial => 'shared/wiki_sidebar')
- else
- content_for :right_side do
+ js_bundle :edit_calendar_event
+ jammit_css :tinymce, :edit_calendar_event_full
+ content_for :right_side, render(:partial => 'shared/wiki_sidebar')
%>
-
- <%= render :partial => 'shared/wiki_sidebar' %>
-<% end %>
-
-<%= render :partial => 'full_calendar_event', :object => @event %>
-<% end %>
\ No newline at end of file
diff --git a/app/views/calendars/_calendar.html.erb b/app/views/calendars/_calendar.html.erb
deleted file mode 100644
index 39120ed6dc3..00000000000
--- a/app/views/calendars/_calendar.html.erb
+++ /dev/null
@@ -1,245 +0,0 @@
-<%
- js_env :CALENDAR => { :ACTIVE_EVENT => @active_event_id }
- js_bundle :calendar
- jammit_css :calendar
- @body_classes << "full-width"
-%>
-<% content_for :stylesheets do %>
-
-<% end %>
-<% content_for :right_side do %>
-
-
-
-
-
- <%= render :partial => 'calendars/mini_calendar', :locals => {:current => current, :first_day => first_day } %>
-
-
- <%= t :calendars_count, { :one => "1 calendar, %{open_count} open", :other => "%{count} calendars, %{open_count} open" },
- :count => @contexts.length, :open_count => ' '.html_safe %>
-
-
- <% @contexts.each_with_index do |c, idx| %>
-
- <% end %>
-
-
-
<%= CalendarEvent.max_visible_calendars %>
- <% if @contexts.length > 10 %><%= t 'messages.max_visible', "You can show up to %{count} calendars at a time", :count => CalendarEvent.max_visible_calendars %><% end %>
-
-
-
-
-
<%= before_label :undated_events, "Undated Events" %>
-
-
- <%= render :partial => 'event', :collection => @undated_events %>
-
-
-
-
-
-
-
-<% end %>
-
- <% @contexts.each do |context| %>
- <% cache([context, 'assignment_groups_for_cal']) do %>
-
-
" class="<%= context.class.to_s.downcase %>_<%= context.id %>_event_url">
- <% if context.respond_to?("assignments") %>
-
-
" class="<%= context.class.to_s.downcase %>_<%= context.id %>_assignment_url">
- <%= select :assignment, :assignment_group_id, (context.assignment_groups.active.select("id, name").map {|g| [g.name, g.id]} << [t('options.new_group', "[ New Group ]"), "new"]), {}, {:class => "assignment_group_id #{context.try_rescue(:weight_assignment_groups) ? 'weight' : ''}", :id => "#{ context.class.to_s.downcase }_#{ context.id }_assignment_groups"} %>
-
- <% end %>
- <% end %>
- <% end %>
-
-
-<%= render :partial => 'event', :object => nil %>
-
-
-
-
-
- <%= form_for(:calendar_event, :url => context_url(@context, :context_calendar_events_url), :html => {:id => 'edit_calendar_event_form', :style => 'padding: 5px;'}) do |f| %>
-
- <% end %>
- <%= form_for(:assignment, :url => ".", :html => {:id => 'edit_assignment_form', :style => 'padding: 5px;'}) do |f| %>
-
- <% end %>
-
-
-
-
-<%= render :partial => "shared/add_assignment_group" %>
-
-
- <%= image_tag "ical_big.png", :style => "float: left; margin: 0px 3px;" %>
- <%= t 'instructions.ics_link', "Copy the link below and paste it into any calendar app that takes
- iCal feeds (Google Calendar, iCal, Outlook, etc.)" %>
-
-
-
diff --git a/app/views/calendars/show.html.erb b/app/views/calendars/show.html.erb
deleted file mode 100644
index 6e42e09b593..00000000000
--- a/app/views/calendars/show.html.erb
+++ /dev/null
@@ -1,76 +0,0 @@
-<% content_for :page_title do %><%= join_title t(:page_title, "Calendar"), @context.name %><% end %>
-<% add_crumb t('crumbs.my_calendar', "My Calendar"), calendar_url %>
-
-<% content_for :auto_discovery do %>
- <% if @context_enrollment %>
- <%= auto_discovery_link_tag(:atom, feeds_calendar_format_url(@context_enrollment.feed_code, :atom), {:title => t(:feed_title, "Course Calendar Atom Feed")}) %>
- <% elsif @context.available? %>
- <%= auto_discovery_link_tag(:atom, feeds_calendar_format_url(@context.feed_code, :atom), {:title => t(:feed_title, "Course Calendar Atom Feed")}) %>
- <% end %>
-<% end %>
-
-<%= render :partial => "calendar", :object => @events, :locals => { :first_day => @first_day, :last_day => @last_day, :current => @current } %>
-
-<% content_for :wizard_box do %>
- <%= render :partial => "calendars/wizard_box" %>
-<% end %>
-
-<% content_for :keyboard_navigation do %>
-
-
- <%= t 'keycodes.next_event', 'j' %>
- :
- <%= t 'keycode_descriptions.next_event', "Next Calendar Day/Event" %>
-
-
- <%= t 'keycodes.previous_event', 'k' %>
- :
- <%= t 'keycode_descriptions.previous_event', "Previous Calendar Day/Event" %>
-
-
- <%= t 'keycodes.open', 'o' %>
- :
- <%= t 'keycode_descriptions.open', "Open Current Event" %>
-
-
- <%= t 'keycodes.edit', 'e' %>
- :
- <%= t 'keycode_descriptions.edit', "Edit Current Event" %>
-
-
- <%= t 'keycodes.delete', 'd' %>
- :
- <%= t 'keycode_descriptions.delete', "Delete Current Event" %>
-
-
- <%= t 'keycodes.new', 'n' %>
- :
- <%= t 'keycode_descriptoins.new', "New Event for Current Day" %>
-
-
- <%= t 'keycodes.refresh', 'r' %>
- :
- <%= t 'keycode_descriptions.refresh', "Refresh Calendar" %>
-
-
- <%= t 'keycodes.next_day', 'ctrl+right' %>
- :
- <%= t 'keycode_descriptions.next_day', "Next Calendar Day" %>
-
-
- <%= t 'keycodes.previous_day', 'ctrl+left' %>
- :
- <%= t 'keycode_descriptions.previous_day', "Previous Calendar Day" %>
-
-
- <%= t 'keycodes.next_week', 'ctrl+down' %>
- :
- <%= t 'keycode_descriptions.next_week', "Next Week" %>
-
-
- <%= t 'keycodes.previous_week', 'ctrl+up' %>
- :
- <%= t 'keycode_descriptions.previous_week', "Previous Week" %>
-
-
-<% end %>
diff --git a/app/views/calendars/show2.html.erb b/app/views/calendars/show2.html.erb
index cac0e6e3196..53e30c21cb3 100644
--- a/app/views/calendars/show2.html.erb
+++ b/app/views/calendars/show2.html.erb
@@ -6,7 +6,7 @@
:SELECTED_CONTEXTS => @selected_contexts,
:ACTIVE_EVENT => @active_event_id,
:VIEW_START => @view_start,
- :CAL2_ONLY => @domain_root_account.calendar2_only?,
+ :CAL2_ONLY => true,
:SHOW_SCHEDULER => @domain_root_account.show_scheduler?
}
js_bundle :calendar2
diff --git a/config/routes.rb b/config/routes.rb
index a92a4854c50..23cfb75856f 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -209,7 +209,7 @@ CanvasRails::Application.routes.draw do
get 'grading_rubrics' => 'gradebooks#grading_rubrics'
get 'grades/:id' => 'gradebooks#grade_summary', as: :student_grades
concerns :announcements
- get 'calendar' => 'calendars#show', as: :old_calendar
+ get 'calendar' => 'calendars#show2', as: :old_calendar
get :locks
concerns :discussions
resources :assignments do
@@ -460,7 +460,7 @@ CanvasRails::Application.routes.draw do
concerns :media
resources :collaborations
- get 'calendar' => 'calendars#show', as: :old_calendar
+ get 'calendar' => 'calendars#show2', as: :old_calendar
end
resources :accounts do
@@ -683,10 +683,9 @@ CanvasRails::Application.routes.draw do
resources :plugins, only: [:index, :show, :update]
- get 'calendar' => 'calendars#show'
+ get 'calendar' => 'calendars#show2'
get 'calendar2' => 'calendars#show2'
get 'course_sections/:course_section_id/calendar_events/:id' => 'calendar_events#show', as: :course_section_calendar_event
- post 'switch_calendar/:preferred_calendar' => 'calendars#switch_calendar', as: :switch_calendar
get 'files' => 'files#index'
get "files/folder#{full_path_glob}", controller: 'files', action: 'react_files', format: false
get "files/search", controller: 'files', action: 'react_files', format: false
diff --git a/public/javascripts/calendar_event.js b/public/javascripts/calendar_event.js
deleted file mode 100644
index 791e0c500e3..00000000000
--- a/public/javascripts/calendar_event.js
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * 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
.
- */
-
-define([
- 'timezone',
- 'i18n!calendar_events',
- 'jquery' /* jQuery, $ */,
- 'wikiSidebar',
- 'jquery.instructure_date_and_time' /* dateString, timeString, date_field, time_field, /\$\.datetime/ */,
- 'jquery.instructure_forms' /* formSubmit, fillFormData, formErrors */,
- 'jquery.instructure_misc_helpers' /* encodeToHex, scrollSidebar */,
- 'jquery.instructure_misc_plugins' /* confirmDelete, fragmentChange, showIf */,
- 'jquery.loadingImg' /* loadingImg, loadingImage */,
- 'jquery.templateData' /* fillTemplateData, getTemplateData */,
- 'compiled/tinymce',
- 'tinymce.editor_box' /* editorBox */,
- 'vendor/date' /* Date.parse */
-], function(tz, I18n, $, wikiSidebar) {
-
- var noContentText = I18n.t('no_content', "No Content");
-
-$(function($) {
- var $full_calendar_event = $("#full_calendar_event"),
- $edit_calendar_event_form = $("#edit_calendar_event_form"),
- $full_calendar_event_holder = $("#full_calendar_event_holder");
-
-
- function hideEditCalendarEventForm(redirect) {
- $full_calendar_event.show();
- $edit_calendar_event_form.hide()
- .find("textarea").editorBox('destroy');
- if (wikiSidebar) {
- wikiSidebar.hide();
- $("#sidebar_content").show();
- }
- if (redirect && $edit_calendar_event_form.hasClass('new_event')) {
- window.location.href = $(".calendar_url").attr('href');
- }
- };
- function editCalendarEventForm() {
- $full_calendar_event.hide();
- var data = $full_calendar_event.getTemplateData({
- textValues: ['start_at_date_string', 'start_at_time_string', 'end_at_time_string', 'title', 'all_day', 'all_day_date']
- });
- if (data.description == noContentText) {
- data.description = "";
- }
- data.start_date = data.start_at_date_string;
- data.start_time = data.start_at_time_string;
- data.end_time = data.end_at_time_string;
- if (data.all_day == 'true') {
- if (data.all_day_date) {
- data.start_date = data.all_day_date;
- }
- data.start_time = '';
- data.end_time = '';
- }
- $edit_calendar_event_form
- .fillFormData(data, {object_name: 'calendar_event'})
- .show()
- .find("textarea").editorBox();
- if (wikiSidebar) {
- wikiSidebar.attachToEditor($edit_calendar_event_form.find("textarea:first"));
- wikiSidebar.show();
- $("#sidebar_content").hide();
- }
- };
-
- if (wikiSidebar) {
- wikiSidebar.init();
- }
- $(".date_field").date_field();
- $(".time_field").time_field();
- $(".delete_event_link").click(function(event) {
- event.preventDefault();
- $("#full_calendar_event_holder").confirmDelete({
- message: "Are you sure you want to delete this event?",
- url: $(this).attr('href'),
- success: function() {
- $(this).fadeOut('slow');
- window.location.href = $(".calendar_url").attr('href');
- }
- });
- });
- $(".switch_full_calendar_event_view").click(function() {
- $("#calendar_event_description").editorBox('toggle');
- // todo: replace .andSelf with .addBack when JQuery is upgraded.
- $(this).siblings(".switch_full_calendar_event_view").andSelf().toggle();
- return false;
- });
- $(".edit_calendar_event_link").click(function() {
- editCalendarEventForm();
- return false;
- });
- $edit_calendar_event_form.find(".cancel_button").click(function() {
- hideEditCalendarEventForm(true);
- return false;
- });
- $edit_calendar_event_form.formSubmit({
- object_name: 'calendar_event',
- processData: function(data) {
- data['calendar_event[start_at]'] = $.datetime.process(data.start_date + " " + data.start_time);
- data['calendar_event[end_at]'] = $.datetime.process(data.start_date + " " + data.end_time);
- data['calendar_event[description]'] = $(this).find("textarea").editorBox('get_code');
- $full_calendar_event_holder.fillTemplateData({
- data: data,
- except: ['description']
- });
- return data;
- },
- beforeSubmit: function(data) {
- hideEditCalendarEventForm();
- $full_calendar_event_holder.loadingImage();
- },
- success: function(data) {
- var calendar_event = data.calendar_event,
- start_at = tz.parse(calendar_event.start_at);
-
-
- calendar_event.start_at_date_string = $.dateString(start_at);
- calendar_event.start_at_time_string = $.timeString(start_at);
- calendar_event.end_at_time_string = $.timeString(calendar_event.end_at);
- calendar_event.all_day_date = $.dateString(calendar_event.all_day_date);
-
- $full_calendar_event_holder.find(".from_string,.to_string,.end_at_time_string").showIf(calendar_event.end_at && calendar_event.end_at != calendar_event.start_at);
- $full_calendar_event_holder.find(".at_string").showIf(!calendar_event.end_at || calendar_event.end_at == calendar_event.start_at);
- $full_calendar_event_holder.find(".not_all_day").showIf(!calendar_event.all_day);
- $full_calendar_event_holder
- .loadingImage('remove')
- .fillTemplateData({
- data: calendar_event,
- htmlValues: ['description']
- });
- $(this).find("textarea").editorBox('set_code', calendar_event.description);
- var month = null, year = null;
- if (calendar_event.start_at) {
- year = calendar_event.start_at.substring(0, 4);
- month = calendar_event.start_at.substring(5, 7);
- }
- var calendar_url = $(".base_calendar_url").attr('href'),
- split = calendar_url.split(/#/),
- anchor = split[1],
- base_url = split[0],
- json = {};
-
- try{
- json = $.parseJSON(anchor) || {};
- } catch(e) {
- json = {};
- }
- if (month && year) {
- json.month = month;
- json.year = year;
- }
- $(".calendar_url").attr('href', base_url + "#" + $.encodeToHex(JSON.stringify(json)));
-
- window.location.href = $(".calendar_url").attr('href');
- },
- error: function(data) {
- $full_calendar_event_holder.loadingImage('remove');
- $(".edit_calendar_event_link:first").click();
- $edit_calendar_event_form.formErrors(data);
- }
- });
- setTimeout(function() {
- if ($full_calendar_event_holder.hasClass('editing')) {
- $(".edit_calendar_event_link:first").click();
- }
- }, 500);
- $(document).fragmentChange(function(event, hash) {
- if (hash == "#edit") {
- $(".edit_calendar_event_link:first").click();
- }
- });
- $.scrollSidebar();
-
-});
-});
diff --git a/spec/controllers/calendars_controller_spec.rb b/spec/controllers/calendars_controller_spec.rb
index 5962bcb9f00..a3300badaab 100644
--- a/spec/controllers/calendars_controller_spec.rb
+++ b/spec/controllers/calendars_controller_spec.rb
@@ -62,41 +62,6 @@ describe CalendarsController do
end
end
- describe "POST 'switch_calendar'" do
- it "should not switch to the old calendar anymore" do
- expect(@user.preferences[:use_calendar1]).to be_nil
-
- post 'switch_calendar', {:preferred_calendar => '1'}
- expect(response).to redirect_to(calendar2_url(anchor: ' '))
- expect(@user.reload.preferences[:use_calendar1]).to be_truthy
- end
-
- it "should not switch to the old calendar if not allowed" do
- expect(@user.preferences[:use_calendar1]).to be_nil
- post 'switch_calendar', {:preferred_calendar => '1'}
- expect(response).to redirect_to(calendar2_url(anchor: ' '))
-
- # not messing with their preference in case they prefer cal1 in a
- # different account
- expect(@user.reload.preferences[:use_calendar1]).to be_truthy
- end
-
- it "should redirect to new calendar regardless of old preference settings" do
- expect(@user.preferences[:use_calendar1]).to be_nil
-
- post 'switch_calendar', {:preferred_calendar => '2'}
- expect(response).to redirect_to(calendar2_url(anchor: ' '))
- expect(@user.reload.preferences[:use_calendar1]).to be_nil
- end
-
- it "should switch to the new calendar if allowed" do
- @user.update_attribute(:preferences, {:use_calendar1 => true})
-
- post 'switch_calendar', {:preferred_calendar => '2'}
- expect(response).to redirect_to(calendar2_url(anchor: ' '))
- expect(@user.reload.preferences[:use_calendar1]).to be_nil
- end
- end
end
describe CalendarEventsApiController do
diff --git a/spec/views/calendars/_calendar.html.erb_spec.rb b/spec/views/calendars/_calendar.html.erb_spec.rb
deleted file mode 100644
index 1827ce7640c..00000000000
--- a/spec/views/calendars/_calendar.html.erb_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# 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
.
-#
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
-require File.expand_path(File.dirname(__FILE__) + '/../views_helper')
-
-describe "/calendars/_calendar" do
- it "should render" do
- today = Time.zone.today
- course_with_student
- view_context(@course, @user)
- assigns[:contexts] = [@course]
- assigns[:first_day] = today
- assigns[:last_day] = today + 30
- assigns[:current] = today + 2
- assigns[:events] = [@course.calendar_events.create!(:title => "some event", :start_at => Time.now)]
- assigns[:assignment_groups_for] = {}
- assigns[:body_classes] = []
- render :partial => 'calendars/calendar', :object => assigns[:events], :locals => {:current => today, :first_day => today - 3, :last_day => today + 30, :request => OpenObject.new(:path_parameters => {:controller => 'calendars', :action => 'show'}, :query_parameters => {})}
- end
-end
-
diff --git a/spec/views/calendars/show.html.erb_spec.rb b/spec/views/calendars/show.html.erb_spec.rb
deleted file mode 100644
index 27f7b1bef7d..00000000000
--- a/spec/views/calendars/show.html.erb_spec.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# 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
.
-#
-
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
-require File.expand_path(File.dirname(__FILE__) + '/../views_helper')
-
-describe "/calendars/show" do
- it "should render" do
- today = Time.zone.today
- course_with_student
- view_context(@course, @user)
- assigns[:events] = []
- assigns[:events] << @course.calendar_events.create!(:title => "some event", :start_at => Time.now, :end_at => Time.now)
- assigns[:events] << @course.assignments.create!(:title => "some assignment", :due_at => Time.now + 1000)
- assigns[:contexts] = [@course]
- assigns[:first_day] = today
- assigns[:last_day] = today + 30
- assigns[:current] = today + 2
- assigns[:assignment_groups_for] = {}
- assigns[:body_classes] = []
- render 'calendars/show'
- expect(response).not_to be_nil
- end
-end
-