Exemple #1
0
    def createAndAdd(self, data):
        created = []

        # make sure we don't create private tasks when the feature is
        # not enabled. the field is hidden, but users could still submit.
        if not is_private_task_feature_enabled():
            data['is_private'] = False

        if isinstance(data['responsible'], basestring):
            data['responsible'] = [data['responsible']]

        all_responsible_users = data['responsible']
        for responsible in all_responsible_users:
            data['responsible'] = responsible
            update_reponsible_field_data(data)
            created.append(self._create_task(data))

        # Restore responsible in data
        data['responsible'] = all_responsible_users

        # Set tasktemplate order and move to planned state if it's part
        # of a sequential process
        if ITask.providedBy(
                self.context) and self.context.is_sequential_main_task():
            position = data['tasktemplate_position']
            if not position:
                position = len(self.context.get_tasktemplate_order())

            for task in created:
                self.context.add_task_to_tasktemplate_order(position, task)

        self._set_immediate_view(created)
        return created
Exemple #2
0
    def createAndAdd(self, data):
        created = []

        # make sure we don't create private tasks when the feature is
        # not enabled. the field is hidden, but users could still submit.
        if not is_private_task_feature_enabled():
            data['is_private'] = False

        if isinstance(data['responsible'], basestring):
            data['responsible'] = [data['responsible']]

        all_responsible_users = data['responsible']
        for responsible in all_responsible_users:
            data['responsible'] = responsible
            update_reponsible_field_data(data)
            created.append(self._create_task(data))

        # Restore responsible in data
        data['responsible'] = all_responsible_users

        # Set tasktemplate order and move to planned state if it's part
        # of a sequential process
        if IFromSequentialTasktemplate.providedBy(self.context):
            position = data['tasktemplate_position']
            if not position:
                position = len(self.context.get_tasktemplate_order())

            for task in created:
                self.context.add_task_to_tasktemplate_order(position, task)

        self._set_immediate_view(created)
        return created
Exemple #3
0
    def private_task_is_not_changed_when_disabled(data):
        if not is_private_task_feature_enabled() and data.is_private:

            # Because the z3c.form.validator.Data object has implemented a
            # getattr fallback, which fetches the value from the context, we
            # need to check if the is_private value was part of the input-data.
            if 'is_private' in data._Data_data___:
                raise Invalid(_(u'error_private_task_feature_is_disabled',
                                default=u'The private task feature is disabled'))
Exemple #4
0
    def private_task_is_not_changed_when_disabled(data):
        if not is_private_task_feature_enabled() and data.is_private:

            # Because the z3c.form.validator.Data object has implemented a
            # getattr fallback, which fetches the value from the context, we
            # need to check if the is_private value was part of the input-data.
            if 'is_private' in data._Data_data___:
                raise Invalid(_(u'error_private_task_feature_is_disabled',
                                default=u'The private task feature is disabled'))
Exemple #5
0
def hide_feature_flagged_fields(groups):
    if not is_private_task_feature_enabled():
        common_group = next(group for group in groups
                            if group.__name__ == u'common')
        common_group.fields = common_group.fields.omit('is_private')

    if not is_optional_task_permissions_revoking_enabled():
        common_group = next(group for group in groups
                            if group.__name__ == u'common')
        common_group.fields = common_group.fields.omit('revoke_permissions')
Exemple #6
0
def hide_feature_flagged_fields(groups):
    if not is_private_task_feature_enabled():
        common_group = next(
            group for group in groups if group.__name__ == u'common')
        common_group.fields = common_group.fields.omit('is_private')

    if not is_optional_task_permissions_revoking_enabled():
        common_group = next(
            group for group in groups if group.__name__ == u'common')
        common_group.fields = common_group.fields.omit('revoke_permissions')
 def test_feature_is_deactivated(self):
     self.assertFalse(is_private_task_feature_enabled())
 def test_feature_is_activated_by_default(self):
     self.assertTrue(is_private_task_feature_enabled())
 def test_feature_is_deactivated(self):
     self.assertFalse(is_private_task_feature_enabled())
 def test_feature_is_activated_by_default(self):
     self.assertTrue(is_private_task_feature_enabled())