(self, request, *args, **kwargs)
| 2278 | ) |
| 2279 | @action(detail=True, methods=["post"], url_path="delete") |
| 2280 | def delete(self, request, *args, **kwargs): |
| 2281 | organization = self.request.organization |
| 2282 | now = now_utc() |
| 2283 | addon = self.get_object() |
| 2284 | num_active_subscriptions = SubscriptionRecord.objects.active().filter( |
| 2285 | organization=organization, |
| 2286 | billing_plan__plan=addon, |
| 2287 | ) |
| 2288 | if num_active_subscriptions > 0: |
| 2289 | raise InvalidOperation("Cannot delete plan with active subscriptions") |
| 2290 | versions = addon.versions.filter(deleted__isnull=True) |
| 2291 | num_versions = versions.count() |
| 2292 | versions.update(deleted=now) |
| 2293 | addon.deleted = now |
| 2294 | addon.save() |
| 2295 | return Response( |
| 2296 | { |
| 2297 | "success": True, |
| 2298 | "message": f"Deleted {num_versions} versions of addon {addon.plan_name}", |
| 2299 | }, |
| 2300 | status=status.HTTP_200_OK, |
| 2301 | ) |
| 2302 | |
| 2303 | @extend_schema(responses=AddOnDetailSerializer) |
| 2304 | def update(self, request, *args, **kwargs): |
nothing calls this directly
no test coverage detected