Update ical export to track primary/overrides calendar using priority (#2871)
Related to https://github.com/grafana/oncall/issues/2778
This commit is contained in:
parent
ec028eb9d9
commit
a17569c49c
5 changed files with 19 additions and 9 deletions
|
|
@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Public API for actions now wraps webhooks @mderynck ([#2790](https://github.com/grafana/oncall/pull/2790))
|
||||
- Allow mobile app to access status endpoint @mderynck ([#2791](https://github.com/grafana/oncall/pull/2791))
|
||||
- Enable shifts export endpoint for all schedule types ([#2863](https://github.com/grafana/oncall/pull/2863))
|
||||
- Use priority field to track primary/overrides calendar in schedule iCal export ([#2871](https://github.com/grafana/oncall/pull/2871))
|
||||
|
||||
## v1.3.26 (2023-08-22)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ ICAL_RRULE = "RRULE"
|
|||
ICAL_UNTIL = "UNTIL"
|
||||
ICAL_LAST_MODIFIED = "LAST-MODIFIED"
|
||||
ICAL_LOCATION = "LOCATION"
|
||||
ICAL_PRIORITY = "PRIORITY"
|
||||
ICAL_STATUS = "STATUS"
|
||||
ICAL_STATUS_CANCELLED = "CANCELLED"
|
||||
ICAL_COMPONENT_VEVENT = "VEVENT"
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ from apps.schedules.constants import (
|
|||
ICAL_DATETIME_START,
|
||||
ICAL_DESCRIPTION,
|
||||
ICAL_LOCATION,
|
||||
ICAL_PRIORITY,
|
||||
ICAL_RECURRENCE_ID,
|
||||
ICAL_SEQUENCE,
|
||||
ICAL_STATUS,
|
||||
|
|
@ -218,7 +219,12 @@ def get_shifts_dict(
|
|||
if calendar_type == CALENDAR_TYPE_FINAL:
|
||||
event_calendar_type = (
|
||||
schedule.OVERRIDES
|
||||
if event.get(ICAL_LOCATION, "") == schedule.CALENDAR_TYPE_VERBAL[schedule.OVERRIDES]
|
||||
if (
|
||||
event.get(ICAL_PRIORITY, "") == schedule.OVERRIDES
|
||||
or
|
||||
# keep for backwards compatibility (to be removed later once schedules are refreshed)
|
||||
event.get(ICAL_LOCATION, "") == schedule.CALENDAR_TYPE_VERBAL[schedule.OVERRIDES]
|
||||
)
|
||||
else schedule.PRIMARY
|
||||
)
|
||||
# Define on-call shift out of ical event that has the actual user
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ from apps.schedules.constants import (
|
|||
ICAL_DATETIME_STAMP,
|
||||
ICAL_DATETIME_START,
|
||||
ICAL_LAST_MODIFIED,
|
||||
ICAL_LOCATION,
|
||||
ICAL_PRIORITY,
|
||||
ICAL_STATUS,
|
||||
ICAL_STATUS_CANCELLED,
|
||||
ICAL_SUMMARY,
|
||||
|
|
@ -461,7 +461,9 @@ class OnCallSchedule(PolymorphicModel):
|
|||
event.add(ICAL_DATETIME_END, e["end"])
|
||||
event.add(ICAL_DATETIME_STAMP, now)
|
||||
event.add(ICAL_LAST_MODIFIED, now)
|
||||
event.add(ICAL_LOCATION, self.CALENDAR_TYPE_VERBAL.get(e["calendar_type"], ""))
|
||||
# set priority based on primary/overrides
|
||||
# 0: undefined priority, 1: high priority
|
||||
event.add(ICAL_PRIORITY, e["calendar_type"])
|
||||
event_uid = "{}-{}-{}".format(e["shift"]["pk"], e["start"].strftime("%Y%m%d%H%S"), u["pk"])
|
||||
event[ICAL_UID] = event_uid
|
||||
calendar.add_component(event)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from apps.schedules.constants import (
|
|||
ICAL_DATETIME_END,
|
||||
ICAL_DATETIME_START,
|
||||
ICAL_LAST_MODIFIED,
|
||||
ICAL_LOCATION,
|
||||
ICAL_PRIORITY,
|
||||
ICAL_STATUS,
|
||||
ICAL_STATUS_CANCELLED,
|
||||
ICAL_SUMMARY,
|
||||
|
|
@ -1663,25 +1663,25 @@ def test_refresh_ical_final_schedule_ok(
|
|||
u1.username,
|
||||
today,
|
||||
today + timezone.timedelta(seconds=(12 * 60 * 60) - 1),
|
||||
OnCallSchedule.CALENDAR_TYPE_VERBAL[OnCallSchedule.PRIMARY],
|
||||
OnCallSchedule.PRIMARY,
|
||||
),
|
||||
(
|
||||
u2.username,
|
||||
today + timezone.timedelta(hours=12),
|
||||
today + timezone.timedelta(hours=22),
|
||||
OnCallSchedule.CALENDAR_TYPE_VERBAL[OnCallSchedule.PRIMARY],
|
||||
OnCallSchedule.PRIMARY,
|
||||
),
|
||||
(
|
||||
u1.username,
|
||||
today + timezone.timedelta(hours=22),
|
||||
today + timezone.timedelta(hours=23),
|
||||
OnCallSchedule.CALENDAR_TYPE_VERBAL[OnCallSchedule.OVERRIDES],
|
||||
OnCallSchedule.OVERRIDES,
|
||||
),
|
||||
(
|
||||
u2.username,
|
||||
today + timezone.timedelta(hours=23),
|
||||
today + timezone.timedelta(seconds=(24 * 60 * 60) - 1),
|
||||
OnCallSchedule.CALENDAR_TYPE_VERBAL[OnCallSchedule.PRIMARY],
|
||||
OnCallSchedule.PRIMARY,
|
||||
),
|
||||
}
|
||||
|
||||
|
|
@ -1699,7 +1699,7 @@ def test_refresh_ical_final_schedule_ok(
|
|||
component[ICAL_SUMMARY],
|
||||
component[ICAL_DATETIME_START].dt,
|
||||
component[ICAL_DATETIME_END].dt,
|
||||
component[ICAL_LOCATION],
|
||||
component[ICAL_PRIORITY],
|
||||
)
|
||||
assert event in expected_events
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue