Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add is_default fields to templates, remove WritableSerialiserMethodFi… #1759

Merged
merged 8 commits into from
Apr 18, 2023
Prev Previous commit
Next Next commit
Cleanup
iskhakov committed Apr 18, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 7b6ff62bd2fed21c0ae044456ec7d4eda8b33758
9 changes: 3 additions & 6 deletions engine/apps/api/serializers/alert_receive_channel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections import OrderedDict
from collections.abc import Mapping

from django.apps import apps
from django.conf import settings
@@ -10,7 +9,6 @@
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from rest_framework.fields import SerializerMethodField, set_value
from rest_framework.settings import api_settings

from apps.alerts.grafana_alerting_sync_manager.grafana_alerting_sync import GrafanaAlertingSyncManager
from apps.alerts.models import AlertReceiveChannel
@@ -246,11 +244,10 @@ def to_internal_value(self, data):
"""
Dict of native values <- Dict of primitive datatypes.
"""
if not isinstance(data, Mapping):
message = self.error_messages["invalid"].format(datatype=type(data).__name__)
raise ValidationError({api_settings.NON_FIELD_ERRORS_KEY: [message]}, code="invalid")
# First validate and save data from serializer fields
ret = super().to_internal_value(data)

ret = OrderedDict()
# Separately validate and save template fields we generate dynamically
errors = OrderedDict()

# handle updates for core templates