Esempio n. 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()
Esempio n. 2
0
 def setUpTestData(cls):
     serializer = ImportSerializer(data=import_data)
     serializer.is_valid()
     serializer.save()
Esempio n. 3
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()
Esempio n. 4
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')})
Esempio n. 5
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)