def test_modify_is_allowed_for_admin_on_a_in_progress_task_as_agency(self):
        task = create(Builder('task').having(issuer='hugo.boss').in_progress())

        self.grant('Administrator')
        modifier = IDeadlineModifier(task)
        self.assertFalse(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
Пример #2
0
    def test_modify_is_allowed_for_admin_on_a_in_progress_task_as_agency(self):
        self.login(self.administrator)

        self.set_workflow_state('task-state-in-progress', self.task)

        modifier = IDeadlineModifier(self.task)
        self.assertFalse(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
    def test_modify_is_allowed_for_a_inbox_group_user_when_inbox_is_issuer(self):
        task = create(Builder('task')
                      .having(issuer='inbox:client1', responsible=TEST_USER_ID)
                      .in_progress())

        modifier = IDeadlineModifier(task)
        self.assertTrue(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
    def test_modify_is_allowed_for_admin_on_a_open_task_as_agency(self):
        task = create(Builder('task')
                      .having(issuer='hugo.boss'))

        self.grant('Administrator')
        modifier = IDeadlineModifier(task)
        self.assertFalse(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
    def test_modify_is_allowed_for_issuing_org_unit_agency_member_as_agency(
            self):
        task = create(
            Builder('task').having(issuer=u'hugo.boss').in_progress())

        modifier = IDeadlineModifier(task)
        self.assertFalse(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
    def test_modify_is_allowed_for_issuing_org_unit_agency_member_as_agency(self):
        task = create(Builder('task')
                      .having(issuer=u'hugo.boss')
                      .in_progress())

        modifier = IDeadlineModifier(task)
        self.assertFalse(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
    def test_modify_is_allowed_for_issuing_org_unit_agency_member_as_agency(self):
        self.login(self.secretariat_user)

        self.set_workflow_state('task-state-in-progress', self.task)

        modifier = IDeadlineModifier(self.task)
        self.assertFalse(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
    def test_modify_is_allowed_for_admin_on_a_in_progress_task_as_agency(self):
        self.login(self.administrator)

        self.set_workflow_state('task-state-in-progress', self.task)

        modifier = IDeadlineModifier(self.task)
        self.assertFalse(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
    def test_modify_is_allowed_for_a_inbox_group_user_when_inbox_is_issuer(
            self):
        task = create(
            Builder('task').having(issuer='inbox:client1',
                                   responsible=TEST_USER_ID).in_progress())

        modifier = IDeadlineModifier(task)
        self.assertTrue(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
Пример #10
0
    def test_modify_is_allowed_for_issuing_org_unit_agency_member_as_agency(
            self):
        self.login(self.secretariat_user)

        self.set_workflow_state('task-state-in-progress', self.task)

        modifier = IDeadlineModifier(self.task)
        self.assertFalse(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
    def test_modify_is_allowed_for_a_inbox_group_user_when_inbox_is_issuer(self):
        self.login(self.secretariat_user)
        self.set_workflow_state('task-state-in-progress', self.task)

        self.task.issuer = 'inbox:fa'
        self.task.sync()

        modifier = IDeadlineModifier(self.task)
        self.assertTrue(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
Пример #12
0
    def test_modify_is_allowed_for_a_inbox_group_user_when_inbox_is_issuer(
            self):
        self.login(self.secretariat_user)
        self.set_workflow_state('task-state-in-progress', self.task)

        self.task.issuer = 'inbox:fa'
        self.task.sync()

        modifier = IDeadlineModifier(self.task)
        self.assertTrue(modifier.is_modify_allowed(include_agency=False))
        self.assertTrue(modifier.is_modify_allowed(include_agency=True))
Пример #13
0
    def test_raise_unauthorized_when_mofication_is_not_allowed(self):
        self.login(self.regular_user)

        with self.assertRaises(Unauthorized):
            IDeadlineModifier(self.task).modify_deadline(
                datetime.date(2013, 10, 1), 'changed deadline',
                'task-transition-modify-deadline')
    def test_modify_is_allowed_for_issuer_on_a_in_progress_task(self):
        task = create(
            Builder('task').having(issuer='hugo.boss',
                                   responsible=TEST_USER_ID).in_progress())

        login(self.portal, 'hugo.boss')
        self.assertTrue(IDeadlineModifier(task).is_modify_allowed())
Пример #15
0
    def render(self):
        new_deadline = self.request.get('new_deadline', None)
        new_deadline = date.fromordinal(int(new_deadline))
        text = self.request.get('text', u'')

        IDeadlineModifier(self.context).update_deadline(new_deadline, text)

        return 'OK'
Пример #16
0
    def _update(self, transition, text):
        new_deadline = self.request.get('new_deadline', None)
        new_deadline = date.fromordinal(int(new_deadline))
        text = self.request.get('text', u'')
        transition = self.request.get('transition')

        IDeadlineModifier(self.context).update_deadline(
            new_deadline, text, transition)
    def test_raise_unauthorized_when_mofication_is_not_allowed(self):
        task = create(
            Builder('task').having(issuer='hugo.boss',
                                   deadline=datetime.date(2013, 1, 1)))

        with self.assertRaises(Unauthorized):
            IDeadlineModifier(task).modify_deadline(datetime.date(2013, 10, 1),
                                                    'changed deadline')
Пример #18
0
    def test_deadline_change_synchronisation(self):
        IDeadlineModifier(self.task).modify_deadline(
            date(2016, 03, 29), u'Frist wurde verschoben.',
            u'task-transition-modify-deadline')

        copy = create(Builder('task').in_state('task-state-in-progress'))
        IResponseTransporter(self.task).send_responses(
            'client1', copy.get_physical_path())

        self.assertEquals([{
            u'after': date(2016, 03, 29),
            u'id': u'deadline',
            u'name': u'label_deadline',
            u'before': date(2016, 03, 27)
        }],
                          IResponseContainer(copy)[1].changes)
    def handle_save(self, action):
        data, errors = self.extractData()
        if not errors:
            try:
                validate_deadline_changed(self.context, data.get('new_deadline'))
            except Invalid as err:
                raise WidgetActionExecutionError('new_deadline', err)

            IDeadlineModifier(self.context).modify_deadline(
                data.get('new_deadline'),
                data.get('text'),
                data.get('transition'))

            msg = _(u'msg_deadline_change_successfull',
                    default=u'Deadline successfully changed.')
            IStatusMessage(self.request).addStatusMessage(msg, type='info')

            return self.request.RESPONSE.redirect(self.context.absolute_url())
Пример #20
0
    def handle_save(self, action):
        data, errors = self.extractData()
        if not errors:

            if data.get('new_deadline') == self.context.deadline:
                raise WidgetActionExecutionError(
                    'new_deadline',
                    Invalid(
                        _('same_deadline_error',
                          default=u'The given deadline, is the current one.')))

            IDeadlineModifier(self.context).modify_deadline(
                data.get('new_deadline'), data.get('text'))

            msg = _(u'msg_deadline_change_successfull',
                    default=u'Deadline successfully changed.')
            IStatusMessage(self.request).addStatusMessage(msg, type='info')

            return self.request.RESPONSE.redirect(self.context.absolute_url())
Пример #21
0
 def modify_deadline_guard(self, c, include_agency):
     return IDeadlineModifier(
         self.context).is_modify_allowed(include_agency=include_agency)
    def test_modify_is_allowed_for_issuer_on_a_open_task(self):
        task = create(Builder('task').having(issuer='hugo.boss'))

        login(self.portal, 'hugo.boss')
        self.assertTrue(IDeadlineModifier(task).is_modify_allowed())
Пример #23
0
 def render(self):
     return IDeadlineModifier(self.context).is_modify_allowed()
Пример #24
0
 def after_transition_hook(self, transition, disable_sync, transition_params):
     IDeadlineModifier(self.context).modify_deadline(
         transition_params['new_deadline'], transition_params.get('text'),
         transition)
Пример #25
0
    def test_modify_is_allowed_for_issuer_on_a_in_progress_task(self):
        self.login(self.dossier_responsible)
        self.set_workflow_state('task-state-in-progress', self.task)

        self.assertTrue(IDeadlineModifier(self.task).is_modify_allowed())