示例#1
0
    def new_comment_by_wb(self, receipt, request):

        store = self.getStore()

        requested_t = WhistleblowerTip(store)
        tip_description = requested_t.get_single(receipt)

        comment_iface = Comment(store)

        comment_stored = comment_iface.new(tip_description['internaltip_id'],
            request['content'], u"whistleblower")

        self.returnData(comment_stored)
        self.returnCode(201)
        return self.prepareRetVals()
示例#2
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()
示例#3
0
    def tip_creation(self):

        store = self.getStore()

        internaltip_iface = InternalTip(store)
        receiver_iface = Receiver(store)

        internal_tip_list = internaltip_iface.get_itips_by_maker(u'new', False)

        if len(internal_tip_list):
            print "TipSched: found %d new Tip" % len(internal_tip_list)

        for internaltip_desc in internal_tip_list:

            # TODO for each itip
            # TODO get file status, or 'continue'

            for receiver_gus in internaltip_desc['receivers']:

                try:
                    receiver_desc = receiver_iface.get_single(receiver_gus)
                except ReceiverGusNotFound:
                    # Log error, a receiver has been removed before get the Tip
                    continue

                # check if the Receiver Tier is the first
                if int(receiver_desc['receiver_level']) != 1:
                    continue

                receivertip_obj = ReceiverTip(store)
                receivertip_desc = receivertip_obj.new(internaltip_desc, receiver_desc)
                print "Created rTip", receivertip_desc['tip_gus'], "for", receiver_desc['name'], \
                    "in", internaltip_desc['context_gus']

            internaltip_iface.flip_mark(internaltip_desc['internaltip_id'], internaltip_iface._marker[1])

        # Escalation is not working at the moment, may be well engineered the function
        # before, permitting various layer of receivers.
        #
        # loops over the InternalTip and checks the escalation threshold
        # It may require the creation of second-step Tips
        escalated_itip_list = internaltip_iface.get_itips_by_maker(internaltip_iface._marker[1], True)

        if len(escalated_itip_list):
            print "TipSched: %d Tip are escalated" % len(escalated_itip_list)

        # This event has to be notified as system Comment
        comment_iface = Comment(store)

        for eitip in escalated_itip_list:
            eitip_id = int(eitip['internaltip_id'])

            comment_iface.new(eitip_id, u"Escalation threshold has been reached", u'system')

            for receiver_gus in eitip['receivers']:

                try:
                    receiver_desc = receiver_iface.get_single(receiver_gus)
                except ReceiverGusNotFound:
                    # Log error, a receiver has been removed before get the Tip
                    continue

                # check if the Receiver Tier is the second
                if int(receiver_desc['receiver_level']) != 2:
                    continue

                receivertip_obj = ReceiverTip(store)
                receivertip_desc = receivertip_obj.new(eitip, receiver_desc)
                print "Created 2nd tir rTip", receivertip_desc['tip_gus'], "for", receiver_desc['name'], \
                    "in", eitip['context_gus']

            internaltip_iface.flip_mark(eitip_id, internaltip_iface._marker[2])