MCPcopy Index your code
hub / github.com/Dispatcharr/Dispatcharr / update

Method update

core/models.py:94–115  ·  view source on GitHub ↗
(cls, pk, **kwargs)

Source from the content-addressed store, hash-verified

92
93 @classmethod
94 def update(cls, pk, **kwargs):
95 instance = cls.objects.get(pk=pk)
96
97 if instance.locked:
98 allowed_fields = {"user_agent_id"} # Only allow updating this field
99
100 for field_name, new_value in kwargs.items():
101 if field_name not in allowed_fields:
102 raise ValidationError(
103 f"Cannot modify {field_name} on a protected profile."
104 )
105
106 # Ensure user_agent ForeignKey updates correctly
107 if field_name == "user_agent" and isinstance(
108 new_value, cls._meta.get_field("user_agent").related_model
109 ):
110 new_value = new_value.pk # Convert object to ID if needed
111
112 setattr(instance, field_name, new_value)
113
114 instance.save()
115 return instance
116
117 def is_proxy(self):
118 if self.locked and self.name == PROXY_PROFILE_NAME:

Callers 5

WebsocketProviderFunction · 0.45
updateNotificationFunction · 0.45
send_websocket_eventFunction · 0.45
_update_groupMethod · 0.45
__init__Method · 0.45

Calls 2

getMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected