Skip to content

Commit 041bb08

Browse files
authored
Merge pull request #507 from johannaengland/bugs/notificationprofile/media-empty
Allow empty media when updating notificationprofile
2 parents 8183b95 + 0ce25f8 commit 041bb08

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/argus/notificationprofile/V1/serializers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ def update(self, instance: NotificationProfile, validated_data: dict):
8585
phone_number = validated_data.pop("phone_number", None)
8686
media = validated_data.pop("media", None)
8787

88-
# Update media
89-
if media:
88+
# Update media to be empty
89+
if media == set():
90+
instance.destinations.set([])
91+
92+
# Update media to not be empty
93+
if "SM" in media or "EM" in media:
9094
if "SM" in media and "EM" not in media:
9195
email_destinations = instance.destinations.filter(media_id="email")
9296
instance.destinations.remove(*email_destinations)

0 commit comments

Comments
 (0)