def put(self, request, slug=None):
        """
        Update
        """
        object = get_object_or_404(AssociateContact, member__user__slug=slug)
        self.check_object_permissions(request, object)  # Validate permissions.
        write_serializer = AssociateContactUpdateSerializer(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(geoip2_associate_contact_audit_func, request.tenant,
                          object)

        read_serializer = AssociateRetrieveSerializer(object.member,
                                                      many=False,
                                                      context={
                                                          'request': request,
                                                      })
        return Response(read_serializer.data, status=status.HTTP_200_OK)
Пример #2
0
 def post(self, request, format=None):
     write_serializer = AssociateDemoteOperationSerializer(
         data=request.data, context={'request': request})
     write_serializer.is_valid(raise_exception=True)
     associate = write_serializer.save()
     read_serializer = AssociateRetrieveSerializer(
         associate,
         many=False,
     )
     return Response(read_serializer.data, status=status.HTTP_201_CREATED)
Пример #3
0
 def get(self, request, slug=None):
     """
     Retrieve
     """
     order = get_object_or_404(Associate, user__slug=slug)
     self.check_object_permissions(request, order)  # Validate permissions.
     serializer = AssociateRetrieveSerializer(order,
                                              many=False,
                                              context={
                                                  'request': request,
                                              })
     # queryset = serializer.setup_eager_loading(self, queryset)
     return Response(data=serializer.data, status=status.HTTP_200_OK)
Пример #4
0
 def post(self, request, format=None):
     """
     Create
     """
     post_serializer = AssociateCreateSerializer(data=request.data,
                                                 context={
                                                     'request': request,
                                                 })
     post_serializer.is_valid(raise_exception=True)
     associate = post_serializer.save()
     retrieve_serializer = AssociateRetrieveSerializer(associate,
                                                       many=False)
     return Response(retrieve_serializer.data,
                     status=status.HTTP_201_CREATED)
Пример #5
0
    def post(self, request, format=None):
        write_serializer = AssociateArchiveOperationSerializer(
            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(geoip2_associate_audit_func, request.tenant, object)

        read_serializer = AssociateRetrieveSerializer(object,
                                                      many=False,
                                                      context={
                                                          'request': request,
                                                      })
        return Response(read_serializer.data, status=status.HTTP_200_OK)
 def put(self, request, slug=None):
     """
     Update
     """
     object = get_object_or_404(AssociateContact, member__user__slug=slug)
     self.check_object_permissions(request, object)  # Validate permissions.
     write_serializer = AssociateContactUpdateSerializer(object,
                                                         data=request.data,
                                                         context={
                                                             'request':
                                                             request,
                                                         })
     write_serializer.is_valid(raise_exception=True)
     object = write_serializer.save()
     read_serializer = AssociateRetrieveSerializer(object.member,
                                                   many=False,
                                                   context={
                                                       'request': request,
                                                   })
     return Response(read_serializer.data, status=status.HTTP_200_OK)
Пример #7
0
    def post(self, request, format=None):
        """
        Create
        """
        post_serializer = AssociateCreateSerializer(data=request.data,
                                                    context={
                                                        'request': request,
                                                    })
        post_serializer.is_valid(raise_exception=True)
        associate = post_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_associate_audit_func, request.tenant,
                          associate)
        django_rq.enqueue(geoip2_associate_address_audit_func, request.tenant,
                          associate.address)

        retrieve_serializer = AssociateRetrieveSerializer(associate,
                                                          many=False)
        return Response(retrieve_serializer.data,
                        status=status.HTTP_201_CREATED)