iCalendar support

pull/6827/head
friflaj 15 years ago
parent 3eeca30f63
commit b1b529cec8
  1. 96
      app/controllers/backlogs_controller.rb
  2. 3
      app/views/backlogs/_view_issues_sidebar.html.erb
  3. 5
      config/locales/en.yml
  4. 4
      config/locales/nl.yml
  5. 1
      config/routes.rb
  6. 1
      init.rb
  7. 1
      lib/backlogs_hooks.rb

@ -1,6 +1,8 @@
include StoriesHelper
include BacklogMenuHelper
require 'icalendar'
class BacklogsController < ApplicationController
unloadable
@ -196,6 +198,100 @@ class BacklogsController < ApplicationController
send_data(cards.pdf.render, :filename => 'cards.pdf', :disposition => 'attachment', :type => 'application/pdf')
end
def calendar
cal = Icalendar::Calendar.new
# current + future sprints
Sprint.find(:all, :conditions => ["not sprint_start_date is null and not effective_date is null and project_id = ? and effective_date >= ?", @project.id, Date.today]).each {|sprint|
cal.event do
dtstart sprint.sprint_start_date
dtend sprint.effective_date
summary l(:event_sprint_summary, { :project => @project.name, :summary => sprint.name } )
description l(:event_sprint_description, {
:summary => sprint.name,
:description => sprint.description,
:url => url_for({
:controller => 'backlogs',
:only_path => false,
:action => 'select_issues',
:project_id => @project.id,
:sprint_id => sprint.id
})
})
klass 'PRIVATE'
transp 'TRANSPARENT'
end
}
open_issues = "
#{IssueStatus.table_name}.is_closed = ?
and tracker_id in (?)
and fixed_version_id in (
select id
from versions
where project_id = ?
and status = 'open'
and not sprint_start_date is null
and effective_date >= ?
)
"
open_issues_and_impediments = "
(assigned_to_id is null or assigned_to_id = ?)
and
(
(#{open_issues})
or
( #{IssueStatus.table_name}.is_closed = ?
and #{Issue.table_name}.id in (
select issue_from_id
from issue_relations
join issues on issues.id = issue_to_id and relation_type = 'blocks'
where #{open_issues})
)
)
"
conditions = [open_issues_and_impediments]
# me or none
conditions << User.current.id
# open stories/tasks
conditions << false
conditions << Story.trackers + [Task.tracker]
conditions << @project.id
conditions << Date.today
# open impediments...
conditions << false
# ... for open stories/tasks
conditions << false
conditions << Story.trackers + [Task.tracker]
conditions << @project.id
conditions << Date.today
issues = Issue.find(:all, :include => :status, :conditions => conditions).each {|issue|
cal.todo do
summary l(:todo_issue_summary, { :type => issue.tracker.name, :summary => issue.subject } )
description l(:todo_issue_description, {
:summary => issue.subject,
:description => issue.description,
:url => url_for({
:controller => 'issues',
:only_path => false,
:action => 'show',
:id => issue.id
})
})
klass 'PRIVATE'
category issue.tracker.name
transp 'TRANSPARENT'
end
}
send_data(cal.to_ical, :filename => "#{@project.identifier}.ics", :disposition => 'attachment', :type => 'text/calendar')
end
private
def find_project

@ -11,7 +11,7 @@
<% end %>
<% end %>
<h3><%= l(:backlogs_product_backlog) %></h3>
<h3><%= project.name %></h3>
<%= link_to(l(:backlogs_product_backlog), {
:controller => 'backlogs',
:action => 'select_issues',
@ -22,6 +22,7 @@
:action => 'product_backlog_cards',
:project_id => project.id
}) %><br/>
<a href="<%= url_for({ :controller => 'backlogs', :only_path => false, :protocol => webcal, :action => 'calendar'}) %>"><%= l(:label_calendar) %></a><br>
<% if sprint && sprint.has_burndown %>
<h3><%= l(:label_sprint_name, {:name => sprint.name}) %></h3>

@ -64,3 +64,8 @@ en:
label_backlogs_unconfigured: "You have not configured Backlogs yet. Please go to {{administration}} > {{plugins}}, then click on the {{configure}} link for this plugin. Once you have set the fields, come back to this page to start using the tool."
label_sprint_velocity: "Velocity {{velocity}}, based on {{sprints}} sprints with an average {{days}} days"
event_sprint_summary: "{{project}}: {{summary}}"
event_sprint_description: "{{summary}}: {{url}}\n{{description}}"
todo_issue_summary: "{{type}}: {{summary}}"
todo_issue_description: "{{summary}}: {{url}}\n{{description}}"

@ -57,3 +57,7 @@ nl:
label_scrum_statistics: Scrum statistieken
label_stories: Stories
label_sprint_velocity: "Velocity {{velocity}}, berekend over {{sprints}} sprints met gemiddeld {{days}} dagen"
event_sprint_summary: "{{project}}: {{summary}}"
event_sprint_description: "{{summary}}: {{url}}\n{{description}}"
todo_issue_summary: "{{type}}: {{summary}}"
todo_issue_description: "{{summary}}: {{url}}\n{{description}}"

@ -5,5 +5,6 @@ ActionController::Routing::Routes.draw do |map|
map.connect 'backlogs/:project_id/:sprint_id/wiki', :controller => 'backlogs', :action => 'wiki'
map.connect 'backlogs/:project_id/:sprint_id/cards', :controller => 'backlogs', :action => 'taskboard_cards'
map.connect 'backlogs/:project_id/cards', :controller => 'backlogs', :action => 'product_backlog_cards'
map.connect 'backlogs/:project_id/calendar', :controller => 'backlogs', :action => 'calendar'
end

@ -57,6 +57,7 @@ Redmine::Plugin.register :redmine_backlogs do
:select_issues,
:taskboard_cards,
:product_backlog_cards,
:calendar,
:burndown ],
:stories => [ :index ],
:tasks => [ :index ],

@ -9,6 +9,7 @@ module BacklogsPlugin
locals[:sprints] = Sprint.open_sprints(context[:project])
locals[:project] = context[:project]
locals[:sprint] = nil
locals[:webcal] = (context[:request].ssl? ? 'webcals' : 'webcal')
q = context[:request].session[:query]
if q

Loading…
Cancel
Save