Beispiel #1
0
    def create_response(self, text):
        response_handler = ICommentResponseHandler(self.context)
        if not response_handler.is_allowed():
            raise Unauthorized(
                "The current user is not allowed to add comments")

        return response_handler.add_response(text)
Beispiel #2
0
    def test_add_response_creates_a_task_commented_activity_record(self):
        dossier = create(Builder('dossier'))
        task = create(Builder('task').within(dossier))

        ICommentResponseHandler(task).add_response("My response")

        activity = Activity.query.order_by(desc(Activity.id)).first()
        self.assertEquals('task-commented', activity.kind)
Beispiel #3
0
    def test_add_response_appends_a_new_response_obj_to_the_context_response_container(
            self):
        dossier = create(Builder('dossier'))
        task = create(Builder('task').within(dossier))

        response_container = IResponseContainer(task)

        self.assertEqual(0, len(response_container))
        ICommentResponseHandler(task).add_response("My response")
        self.assertEqual(1, len(response_container))
Beispiel #4
0
 def _append_additional_menu_items(self, regular_items, agency_items):
     if ICommentResponseHandler(self.context).is_allowed():
         regular_items.append({
             'title':
             'label_add_comment',
             'url':
             '{}/@@addcommentresponse'.format(self.context.absolute_url()),
             'response_description':
             ResponseDescription.get(transition='task-commented')
         })
Beispiel #5
0
    def test_a_Editor_can_add_task_comment_on_open_dossier(self):
        create(
            Builder('user').having(
                firstname='Hugo',
                lastname='Boss').with_roles('Editor').with_userid('hugo.boss'))

        dossier = create(Builder('dossier'))
        task = create(Builder('task').within(dossier))

        self.login('hugo.boss')

        self.assertTrue(ICommentResponseHandler(task).is_allowed())
Beispiel #6
0
    def test_comment_is_not_synced_to_forwarding_predecessor(self):
        predecessor = create(Builder('forwarding'))
        successor = create(Builder('task').successor_from(predecessor))

        activate_request_layer(self.portal.REQUEST,
                               IInternalOpengeverRequestLayer)

        response_container = IResponseContainer(predecessor)

        self.assertEqual(0, len(response_container))
        ICommentResponseHandler(successor).add_response("My response")
        self.assertEqual(0, len(response_container))
Beispiel #7
0
    def test_a_Manager_can_not_add_task_comment_on_closed_dossier(self):
        create(
            Builder('user').having(firstname='Hugo',
                                   lastname='Boss').with_roles(
                                       'Manager').with_userid('hugo.boss'))

        dossier = create(Builder('dossier').in_state('dossier-state-resolved'))
        task = create(Builder('task').within(dossier))

        self.login('hugo.boss')

        self.assertFalse(ICommentResponseHandler(task).is_allowed())
Beispiel #8
0
    def test_commenting_is_disallowed_for_tasks_within_a_closed_dossier(self):
        dossier = create(Builder('dossier').in_state('dossier-state-resolved'))
        task = create(Builder('task').within(dossier))

        self.assertFalse(ICommentResponseHandler(task).is_allowed())
Beispiel #9
0
 def createAndAdd(self, data):
     response_handler = ICommentResponseHandler(self.context)
     return response_handler.add_response(data.get('text'))
Beispiel #10
0
 def createAndAdd(self, data):
     response_handler = ICommentResponseHandler(self.context)
     return response_handler.add_response(data.get('text'))