MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / update

Method update

core/serializers.py:48–91  ·  view source on GitHub ↗
(self, instance, validated_data)

Source from the content-addressed store, hash-verified

46 fields = "__all__"
47
48 def update(self, instance, validated_data):
49 if instance.key == NETWORK_ACCESS_KEY:
50 errors = False
51 invalid = {}
52 value = validated_data.get("value")
53 for key, val in value.items():
54 cidrs = val.split(",")
55 for cidr in cidrs:
56 try:
57 ipaddress.ip_network(cidr)
58 except:
59 errors = True
60 if key not in invalid:
61 invalid[key] = []
62 invalid[key].append(cidr)
63
64 if errors:
65 # Perform CIDR validation
66 raise serializers.ValidationError(
67 {
68 "message": "Invalid CIDRs",
69 "value": invalid,
70 }
71 )
72
73 # Sanitize series_rules when DVR settings are saved through the
74 # generic settings API (e.g. Settings page round-trip) to prevent
75 # corrupted non-dict entries from persisting.
76 if instance.key == DVR_SETTINGS_KEY:
77 value = validated_data.get("value")
78 if isinstance(value, dict) and "series_rules" in value:
79 rules = value["series_rules"]
80 value["series_rules"] = (
81 [r for r in rules if isinstance(r, dict)]
82 if isinstance(rules, list)
83 else []
84 )
85
86 result = super().update(instance, validated_data)
87
88 # Note: Cache invalidation and notification sync is handled by post_save signal
89 # in core/signals.py to ensure it happens even if settings are updated elsewhere
90
91 return result
92
93class ProxySettingsSerializer(serializers.Serializer):
94 """Serializer for proxy settings stored as JSON in CoreSettings"""

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected