Allow editing assigned team via public api (#1619)
# What this PR does
For example, changing the integration's team
```
curl "localhost:8080/api/v1/integrations/CLYV3QBVHDV3T/" \
--request PUT \
--header "Authorization: meow" \
--header "Content-Type: application/json" --data '{"team_id": "TWP6JJJN6LYZX"}'
```
## Which issue(s) this PR fixes
## Checklist
- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
This commit is contained in:
parent
42291748b5
commit
498e7ed5f3
9 changed files with 6 additions and 15 deletions
|
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Changed
|
||||
|
||||
- Allow editing assigned team via public api ([1619](https://github.com/grafana/oncall/pull/1619))
|
||||
- Disable mentions when resolution note is created by @iskhakov ([1696](https://github.com/grafana/oncall/pull/1696))
|
||||
- Display warnings on users page in a clean and consistent way by @iskhakov ([#1681](https://github.com/grafana/oncall/pull/1681))
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ class ActionCreateSerializer(serializers.ModelSerializer):
|
|||
|
||||
|
||||
class ActionUpdateSerializer(ActionCreateSerializer):
|
||||
team_id = TeamPrimaryKeyRelatedField(source="team", read_only=True)
|
||||
url = serializers.CharField(required=False, allow_null=False, allow_blank=False, source="webhook")
|
||||
|
||||
class Meta(ActionCreateSerializer.Meta):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,3 @@ class EscalationChainSerializer(serializers.ModelSerializer):
|
|||
"organization",
|
||||
"team_id",
|
||||
)
|
||||
|
||||
|
||||
class EscalationChainUpdateSerializer(EscalationChainSerializer):
|
||||
team_id = TeamPrimaryKeyRelatedField(source="team", read_only=True)
|
||||
|
|
|
|||
|
|
@ -359,7 +359,6 @@ class IntegrationSerializer(EagerLoadingMixin, serializers.ModelSerializer, Main
|
|||
|
||||
class IntegrationUpdateSerializer(IntegrationSerializer):
|
||||
type = IntegrationTypeField(source="integration", read_only=True)
|
||||
team_id = TeamPrimaryKeyRelatedField(source="team", read_only=True)
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
validated_data = self._correct_validated_data(validated_data)
|
||||
|
|
|
|||
|
|
@ -359,7 +359,6 @@ class CustomOnCallShiftUpdateSerializer(CustomOnCallShiftSerializer):
|
|||
name = serializers.CharField(required=False)
|
||||
start = serializers.DateTimeField(required=False)
|
||||
rotation_start = serializers.DateTimeField(required=False)
|
||||
team_id = TeamPrimaryKeyRelatedField(read_only=True, source="team")
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
event_type = validated_data.get("type", instance.type)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from apps.schedules.tasks import (
|
|||
schedule_notify_about_empty_shifts_in_schedule,
|
||||
schedule_notify_about_gaps_in_schedule,
|
||||
)
|
||||
from common.api_helpers.custom_fields import TeamPrimaryKeyRelatedField, UsersFilteredByOrganizationField
|
||||
from common.api_helpers.custom_fields import UsersFilteredByOrganizationField
|
||||
from common.api_helpers.exceptions import BadRequest
|
||||
from common.timezones import TimeZoneField
|
||||
|
||||
|
|
@ -60,7 +60,6 @@ class ScheduleCalendarSerializer(ScheduleBaseSerializer):
|
|||
|
||||
class ScheduleCalendarUpdateSerializer(ScheduleCalendarSerializer):
|
||||
time_zone = TimeZoneField(required=False)
|
||||
team_id = TeamPrimaryKeyRelatedField(read_only=True, source="team")
|
||||
|
||||
class Meta:
|
||||
model = OnCallScheduleCalendar
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class ScheduleICalSerializer(ScheduleBaseSerializer):
|
|||
|
||||
|
||||
class ScheduleICalUpdateSerializer(ScheduleICalSerializer):
|
||||
team_id = TeamPrimaryKeyRelatedField(read_only=True, source="team")
|
||||
team_id = TeamPrimaryKeyRelatedField(required=False, allow_null=True, source="team")
|
||||
|
||||
class Meta:
|
||||
model = OnCallScheduleICal
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ from common.timezones import TimeZoneField
|
|||
|
||||
|
||||
class ScheduleWebSerializer(ScheduleBaseSerializer):
|
||||
team_id = TeamPrimaryKeyRelatedField(required=False, allow_null=True, source="team")
|
||||
time_zone = TimeZoneField(required=True)
|
||||
shifts = UsersFilteredByOrganizationField(
|
||||
queryset=CustomOnCallShift.objects,
|
||||
|
|
@ -49,7 +50,6 @@ class ScheduleWebSerializer(ScheduleBaseSerializer):
|
|||
|
||||
class ScheduleWebUpdateSerializer(ScheduleWebSerializer):
|
||||
time_zone = TimeZoneField(required=False)
|
||||
team_id = TeamPrimaryKeyRelatedField(read_only=True, source="team")
|
||||
|
||||
class Meta:
|
||||
model = OnCallScheduleWeb
|
||||
|
|
|
|||
|
|
@ -6,15 +6,14 @@ from rest_framework.viewsets import ModelViewSet
|
|||
from apps.alerts.models import EscalationChain
|
||||
from apps.auth_token.auth import ApiTokenAuthentication
|
||||
from apps.public_api.serializers import EscalationChainSerializer
|
||||
from apps.public_api.serializers.escalation_chains import EscalationChainUpdateSerializer
|
||||
from apps.public_api.throttlers.user_throttle import UserThrottle
|
||||
from common.api_helpers.filters import ByTeamFilter
|
||||
from common.api_helpers.mixins import RateLimitHeadersMixin, UpdateSerializerMixin
|
||||
from common.api_helpers.mixins import RateLimitHeadersMixin
|
||||
from common.api_helpers.paginators import FiftyPageSizePaginator
|
||||
from common.insight_log import EntityEvent, write_resource_insight_log
|
||||
|
||||
|
||||
class EscalationChainView(RateLimitHeadersMixin, UpdateSerializerMixin, ModelViewSet):
|
||||
class EscalationChainView(RateLimitHeadersMixin, ModelViewSet):
|
||||
authentication_classes = (ApiTokenAuthentication,)
|
||||
permission_classes = (IsAuthenticated,)
|
||||
|
||||
|
|
@ -22,7 +21,6 @@ class EscalationChainView(RateLimitHeadersMixin, UpdateSerializerMixin, ModelVie
|
|||
|
||||
model = EscalationChain
|
||||
serializer_class = EscalationChainSerializer
|
||||
update_serializer_class = EscalationChainUpdateSerializer
|
||||
|
||||
pagination_class = FiftyPageSizePaginator
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue