def delete_receiver(self, receiver_gus): store = self.getStore() receiver_iface = Receiver(store) receiver_desc = receiver_iface.get_single(receiver_gus) receivertip_iface = ReceiverTip(store) # Remove Tip possessed by the receiver related_tips = receivertip_iface.get_tips_by_receiver(receiver_gus) for tip in related_tips: receivertip_iface.personal_delete(tip['tip_gus']) # Remind: the comment are kept, and the name do not use a reference # but is stored in the comment entry. context_iface = Context(store) # Just an alignment check that need to be removed contexts_associated = context_iface.get_contexts_by_receiver(receiver_gus) print "context associated by receiver POV:", len(contexts_associated),\ "context associated by receiver-DB field:", len(receiver_desc['contexts']) context_iface.align_receiver_delete(receiver_desc['contexts'], receiver_gus) receiverconf_iface = ReceiverConfs(store) receivercfg_list = receiverconf_iface.get_confs_by_receiver(receiver_gus) for rcfg in receivercfg_list: receiverconf_iface.delete(rcfg['config_id'], receiver_gus) # Finally delete the receiver receiver_iface.receiver_delete(receiver_gus) self.returnData(receiver_desc) self.returnCode(200) return self.prepareRetVals()
def delete(self, tip_token, *uriargs): """ Request: None Response: None Errors: ForbiddenOperation, TipGusNotFound When an uber-receiver decide to "total delete" a Tip, is handled by this call. """ try: if not is_receiver_token(tip_token): raise ForbiddenOperation receivertip_iface = ReceiverTip() receivers_map = yield receivertip_iface.get_receivers_by_tip(tip_token) if not receivers_map['actor']['can_delete_submission']: raise ForbiddenOperation # sibilings_tips has the keys: 'sibilings': [$] 'requested': $ sibilings_tips = yield receivertip_iface.get_sibiligs_by_tip(tip_token) # delete all the related tip for sibiltip in sibilings_tips['sibilings']: yield receivertip_iface.personal_delete(sibiltip['tip_gus']) # and the tip of the called yield receivertip_iface.personal_delete(sibilings_tips['requested']['tip_gus']) # extract the internaltip_id, we need for the next operations itip_id = sibilings_tips['requested']['internaltip_id'] file_iface = File() # remove all the files: XXX think if delivery method need to be inquired files_list = yield file_iface.get_files_by_itip(itip_id) print "TODO remove file_list", files_list comment_iface = Comment() # remove all the comments based on a specific itip_id comments_list = yield comment_iface.delete_comment_by_itip(itip_id) internaltip_iface = InternalTip() # finally, delete the internaltip internaltip_iface.tip_delete(sibilings_tips['requested']['internaltip_id']) self.set_status(200) except ForbiddenOperation, e: self.set_status(e.http_status) self.write({'error_message' : e.error_message, 'error_code' : e.error_code})
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})
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 delete_tip(self, tip_gus): store = self.getStore() receivertip_iface = ReceiverTip(store) receivers_map = receivertip_iface.get_receivers_by_tip(tip_gus) if not receivers_map['actor']['can_delete_submission']: raise ForbiddenOperation # sibilings_tips has the keys: 'sibilings': [$] 'requested': $ sibilings_tips = receivertip_iface.get_sibiligs_by_tip(tip_gus) # delete all the related tip for sibiltip in sibilings_tips['sibilings']: receivertip_iface.personal_delete(sibiltip['tip_gus']) # and the tip of the called receivertip_iface.personal_delete(sibilings_tips['requested']['tip_gus']) # extract the internaltip_id, we need for the next operations itip_id = sibilings_tips['requested']['internaltip_id'] # remove all the files: XXX think if delivery method need to be inquired file_iface = File(store) files_list = file_iface.get_files_by_itip(itip_id) # remove all the comments based on a specific itip_id comment_iface = Comment(store) comments_list = comment_iface.delete_comment_by_itip(itip_id) internaltip_iface = InternalTip(store) # finally, delete the internaltip internaltip_iface.tip_delete(sibilings_tips['requested']['internaltip_id']) # XXX Notify Tip removal to the receivers ? # XXX ask to the deleter a comment about the action, notifiy this comment ? self.returnCode(200) return self.prepareRetVals()
def delete(self, receiver_gus, *uriargs): """ Parameter: receiver_gus Request: None Response: None Errors: InvalidInputFormat, ReceiverGusNotFound """ receiver_iface = Receiver() try: # TODO parameter receiver_gus validation - InvalidInputFormat receiver_desc = yield receiver_iface.get_single(receiver_gus) receivertip_iface = ReceiverTip() # Remove Tip possessed by the receiver related_tips = yield receivertip_iface.get_tips_by_receiver(receiver_gus) for tip in related_tips: yield receivertip_iface.personal_delete(tip['tip_gus']) # Remind: the comment are kept, and the name is not referenced but stored # in the comment entry. context_iface = Context() # TODO make an app log contexts_associated = yield context_iface.get_contexts_by_receiver(receiver_gus) print "context associated by receiver POV:", len(contexts_associated),\ "context associated by receiver-DB field:", len(receiver_desc['contexts']) yield context_iface.align_receiver_delete(receiver_desc['contexts'], receiver_gus) receiverconf_iface = ReceiverConfs() # Delete all the receiver configuration associated TODO - App log an number of RCFGs receivercfg_list = yield receiverconf_iface.get_confs_by_receiver(receiver_gus) for rcfg in receivercfg_list: yield receiverconf_iface.delete(rcfg['config_id'], receiver_gus) # Finally delete the receiver yield receiver_iface.receiver_delete(receiver_gus) self.set_status(200) except ReceiverGusNotFound, e: self.set_status(e.http_status) self.write({'error_message': e.error_message, 'error_code' : e.error_code})
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})