Beispiel #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()
Beispiel #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()
Beispiel #3
0
 def setUpTestData(cls):
     serializer = ImportSerializer(data=import_data)
     serializer.is_valid()
     serializer.save()
Beispiel #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()
Beispiel #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)
Beispiel #6
0
def citizen_list(request, import_id):
    import_instance = get_object_or_404(Import, id=import_id)
    serializer = ImportSerializer(import_instance)
    return Response({'data': serializer.data.get('citizens')})
Beispiel #7
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)