Fixed timezone issue and added alarm support.
This commit is contained in:
parent
ac1c17fb2a
commit
af29df04c0
2 changed files with 28 additions and 11 deletions
|
@ -30,7 +30,6 @@ class CalendarSubscriptions
|
||||||
end
|
end
|
||||||
|
|
||||||
def generic(object_name, method_name = 'all')
|
def generic(object_name, method_name = 'all')
|
||||||
|
|
||||||
events_data = generic_call(object_name, method_name)
|
events_data = generic_call(object_name, method_name)
|
||||||
to_ical(events_data)
|
to_ical(events_data)
|
||||||
end
|
end
|
||||||
|
@ -59,6 +58,13 @@ class CalendarSubscriptions
|
||||||
cal.event do |e|
|
cal.event do |e|
|
||||||
e.dtstart = event_data[:dtstart]
|
e.dtstart = event_data[:dtstart]
|
||||||
e.dtend = event_data[:dtend]
|
e.dtend = event_data[:dtend]
|
||||||
|
if event_data[:alarm]
|
||||||
|
e.alarm do |a|
|
||||||
|
a.action = 'DISPLAY'
|
||||||
|
a.summary = event_data[:alarm][:summary]
|
||||||
|
a.trigger = event_data[:alarm][:trigger]
|
||||||
|
end
|
||||||
|
end
|
||||||
e.summary = event_data[:summary]
|
e.summary = event_data[:summary]
|
||||||
e.description = event_data[:description]
|
e.description = event_data[:description]
|
||||||
e.ip_class = 'PRIVATE'
|
e.ip_class = 'PRIVATE'
|
||||||
|
|
|
@ -5,6 +5,7 @@ class CalendarSubscriptions::Tickets
|
||||||
def initialize(user, preferences)
|
def initialize(user, preferences)
|
||||||
@user = user
|
@user = user
|
||||||
@preferences = preferences
|
@preferences = preferences
|
||||||
|
@tzid = 'UTC'
|
||||||
end
|
end
|
||||||
|
|
||||||
def all
|
def all
|
||||||
|
@ -75,8 +76,8 @@ class CalendarSubscriptions::Tickets
|
||||||
|
|
||||||
translated_state = Translation.translate(user_locale, ticket.state.name)
|
translated_state = Translation.translate(user_locale, ticket.state.name)
|
||||||
|
|
||||||
event_data[:dtstart] = Icalendar::Values::Date.new( Time.zone.today )
|
event_data[:dtstart] = Icalendar::Values::Date.new(Time.zone.today, 'tzid' => @tzid)
|
||||||
event_data[:dtend] = Icalendar::Values::Date.new( Time.zone.today )
|
event_data[:dtend] = Icalendar::Values::Date.new(Time.zone.today, 'tzid' => @tzid)
|
||||||
event_data[:summary] = "#{translated_state} #{translated_ticket}: '#{ticket.title}'"
|
event_data[:summary] = "#{translated_state} #{translated_ticket}: '#{ticket.title}'"
|
||||||
event_data[:description] = "T##{ticket.number}"
|
event_data[:description] = "T##{ticket.number}"
|
||||||
|
|
||||||
|
@ -117,6 +118,7 @@ class CalendarSubscriptions::Tickets
|
||||||
|
|
||||||
user_locale = @user.preferences['locale'] || 'en'
|
user_locale = @user.preferences['locale'] || 'en'
|
||||||
translated_ticket = Translation.translate(user_locale, 'ticket')
|
translated_ticket = Translation.translate(user_locale, 'ticket')
|
||||||
|
customer = Translation.translate(user_locale, 'customer')
|
||||||
|
|
||||||
events_data = []
|
events_data = []
|
||||||
tickets.each do |ticket|
|
tickets.each do |ticket|
|
||||||
|
@ -132,10 +134,14 @@ class CalendarSubscriptions::Tickets
|
||||||
|
|
||||||
translated_state = Translation.translate(user_locale, ticket.state.name)
|
translated_state = Translation.translate(user_locale, ticket.state.name)
|
||||||
|
|
||||||
event_data[:dtstart] = Icalendar::Values::DateTime.new( pending_time )
|
event_data[:dtstart] = Icalendar::Values::DateTime.new(pending_time, 'tzid' => @tzid)
|
||||||
event_data[:dtend] = Icalendar::Values::DateTime.new( pending_time )
|
event_data[:dtend] = Icalendar::Values::DateTime.new(pending_time, 'tzid' => @tzid)
|
||||||
event_data[:summary] = "#{translated_state} #{translated_ticket}: '#{ticket.title}'"
|
event_data[:summary] = "#{translated_state} #{translated_ticket}: '#{ticket.title}' #{customer}: #{ticket.customer.longname}"
|
||||||
event_data[:description] = "T##{ticket.number}"
|
event_data[:description] = "T##{ticket.number}"
|
||||||
|
event_data[:alarm] = {
|
||||||
|
summary: event_data[:summary],
|
||||||
|
trigger: '-PT1M',
|
||||||
|
}
|
||||||
|
|
||||||
events_data.push event_data
|
events_data.push event_data
|
||||||
end
|
end
|
||||||
|
@ -167,6 +173,7 @@ class CalendarSubscriptions::Tickets
|
||||||
|
|
||||||
user_locale = @user.preferences['locale'] || 'en'
|
user_locale = @user.preferences['locale'] || 'en'
|
||||||
translated_ticket_escalation = Translation.translate(user_locale, 'ticket escalation')
|
translated_ticket_escalation = Translation.translate(user_locale, 'ticket escalation')
|
||||||
|
customer = Translation.translate(user_locale, 'customer')
|
||||||
|
|
||||||
tickets.each do |ticket|
|
tickets.each do |ticket|
|
||||||
|
|
||||||
|
@ -179,10 +186,14 @@ class CalendarSubscriptions::Tickets
|
||||||
escalation_time = Time.zone.today
|
escalation_time = Time.zone.today
|
||||||
end
|
end
|
||||||
|
|
||||||
event_data[:dtstart] = Icalendar::Values::DateTime.new( escalation_time )
|
event_data[:dtstart] = Icalendar::Values::DateTime.new(escalation_time, 'tzid' => @tzid)
|
||||||
event_data[:dtend] = Icalendar::Values::DateTime.new( escalation_time )
|
event_data[:dtend] = Icalendar::Values::DateTime.new(escalation_time, 'tzid' => @tzid)
|
||||||
event_data[:summary] = "#{translated_ticket_escalation}: '#{ticket.title}'"
|
event_data[:summary] = "#{translated_ticket_escalation}: '#{ticket.title}' #{customer}: #{ticket.customer.longname} "
|
||||||
event_data[:description] = "T##{ticket.number}"
|
event_data[:description] = "T##{ticket.number}"
|
||||||
|
event_data[:alarm] = {
|
||||||
|
summary: event_data[:summary],
|
||||||
|
trigger: '-PT1M',
|
||||||
|
}
|
||||||
|
|
||||||
events_data.push event_data
|
events_data.push event_data
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue