Пример #1
0
 def post(self, request):
     serializer = ImportSerializer(data=request.data, context={'request': request})
     serializer.is_valid(raise_exception=True)
     data = serializer.validated_data
     if 'errors' in data:
         return Response(data={'errors': data['errors']}, status=BAD_REQUEST)
     return Response()
Пример #2
0
 def post(self, request):
     serializer = ImportSerializer(data=request.data,
                                   context={'request': request})
     serializer.is_valid(raise_exception=True)
     data = serializer.validated_data
     if 'errors' in data:
         return Response(data={'errors': data['errors']},
                         status=BAD_REQUEST)
     return Response()
Пример #3
0
 def setUpTestData(cls):
     serializer = ImportSerializer(data=import_data)
     serializer.is_valid()
     serializer.save()
Пример #4
0
    def setUpTestData(cls):
        cls.url = reverse('citizen', kwargs={'import_id': 1, 'citizen_id': 1})

        serializer = ImportSerializer(data=import_data)
        serializer.is_valid()
        serializer.save()
Пример #5
0
def import_from_url(request):
    ser = ImportSerializer(data=request.data, context=dict(user=request.user))
    if ser.is_valid(raise_exception=True):
        ser.save()
        return Response(ser.validated_data, status=status.HTTP_201_CREATED)
Пример #6
0
def import_list(request):
    serializer = ImportSerializer(data=request.data)
    serializer.is_valid(raise_exception=True)
    import_instance = serializer.save()
    return Response({'data': {'import_id': import_instance.id}}, status=status.HTTP_201_CREATED)