(self, request: Request, *args: object, **kwargs: object)
| 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: |
no test coverage detected