inline only usage of Array#to_ics
Change-Id: Ife84767f08ba50978e43045054bb9906443c03f3 Reviewed-on: https://gerrit.instructure.com/30030 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Raphael Weiner <rweiner@pivotallabs.com> Product-Review: Raphael Weiner <rweiner@pivotallabs.com> QA-Review: Raphael Weiner <rweiner@pivotallabs.com>
This commit is contained in:
parent
14d61df591
commit
1b2b74e34e
|
@ -563,8 +563,8 @@ class CalendarEventsApiController < ApplicationController
|
|||
end
|
||||
respond_to do |format|
|
||||
format.ics do
|
||||
render :text => @events.to_ics(t('ics_title', "%{course_or_group_name} Calendar (Canvas)", :course_or_group_name => @context.name),
|
||||
case
|
||||
name = t('ics_title', "%{course_or_group_name} Calendar (Canvas)", :course_or_group_name => @context.name)
|
||||
description = case
|
||||
when @context.is_a?(Course)
|
||||
t('ics_description_course', "Calendar events for the course, %{course_name}", :course_name => @context.name)
|
||||
when @context.is_a?(Group)
|
||||
|
@ -573,7 +573,20 @@ class CalendarEventsApiController < ApplicationController
|
|||
t('ics_description_user', "Calendar events for the user, %{user_name}", :user_name => @context.name)
|
||||
else
|
||||
t('ics_description', "Calendar events for %{context_name}", :context_name => @context.name)
|
||||
end)
|
||||
end
|
||||
|
||||
calendar = Icalendar::Calendar.new
|
||||
# to appease Outlook
|
||||
calendar.custom_property("METHOD", "PUBLISH")
|
||||
calendar.custom_property("X-WR-CALNAME", name)
|
||||
calendar.custom_property("X-WR-CALDESC", description)
|
||||
|
||||
@events.each do |event|
|
||||
ics_event = event.to_ics(false)
|
||||
calendar.add_event(ics_event) if ics_event
|
||||
end
|
||||
|
||||
render :text => calendar.to_ical
|
||||
end
|
||||
format.atom do
|
||||
feed = Atom::Feed.new do |f|
|
||||
|
|
|
@ -27,20 +27,6 @@ class Array
|
|||
end
|
||||
end
|
||||
|
||||
def to_ics(name="", desc="")
|
||||
cal = Icalendar::Calendar.new
|
||||
# to appease Outlook
|
||||
cal.custom_property("METHOD","PUBLISH")
|
||||
cal.custom_property("X-WR-CALNAME",name)
|
||||
cal.custom_property("X-WR-CALDESC",desc)
|
||||
|
||||
self.each do |item|
|
||||
event = item.to_ics(false)
|
||||
cal.add_event(event) if event
|
||||
end
|
||||
cal.to_ical
|
||||
end
|
||||
|
||||
# backport from ActiveSupport 3.x
|
||||
# Like uniq, but using a criteria given by a block, similar to sort_by
|
||||
unless method_defined?(:uniq_by)
|
||||
|
|
Loading…
Reference in New Issue