Ejemplo n.º 1
0
    def create(self, request, project, jm):
        """
        POST method implementation
        """
        jm.insert_job_note(
            int(request.DATA['job_id']),
            int(request.DATA['failure_classification_id']),
            request.DATA['who'],
            request.DATA.get('note', '')
        )

        publisher = JobClassificationPublisher(settings.BROKER_URL)
        try:
            publisher.publish(int(request.DATA['job_id']),
                              request.DATA['who'], project)
        finally:
            publisher.disconnect()

        # refresh unclassified failure count and publish the socket event
        unclassified_failure_count(projects=[project])

        return Response(
            {'message': 'note stored for job {0}'.format(
                request.DATA['job_id']
            )}
        )
Ejemplo n.º 2
0
    def create(self, request, project, jm):
        """
        POST method implementation
        """
        jm.insert_job_note(
            int(request.DATA['job_id']),
            int(request.DATA['failure_classification_id']),
            request.user.email,
            request.DATA.get('note', '')
        )

        publisher = JobClassificationPublisher(settings.BROKER_URL)
        try:
            publisher.publish(int(request.DATA['job_id']),
                              request.DATA['who'], project)
        finally:
            publisher.disconnect()

        # refresh unclassified failure count and publish the socket event
        unclassified_failure_count(projects=[project])

        return Response(
            {'message': 'note stored for job {0}'.format(
                request.DATA['job_id']
            )}
        )
Ejemplo n.º 3
0
    def destroy(self, request, project, jm, pk=None):
        """
        Delete a note entry
        """
        objs = jm.get_job_note(pk)
        if objs:
            jm.delete_job_note(pk, objs[0]['job_id'])
            publisher = JobClassificationPublisher(settings.BROKER_URL)
            try:
                publisher.publish(objs[0]['job_id'], objs[0]['who'], project)
            finally:
                publisher.disconnect()
            return Response({"message": "Note deleted"})

        else:
            return Response("No note with id: {0}".format(pk), 404)
Ejemplo n.º 4
0
    def destroy(self, request, project, jm, pk=None):
        """
        Delete a note entry
        """
        objs = jm.get_job_note(pk)
        if objs:
            jm.delete_job_note(pk, objs[0]['job_id'])
            publisher = JobClassificationPublisher(settings.BROKER_URL)
            try:
                publisher.publish(objs[0]['job_id'], objs[0]['who'], project)
            finally:
                publisher.disconnect()
            return Response({"message": "Note deleted"})

        else:
            return Response("No note with id: {0}".format(pk), 404)