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

Method save

core/models.py:68–91  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

66 return self.name
67
68 def save(self, *args, **kwargs):
69 if self.pk: # Only check existing records
70 orig = StreamProfile.objects.get(pk=self.pk)
71 if orig.locked:
72 allowed_fields = {"user_agent_id"} # Only allow this field to change
73 for field in self._meta.fields:
74 field_name = field.name
75
76 # Convert user_agent to user_agent_id for comparison
77 orig_value = getattr(orig, field_name)
78 new_value = getattr(self, field_name)
79
80 # Ensure that ForeignKey fields compare their ID values
81 if isinstance(orig_value, models.Model):
82 orig_value = orig_value.pk
83 if isinstance(new_value, models.Model):
84 new_value = new_value.pk
85
86 if field_name not in allowed_fields and orig_value != new_value:
87 raise ValidationError(
88 f"Cannot modify {field_name} on a protected profile."
89 )
90
91 super().save(*args, **kwargs)
92
93 @classmethod
94 def update(cls, pk, **kwargs):

Callers 15

_set_series_rules_rawMethod · 0.45
_set_epg_field_rawMethod · 0.45
updateMethod · 0.45
_update_groupMethod · 0.45
rehash_streamsFunction · 0.45
updateMethod · 0.45
partial_updateMethod · 0.45
dismissMethod · 0.45

Calls 1

getMethod · 0.45