Ejemplo n.º 1
0
    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})
Ejemplo n.º 2
0
    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()