Exemplo n.º 1
0
 def handle_export_collection_version(self):
     version = self.get_object()
     try:
         export_collection.delay(version.id)
         return 202
     except AlreadyQueued:
         return 409
Exemplo n.º 2
0
 def handle_export_collection_version(self):
     version = self.get_object()
     try:
         export_collection.delay(version.id)
         return 202
     except AlreadyQueued:
         return 409
Exemplo n.º 3
0
 def create(self, request, *args, **kwargs):
     if not self.versioned_object:
         return HttpResponse(status=status.HTTP_405_METHOD_NOT_ALLOWED)
     serializer = self.get_serializer(data=request.DATA,
                                      files=request.FILES)
     if serializer.is_valid():
         self.pre_save(serializer.object)
         try:
             self.object = serializer.save(
                 force_insert=True, versioned_object=self.versioned_object)
             if serializer.is_valid():
                 self.post_save(self.object, created=True)
                 headers = self.get_success_headers(serializer.data)
                 version = self.object
                 export_collection.delay(version.id)
                 return Response(serializer.data,
                                 status=status.HTTP_201_CREATED,
                                 headers=headers)
         except IntegrityError, e:
             result = {
                 'error':
                 str(e),
                 'detail':
                 'Collection version  \'%s\' already exist. ' %
                 serializer.data.get('id')
             }
             return Response(result, status=status.HTTP_409_CONFLICT)
Exemplo n.º 4
0
 def create(self, request, *args, **kwargs):
     if not self.versioned_object:
         return HttpResponse(status=status.HTTP_405_METHOD_NOT_ALLOWED)
     serializer = self.get_serializer(data=request.DATA, files=request.FILES)
     if serializer.is_valid():
         self.pre_save(serializer.object)
         try:
             self.object = serializer.save(force_insert=True, versioned_object=self.versioned_object)
             if serializer.is_valid():
                 self.post_save(self.object, created=True)
                 headers = self.get_success_headers(serializer.data)
                 version = self.object
                 export_collection.delay(version.id)
                 return Response(serializer.data, status=status.HTTP_201_CREATED,
                                 headers=headers)
         except IntegrityError, e:
             result = {'error': str(e),
                       'detail': 'Collection version  \'%s\' already exist. ' % serializer.data.get('id')}
             return Response(result, status=status.HTTP_409_CONFLICT)