diff --git a/api/tacticalrmm/checks/models.py b/api/tacticalrmm/checks/models.py index b5999c6f..31d12997 100644 --- a/api/tacticalrmm/checks/models.py +++ b/api/tacticalrmm/checks/models.py @@ -166,6 +166,27 @@ class Check(models.Model): if self.check_type == "cpuload" or self.check_type == "memory": return ", ".join(str(f"{x}%") for x in self.history[-6:]) + @property + def non_editable_fields(self): + return [ + "check_type", + "status", + "more_info", + "last_run", + "fail_count", + "email_sent", + "text_sent", + "outage_history", + "extra_details", + "stdout", + "stderr", + "retcode", + "execution_time", + "history", + "readable_desc", + "history_info", + ] + def handle_check(self, data): if self.check_type != "cpuload" and self.check_type != "memory": diff --git a/api/tacticalrmm/checks/views.py b/api/tacticalrmm/checks/views.py index cfa8af14..a57590d2 100644 --- a/api/tacticalrmm/checks/views.py +++ b/api/tacticalrmm/checks/views.py @@ -59,6 +59,9 @@ class GetUpdateDeleteCheck(APIView): def patch(self, request, pk): check = get_object_or_404(Check, pk=pk) + # removed fields that should not be changed when editing a check from the frontend + [request.data.pop(i) for i in check.non_editable_fields] + serializer = CheckSerializer(instance=check, data=request.data, partial=True) serializer.is_valid(raise_exception=True) obj = serializer.save()