def put(self, request, slug=None):
        """
        Update
        """
        object = get_object_or_404(StaffAddress, member__user__slug=slug)
        self.check_object_permissions(request, object)  # Validate permissions.
        write_serializer = StaffAddressUpdateSerializer(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_staff_address_func,
                          request.tenant.schema_name, slug)
        django_rq.enqueue(geoip2_staff_address_audit_func, request.tenant,
                          object)

        read_serializer = StaffRetrieveSerializer(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 = StaffDemoteOperationSerializer(
         data=request.data, context={'request': request})
     write_serializer.is_valid(raise_exception=True)
     staff = write_serializer.save()
     read_serializer = StaffRetrieveSerializer(
         staff,
         many=False,
     )
     return Response(read_serializer.data, status=status.HTTP_201_CREATED)
예제 #3
0
 def put(self, request, slug=None):
     """
     Update
     """
     object = get_object_or_404(StaffContact, member__user__slug=slug)
     self.check_object_permissions(request, object)  # Validate permissions.
     write_serializer = StaffContactUpdateSerializer(object, data=request.data, context={'request': request,})
     write_serializer.is_valid(raise_exception=True)
     object = write_serializer.save()
     read_serializer = StaffRetrieveSerializer(object.member, many=False, context={'request': request,})
     return Response(read_serializer.data, status=status.HTTP_200_OK)
예제 #4
0
 def post(self, request, format=None):
     """
     Create
     """
     post_serializer = StaffCreateSerializer(
         data=request.data,
         context={'request': request,
     });
     post_serializer.is_valid(raise_exception=True)
     staff = post_serializer.save()
     retrieve_serializer = StaffRetrieveSerializer(staff, many=False)
     return Response(retrieve_serializer.data, status=status.HTTP_201_CREATED)
예제 #5
0
 def get(self, request, slug=None):
     """
     Retrieve
     """
     order = get_object_or_404(Staff, user__slug=slug)
     self.check_object_permissions(request, order)  # Validate permissions.
     serializer = StaffRetrieveSerializer(order,
                                          many=False,
                                          context={
                                              'request': request,
                                          })
     # queryset = serializer.setup_eager_loading(self, queryset)
     return Response(data=serializer.data, status=status.HTTP_200_OK)
예제 #6
0
    def post(self, request, format=None):
        serializer = StaffArchiveOperationSerializer(
            data=request.data,
            context={
                'request': request
            }
        )
        serializer.is_valid(raise_exception=True)
        staff = 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_staff_audit_func, request.tenant, staff)

        read_serializer = StaffRetrieveSerializer(staff, many=False,)
        return Response(read_serializer.data, status=status.HTTP_200_OK)
예제 #7
0
    def post(self, request, format=None):
        """
        Create
        """
        post_serializer = StaffCreateSerializer(data=request.data,
                                                context={
                                                    'request': request,
                                                })
        post_serializer.is_valid(raise_exception=True)
        staff = 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_staff_audit_func, request.tenant, staff)
        django_rq.enqueue(geoip2_staff_address_audit_func, request.tenant,
                          staff.address)

        retrieve_serializer = StaffRetrieveSerializer(staff, many=False)
        return Response(retrieve_serializer.data,
                        status=status.HTTP_201_CREATED)