def subscribe(self, request, pk, org, auditlog=None): name = request.data.get("product") try: product = models.Product.objects.get(name=name) except models.Product.DoesNotExist: return Response({"product": [f"Unknown product: {name}"]}, status=400) sub = models.Subscription.get_or_create(org, product.group) sub.add_prod(product) if not sub.cycle: sub.start_cycle() serializer = Serializers.sub(sub) return Response(serializer.data)
def services(self, request, pk, org): queryset = models.Subscription.objects.filter(org=org) serializer = Serializers.sub(queryset, many=True) return Response(serializer.data)