def put(self, request, slug=None):
        """
        Update
        """
        object = get_object_or_404(AreaCoordinatorAddress,
                                   member__user__slug=slug)
        self.check_object_permissions(request, object)  # Validate permissions.
        write_serializer = AreaCoordinatorAddressUpdateSerializer(
            object, data=request.data, context={
                'request': request,
            })
        write_serializer.is_valid(raise_exception=True)
        object = write_serializer.save()

        # Run the following functions in the background so our API performance
        # would not be impacted with not-import computations.
        django_rq.enqueue(geocode_area_coordinator_address_func,
                          request.tenant.schema_name, slug)
        django_rq.enqueue(geoip2_area_coordinator_address_audit_func,
                          request.tenant, object)

        read_serializer = AreaCoordinatorRetrieveSerializer(object.member,
                                                            many=False,
                                                            context={
                                                                'request':
                                                                request,
                                                            })
        return Response(read_serializer.data, status=status.HTTP_200_OK)
 def post(self, request, format=None):
     write_serializer = AreaCoordinatorDemoteOperationSerializer(
         data=request.data, context={'request': request})
     write_serializer.is_valid(raise_exception=True)
     area_coordinator = write_serializer.save()
     read_serializer = AreaCoordinatorRetrieveSerializer(
         area_coordinator,
         many=False,
     )
     return Response(read_serializer.data, status=status.HTTP_201_CREATED)
Exemple #3
0
 def put(self, request, slug=None):
     """
     Update
     """
     object = get_object_or_404(AreaCoordinatorContact, member__user__slug=slug)
     self.check_object_permissions(request, object)  # Validate permissions.
     write_serializer = AreaCoordinatorContactUpdateSerializer(object, data=request.data, context={'request': request,})
     write_serializer.is_valid(raise_exception=True)
     object = write_serializer.save()
     read_serializer = AreaCoordinatorRetrieveSerializer(object.member, many=False, context={'request': request,})
     return Response(read_serializer.data, status=status.HTTP_200_OK)
 def get(self, request, slug=None):
     """
     Retrieve
     """
     order = get_object_or_404(AreaCoordinator, user__slug=slug)
     self.check_object_permissions(request, order)  # Validate permissions.
     serializer = AreaCoordinatorRetrieveSerializer(order,
                                                    many=False,
                                                    context={
                                                        'request': request,
                                                    })
     # queryset = serializer.setup_eager_loading(self, queryset)
     return Response(data=serializer.data, status=status.HTTP_200_OK)
 def post(self, request, format=None):
     """
     Create
     """
     post_serializer = AreaCoordinatorCreateSerializer(data=request.data,
                                                       context={
                                                           'request':
                                                           request,
                                                       })
     post_serializer.is_valid(raise_exception=True)
     area_coordinator = post_serializer.save()
     retrieve_serializer = AreaCoordinatorRetrieveSerializer(
         area_coordinator, many=False)
     return Response(retrieve_serializer.data,
                     status=status.HTTP_201_CREATED)
Exemple #6
0
    def post(self, request, format=None):
        write_serializer = AreaCoordinatorPromoteOperationSerializer(
            data=request.data, context={'request': request})
        write_serializer.is_valid(raise_exception=True)
        area_coordinator = write_serializer.save()

        # Run the following functions in the background so our API performance
        # would not be impacted with not-import computations.
        django_rq.enqueue(geoip2_area_coordinator_address_audit_func,
                          request.tenant, area_coordinator)

        read_serializer = AreaCoordinatorRetrieveSerializer(
            area_coordinator,
            many=False,
        )
        return Response(read_serializer.data, status=status.HTTP_201_CREATED)
    def post(self, request, format=None):
        serializer = AreaCoordinatorArchiveOperationSerializer(
            data=request.data, context={'request': request})
        serializer.is_valid(raise_exception=True)
        object = serializer.save()

        # Run the following functions in the background so our API performance
        # would not be impacted with not-import computations.
        django_rq.enqueue(geoip2_area_coordinator_audit_func, request.tenant,
                          object)

        read_serializer = AreaCoordinatorRetrieveSerializer(object,
                                                            many=False,
                                                            context={
                                                                'request':
                                                                request,
                                                            })
        return Response(read_serializer.data, status=status.HTTP_200_OK)