Commit 877ed9e7c615058576af8c772a1a2adb99a3a532

Authored by Nathan B
2 parents 5528df16 ab4890ba
Exists in master and in 1 other branch production

Merge pull request #105 from gorenje/ics_for_notices

Added ics format for a problem, listing its linked notices in ics format.
app/helpers/application_helper.rb
... ... @@ -3,6 +3,22 @@ module ApplicationHelper
3 3 create_percentage_table_for(problem) {|notice| notice.message}
4 4 end
5 5  
  6 + def generate_problem_ical(notices)
  7 + RiCal.Calendar do |cal|
  8 + notices.each_with_index do |notice,idx|
  9 + cal.event do |event|
  10 + event.summary = "#{idx+1} #{notice.message.to_s}"
  11 + event.description = notice.request['url']
  12 + event.dtstart = notice.created_at.utc
  13 + event.dtend = notice.created_at.utc + 60.minutes
  14 + event.organizer = notice.server_environment && notice.server_environment["hostname"]
  15 + event.location = notice.server_environment && notice.server_environment["project-root"]
  16 + event.url = app_err_url(:app_id => notice.problem.app.id, :id => notice.problem)
  17 + end
  18 + end
  19 + end.to_s
  20 + end
  21 +
6 22 def generate_ical(deploys)
7 23 RiCal.Calendar { |cal|
8 24 deploys.each_with_index do |deploy,idx|
... ...
app/views/errs/show.html.haml
... ... @@ -11,6 +11,8 @@
11 11 %strong Last Notice:
12 12 = last_notice_at(@problem).to_s(:micro)
13 13 - content_for :action_bar do
  14 + - if current_user.authentication_token
  15 + %span= link_to 'iCal', app_err_path(:app_id => @app.id, :id => @problem.id, :format => "ics", :auth_token => current_user.authentication_token), :class => "calendar_link"
14 16 - if @problem.app.issue_tracker_configured?
15 17 - if @problem.issue_link.blank?
16 18 %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "#{@app.issue_tracker.class::Label}_create create-issue"
... ...
app/views/errs/show.ics.haml 0 → 100644
... ... @@ -0,0 +1 @@
  1 += generate_problem_ical(@problem.notices.order_by(:created_at.asc))
... ...