Ejemplo n.º 1
0
    def put(self, tip_token, *uriargs):
        """
        Request: actorsTipOpsDesc
        Response: actorsTipDesc
        Errors: InvalidTipAuthToken, InvalidInputFormat, ForbiddenOperation

        This interface modify some tip status value. pertinence, personal delete are handled here.
        Total delete operation is handled in this class, by the DELETE HTTP method.
        Those operations (may) trigger a 'system comment' inside of the Tip comment list.
        """

        try:
            request = validateMessage(self.request.body, requests.actorsTipOpsDesc)

            if not is_receiver_token(tip_token):
                raise ForbiddenOperation

            requested_t = ReceiverTip()

            if request['personal_delete']:
                yield requested_t.personal_delete(tip_token)
            if request['is_pertinent']:
                yield requested_t.pertinence_vote(tip_token, request['is_pertinent'])

            self.set_status(200)

        except InvalidInputFormat, e:

            self.set_status(e.http_status)
            self.write({'error_message' : e.error_message, 'error_code' : e.error_code})
Ejemplo n.º 2
0
    def update_tip_by_receiver(self, tip_gus, request):

        store = self.getStore()

        receivertip_iface = ReceiverTip(store)

        if request['personal_delete']:
            receivertip_iface.personal_delete(tip_gus)

        elif request['is_pertinent']:
            # elif is used to avoid the message with both delete+pertinence.
            # This operation is based in ReceiverTip and is returned
            # the sum of the vote expressed. This value is updated in InternalTip
            (itip_id, vote_sum) = receivertip_iface.pertinence_vote(tip_gus, request['is_pertinent'])

            internaltip_iface = InternalTip(store)
            internaltip_iface.update_pertinence(itip_id, vote_sum)

        self.returnCode(200)
        return self.prepareRetVals()
Ejemplo n.º 3
0
    def put(self, tip_token, *uriargs):
        """
        Request: actorsTipOpsDesc
        Response: None
        Errors: InvalidTipAuthToken, InvalidInputFormat, ForbiddenOperation

        This interface modify some tip status value. pertinence, personal delete are handled here.
        Total delete operation is handled in this class, by the DELETE HTTP method.
        Those operations (may) trigger a 'system comment' inside of the Tip comment list.

        This interface return None, because may execute a delete operation. The client
        know which kind of operation has been requested. If a pertinence vote, would
        perform a refresh on get() API, if a delete, would bring the user in other places.
        """

        try:
            request = validateMessage(self.request.body, requests.actorsTipOpsDesc)

            if not is_receiver_token(tip_token):
                raise ForbiddenOperation

            receivertip_iface = ReceiverTip()

            if request['personal_delete']:
                yield receivertip_iface.personal_delete(tip_token)

            elif request['is_pertinent']:
                # elif is used to avoid the message with both delete+pertinence.
                # This operation is based in ReceiverTip and is returned
                # the sum of the vote expressed. This value is updated in InternalTip
                (itip_id, vote_sum) = yield receivertip_iface.pertinence_vote(tip_token, request['is_pertinent'])

                internaltip_iface = InternalTip()
                yield internaltip_iface.update_pertinence(itip_id, vote_sum)

            self.set_status(200)

        except InvalidInputFormat, e:

            self.set_status(e.http_status)
            self.write({'error_message' : e.error_message, 'error_code' : e.error_code})