diff --git a/CHANGELOG.md b/CHANGELOG.md index 9951042e..41e27a46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Added + +- Add full avatar URL for on-call users in schedule internal API by @vadimkerr ([#2414](https://github.com/grafana/oncall/pull/2414)) + ## v1.3.3 (2023-06-29) ### Added diff --git a/engine/apps/api/tests/test_schedules.py b/engine/apps/api/tests/test_schedules.py index cf08592f..69ae02dc 100644 --- a/engine/apps/api/tests/test_schedules.py +++ b/engine/apps/api/tests/test_schedules.py @@ -1858,3 +1858,36 @@ def test_get_schedule_from_other_team_with_flag( response = client.get(url, format="json", **make_user_auth_headers(user, token)) assert response.status_code == status.HTTP_200_OK + + +@pytest.mark.django_db +def test_get_schedule_on_call_now( + make_organization, make_user_for_organization, make_token_for_organization, make_schedule, make_user_auth_headers +): + organization = make_organization(grafana_url="https://example.com") + user = make_user_for_organization(organization, username="test", avatar_url="/avatar/test123") + _, token = make_token_for_organization(organization) + + schedule = make_schedule( + organization, + schedule_class=OnCallScheduleWeb, + name="test_web_schedule", + ) + + client = APIClient() + url = reverse("api-internal:schedule-list") + with patch( + "apps.schedules.models.on_call_schedule.OnCallScheduleQuerySet.get_oncall_users", + return_value={schedule.pk: [user]}, + ): + response = client.get(url, format="json", **make_user_auth_headers(user, token)) + + assert response.status_code == status.HTTP_200_OK + assert response.json()["results"][0]["on_call_now"] == [ + { + "pk": user.public_primary_key, + "username": "test", + "avatar": "/avatar/test123", + "avatar_full": "https://example.com/avatar/test123", + } + ] diff --git a/engine/apps/user_management/models/user.py b/engine/apps/user_management/models/user.py index 931f1bcb..5ca8c27f 100644 --- a/engine/apps/user_management/models/user.py +++ b/engine/apps/user_management/models/user.py @@ -270,7 +270,12 @@ class User(models.Model): self._timezone = value def short(self): - return {"username": self.username, "pk": self.public_primary_key, "avatar": self.avatar_url} + return { + "username": self.username, + "pk": self.public_primary_key, + "avatar": self.avatar_url, + "avatar_full": self.avatar_full_url, + } # Insight logs @property