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()
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})