def create_metaxcan(self, request, *args, **kwargs): user = self.get_authenticated_user() active = Job.active_job(self.request.user) if active: raise PermissionDenied job, headers = self.create_job(request, args, kwargs) metaxcan_parameters = MetaxcanParameters(owner=user) metaxcan_parameters.save() job.metaxcan_parameters = metaxcan_parameters job.save() serializer = self.get_serializer(job) return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
def active(self, request, *args, **kwargs): user = self.get_authenticated_user() active = Job.active_job(self.request.user) data = self.get_serializer(active).data if active else None return Response(data)