예제 #1
0
    def get(self, tip_token, *uriargs):
        """
        Parameters: None
        Response: actorsTipDesc
        Errors: InvalidTipAuthToken

        tip_token can be: a tip_gus for a receiver, or a WhistleBlower receipt, understand
        the format, help in addressing which kind of Tip need to be handled.
        """

        try:
            if is_receiver_token(tip_token):
                requested_t = ReceiverTip()
                tip_description = yield requested_t.get_single(tip_token)
            else:
                requested_t = WhistleblowerTip()
                tip_description = yield requested_t.get_single(tip_token)

            # TODO output filtering: actorsTipDesc
            self.set_status(200)
            self.write(json.dumps(tip_description))

        except TipGusNotFound, e:

            self.set_status(e.http_status)
            self.write({'error_message' : e.error_message, 'error_code' : e.error_code})
예제 #2
0
    def post(self, tip_token, *uriargs):
        """
        Request: actorsCommentDesc
        Response: actorsCommentDesc
        Errors: InvalidTipAuthToken, InvalidInputFormat, TipGusNotFound, TipReceiptNotFound
        """

        comment_iface = Comment()

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

            if is_receiver_token(tip_token):

                requested_t = ReceiverTip()

                tip_description = yield requested_t.get_single(tip_token)
                comment_stored = yield comment_iface.add_comment(tip_description['internaltip_id'],
                    request['content'], u"receiver", tip_description['receiver_gus'])

            else:
                requested_t = WhistleblowerTip()

                tip_description = yield requested_t.get_single(tip_token)
                comment_stored = yield comment_iface.add_comment(tip_description['internaltip_id'],
                    request['content'], u"whistleblower")

            self.set_status(200)
            self.write(json.dumps(comment_stored))

        except TipGusNotFound, e:

            self.set_status(e.http_status)
            self.write({'error_message' : e.error_message, 'error_code' : e.error_code})
예제 #3
0
    def get(self, tip_token, *uriargs):
        """
        Parameters: None
        Response: actorsReceiverList
        Errors: InvalidTipAuthToken
        """

        try:
            if is_receiver_token(tip_token):

                requested_t = ReceiverTip()
                tip_description = yield requested_t.get_single(tip_token)

            else:

                requested_t = WhistleblowerTip()
                tip_description = yield requested_t.get_single(tip_token)

            itip_iface = InternalTip()

            inforet = yield itip_iface.get_receivers_by_itip(tip_description['internaltip_id'])

            self.write(json.dumps(inforet))
            self.set_status(200)

        except TipGusNotFound, e:

            self.set_status(e.http_status)
            self.write({'error_message' : e.error_message, 'error_code' : e.error_code})
예제 #4
0
    def get(self, tip_token, *uriargs):
        """
        Parameters: None (TODO start/end, date)
        Response: actorsCommentList
        Errors: InvalidTipAuthToken
        """

        try:

            if is_receiver_token(tip_token):
                requested_t = ReceiverTip()
                tip_description = yield requested_t.get_single(tip_token)
            else:
                requested_t = WhistleblowerTip()
                tip_description = yield requested_t.get_single(tip_token)

            comment_iface = Comment()
            comment_list = yield comment_iface.get_comment_by_itip(tip_description['internaltip_id'])

            self.set_status(200)
            self.write(json.dumps(comment_list))

        except TipGusNotFound, e:

            self.set_status(e.http_status)
            self.write({'error_message' : e.error_message, 'error_code' : e.error_code})
예제 #5
0
    def get_tip_by_receiver(self, tip_gus):

        requested_t = ReceiverTip(self.getStore())
        tip_description = requested_t.get_single(tip_gus)

        self.returnData(tip_description)
        self.returnCode(200)
        return self.prepareRetVals()
예제 #6
0
    def get_receiver_list_by_receiver(self, tip_gus):

        store = self.getStore()

        requested_t = ReceiverTip(store)
        tip_description = requested_t.get_single(tip_gus)

        itip_iface = InternalTip(store)
        inforet = itip_iface.get_receivers_by_itip(tip_description['internaltip_id'])

        self.returnData(inforet)
        self.returnCode(200)
        return self.prepareRetVals()
예제 #7
0
    def get_comment_list_by_receiver(self, tip_gus):

        store = self.getStore()

        requested_t = ReceiverTip(store)
        tip_description = requested_t.get_single(tip_gus)

        comment_iface = Comment(store)
        comment_list = comment_iface.get_comment_by_itip(tip_description['internaltip_id'])

        self.returnData(comment_list)
        self.returnCode(200)
        return self.prepareRetVals()
예제 #8
0
    def new_comment_by_receiver(self, tip_gus, request):

        store = self.getStore()

        requested_t = ReceiverTip(store)
        tip_description = requested_t.get_single(tip_gus)

        comment_iface = Comment(store)

        comment_stored = comment_iface.new(tip_description['internaltip_id'],
            request['content'], u"receiver", tip_description['receiver_gus'])
        # XXX here can be put the name of the Receiver

        self.returnData(comment_stored)
        self.returnCode(201)
        return self.prepareRetVals()