MCPcopy
hub / github.com/uselotus/lotus / delete

Method delete

backend/metering_billing/views/model_views.py:1003–1027  ·  view source on GitHub ↗
(self, request, *args, **kwargs)

Source from the content-addressed store, hash-verified

1001 )
1002 @action(detail=True, methods=["post"], url_path="delete")
1003 def delete(self, request, *args, **kwargs):
1004 organization = self.request.organization
1005 now = now_utc()
1006 plan_version = self.get_object()
1007 num_active_subscriptions = (
1008 SubscriptionRecord.objects.active()
1009 .filter(
1010 organization=organization,
1011 billing_plan=plan_version,
1012 )
1013 .count()
1014 )
1015 if num_active_subscriptions > 0:
1016 raise InvalidOperation(
1017 "Cannot delete plan version with active subscriptions"
1018 )
1019 plan_version.deleted = now
1020 plan_version.save()
1021 return Response(
1022 {
1023 "success": True,
1024 "message": f"Deleted plan version {str(plan_version)}",
1025 },
1026 status=status.HTTP_200_OK,
1027 )
1028
1029 @extend_schema(
1030 parameters=None,

Callers

nothing calls this directly

Calls 5

get_objectMethod · 0.95
now_utcFunction · 0.90
InvalidOperationClass · 0.90
activeMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected