MCPcopy Index your code
hub / github.com/Flagsmith/flagsmith / destroy

Method destroy

api/experimentation/views.py:625–646  ·  view source on GitHub ↗
(self, request: Request, *args: object, **kwargs: object)

Source from the content-addressed store, hash-verified

623 create_metric_audit_log(metric, self._get_user(self.request), action="updated")
624
625 def destroy(self, request: Request, *args: object, **kwargs: object) -> Response:
626 instance: Metric = self.get_object()
627 if (
628 ExperimentMetric.objects.filter(
629 metric=instance,
630 experiment__deleted_at__isnull=True,
631 )
632 .exclude(experiment__status=ExperimentStatus.COMPLETED)
633 .exists()
634 ):
635 return Response(
636 {
637 "detail": (
638 "Cannot delete a metric attached to an active experiment. "
639 "Detach it or complete the experiment first."
640 )
641 },
642 status=status.HTTP_409_CONFLICT,
643 )
644 create_metric_audit_log(instance, self._get_user(request), action="deleted")
645 instance.delete()
646 return Response(status=status.HTTP_204_NO_CONTENT)
647
648 @staticmethod
649 def _get_user(request: Request) -> FFAdminUser:

Callers 1

destroyMethod · 0.45

Calls 5

_get_userMethod · 0.95
create_metric_audit_logFunction · 0.90
existsMethod · 0.80
get_objectMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected