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,9 +30,8 @@ class CalendarSubscriptions
|
|||
end
|
||||
|
||||
def generic(object_name, method_name = 'all')
|
||||
|
||||
events_data = generic_call( object_name, method_name )
|
||||
to_ical( events_data )
|
||||
events_data = generic_call(object_name, method_name)
|
||||
to_ical(events_data)
|
||||
end
|
||||
|
||||
def generic_call(object_name, method_name = 'all')
|
||||
|
@ -59,6 +58,13 @@ class CalendarSubscriptions
|
|||
cal.event do |e|
|
||||
e.dtstart = event_data[:dtstart]
|
||||
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.description = event_data[:description]
|
||||
e.ip_class = 'PRIVATE'
|
||||
|
|
|
@ -5,6 +5,7 @@ class CalendarSubscriptions::Tickets
|
|||
def initialize(user, preferences)
|
||||
@user = user
|
||||
@preferences = preferences
|
||||
@tzid = 'UTC'
|
||||
end
|
||||
|
||||
def all
|
||||
|
@ -75,8 +76,8 @@ class CalendarSubscriptions::Tickets
|
|||
|
||||
translated_state = Translation.translate(user_locale, ticket.state.name)
|
||||
|
||||
event_data[:dtstart] = Icalendar::Values::Date.new( Time.zone.today )
|
||||
event_data[:dtend] = 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, 'tzid' => @tzid)
|
||||
event_data[:summary] = "#{translated_state} #{translated_ticket}: '#{ticket.title}'"
|
||||
event_data[:description] = "T##{ticket.number}"
|
||||
|
||||
|
@ -117,6 +118,7 @@ class CalendarSubscriptions::Tickets
|
|||
|
||||
user_locale = @user.preferences['locale'] || 'en'
|
||||
translated_ticket = Translation.translate(user_locale, 'ticket')
|
||||
customer = Translation.translate(user_locale, 'customer')
|
||||
|
||||
events_data = []
|
||||
tickets.each do |ticket|
|
||||
|
@ -132,10 +134,14 @@ class CalendarSubscriptions::Tickets
|
|||
|
||||
translated_state = Translation.translate(user_locale, ticket.state.name)
|
||||
|
||||
event_data[:dtstart] = Icalendar::Values::DateTime.new( pending_time )
|
||||
event_data[:dtend] = Icalendar::Values::DateTime.new( pending_time )
|
||||
event_data[:summary] = "#{translated_state} #{translated_ticket}: '#{ticket.title}'"
|
||||
event_data[:dtstart] = Icalendar::Values::DateTime.new(pending_time, 'tzid' => @tzid)
|
||||
event_data[:dtend] = Icalendar::Values::DateTime.new(pending_time, 'tzid' => @tzid)
|
||||
event_data[:summary] = "#{translated_state} #{translated_ticket}: '#{ticket.title}' #{customer}: #{ticket.customer.longname}"
|
||||
event_data[:description] = "T##{ticket.number}"
|
||||
event_data[:alarm] = {
|
||||
summary: event_data[:summary],
|
||||
trigger: '-PT1M',
|
||||
}
|
||||
|
||||
events_data.push event_data
|
||||
end
|
||||
|
@ -167,6 +173,7 @@ class CalendarSubscriptions::Tickets
|
|||
|
||||
user_locale = @user.preferences['locale'] || 'en'
|
||||
translated_ticket_escalation = Translation.translate(user_locale, 'ticket escalation')
|
||||
customer = Translation.translate(user_locale, 'customer')
|
||||
|
||||
tickets.each do |ticket|
|
||||
|
||||
|
@ -179,10 +186,14 @@ class CalendarSubscriptions::Tickets
|
|||
escalation_time = Time.zone.today
|
||||
end
|
||||
|
||||
event_data[:dtstart] = Icalendar::Values::DateTime.new( escalation_time )
|
||||
event_data[:dtend] = Icalendar::Values::DateTime.new( escalation_time )
|
||||
event_data[:summary] = "#{translated_ticket_escalation}: '#{ticket.title}'"
|
||||
event_data[:dtstart] = Icalendar::Values::DateTime.new(escalation_time, 'tzid' => @tzid)
|
||||
event_data[:dtend] = Icalendar::Values::DateTime.new(escalation_time, 'tzid' => @tzid)
|
||||
event_data[:summary] = "#{translated_ticket_escalation}: '#{ticket.title}' #{customer}: #{ticket.customer.longname} "
|
||||
event_data[:description] = "T##{ticket.number}"
|
||||
event_data[:alarm] = {
|
||||
summary: event_data[:summary],
|
||||
trigger: '-PT1M',
|
||||
}
|
||||
|
||||
events_data.push event_data
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue