Project

General

Profile

Feature #1077 » ICS_Support__3.patch

Sławek Goszcz, 2009-09-07 10:43

View differences:

redmine/app/controllers/application.rb 2009-09-04 14:55:52.000000000 +0200
require 'uri'
require 'cgi'
require 'icalendar'
class ApplicationController < ActionController::Base
layout 'base'
......
render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
end
#EDIT
def render_ics(items, options={})
cal = Icalendar::Calendar.new
items.each { |i|
event = Icalendar::Event.new
event.dtstart = i.start_date
event.dtend = i.due_date
if i.is_a? Issue
event.summary = i.subject
else
event.summary = "V. " + i.name
end
if !i.description.nil?
event.description = i.description
end
cal.add_event(event)
}
@cal_string = cal.to_ical
render :template => "common/calendar.ics.erb", :layout => false , :content_type => Mime::ICS
end
def self.accept_key_auth(*actions)
actions = actions.flatten.map(&:to_s)
write_inheritable_attribute('accept_key_auth_actions', actions)
redmine/app/controllers/issues_controller.rb 2009-09-04 14:50:42.000000000 +0200
retrieve_query
if @query.valid?
events = []
#EDIT
if (request.format == Mime::ICS)
@calendar.startdt = @project.created_on.to_s(:db)
end
events += Issue.find(:all,
:include => [:tracker, :status, :assigned_to, :priority, :project],
:conditions => ["(#{@query.statement}) AND ((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt]
......
@calendar.events = events
end
render :layout => false if request.xhr?
#render :layout => false if request.xhr?
#EDIT
respond_to do |format|
format.html { render :layout => false if request.xhr? }
format.ics { render_ics(events) }
end
end
def context_menu
redmine/app/views/common/calendar.ics.erb 2009-09-04 14:59:00.000000000 +0200
<%= @cal_string %>
redmine/lib/redmine/helpers/calendar.rb 2009-09-04 14:39:59.000000000 +0200
end
end
def startdt=(dt)
@startdt = dt
end
# Sets calendar events
def events=(events)
@events = events
(3-3/12)