Exemplo n.º 1
0
class IPSTActionFieldsSchema(Interface):
    field_name = schema.Choice(
        title=_(u'Field name'),
        vocabulary=u'imio.project.pst.ActionFieldsVocabulary',
    )

    read_tal_condition = schema.TextLine(
        title=_("Read TAL condition"),
        required=False,
    )

    write_tal_condition = schema.TextLine(
        title=_("Write TAL condition"),
        required=False,
    )
Exemplo n.º 2
0
    def validate(self, value):
        # we call the already defined validators
        super(ManagerFieldValidator, self).validate(value)
        member = api.user.get_current()
        # bypass for Managers
        if member.has_role('Manager'):
            return True

        # if not value:  # covered by min_length
        #     raise Invalid(_(u"You must choose at least one group"))

        member_groups = api.group.get_groups(user=member)
        member_groups_ids = [g.id for g in member_groups]
        if 'pst_editors' in member_groups_ids:
            return True

        member_orgs = organizations_with_suffixes(member_groups, ['actioneditor'])

        # if not Manager, check if the user selected at least one of the groups
        # he is member of or he will not be able to see the element after saving

        def check_intersection():
            for org in value:
                if org in member_orgs:
                    return True
            return False

        if not check_intersection():
            raise Invalid(_(u"You must choose at least one group of which you are a member"))
Exemplo n.º 3
0
 def __call__(self, context):
     voc_inst = ActionEditorsVocabulary()
     voc = voc_inst(context)
     terms = [SimpleTerm(EMPTY_STRING, EMPTY_STRING, _('Empty value'))]
     for term in voc:
         terms.append(term)
     return SimpleVocabulary(terms)
Exemplo n.º 4
0
class IActionLink(ISymlink):
    symbolic_link = RelationChoice(
        title=_(u"Symbolic link"),
        source=ObjPathSourceBinder(
            navigation_tree_query={"portal_type": ("pstaction", )},
            portal_type=("pstaction", ),
            symlink_status=("void", "source")),
        required=True,
    )
Exemplo n.º 5
0
class IBudgetSplitSchema(Interface):
    """"""

    uid = schema.TextLine(
        title=_(u"UID"),
        required=True,
    )

    title = schema.TextLine(
        title=_(u"Title"),
        required=True,
    )

    percentage = schema.Float(
        title=_(u"Percentage"),
        required=True,
        min=0.0,
        max=100.0,
    )
Exemplo n.º 6
0
class IPSTAction(IProject):
    """
        PSTAction schema, field ordering
    """

    representative_responsible = LocalRolesField(
        title=_(u"Representative responsible"),
        description=_(u"Choose principals that will be representative responsible for this project. "
                      u"If nothing choosed, the oo value is used for searches."),
        value_type=schema.Choice(
            vocabulary=u'imio.project.pst.content.operational.representative_responsible_vocabulary',
        ),
        required=False,
    )
    form.widget('representative_responsible', AjaxChosenMultiFieldWidget, populate_select=True)

    responsible = schema.Choice(
        title=_(u'Responsible'),
        vocabulary=u'imio.project.pst.ActionEditorsVocabulary',
        required=False,
    )
    form.widget('responsible', AjaxChosenFieldWidget, populate_select=True)

    health_indicator = schema.Choice(
        title=_(u'Health indicator'),
        # description=_(u"Choose a health level."),
        vocabulary=u'imio.project.pst.content.action.health_indicator_vocabulary',
    )

    health_indicator_details = schema.Text(
        title=_(u'Health indicator_details'),
        # description=_(u"Details concerning the action health."),
        required=False,
    )

    # change label
    form.widget('result_indicator', DataGridFieldFactory, display_table_css_class='listing nosort',
                label=_(u'Realisation indicator'))

    budget_split = schema.List(
        title=_(u"Budget split"),
        required=False,
        value_type=DictRow(
            title=_("Budget split"), schema=IBudgetSplitSchema, required=False
        ),
    )

    @invariant
    def budget_split_total_invariant(data):
        budget_split = getattr(data, 'budget_split', [])
        if budget_split and sum([line.get('percentage') for line in budget_split]) != 100.0:
            raise Invalid(_(u'The sum of all percentages must amount to 100 %.'))
Exemplo n.º 7
0
    def handleAdd(self, action):

        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        self.applyChanges(data)
        IStatusMessage(self.request).addStatusMessage(
            _(u"Budget split saved"),
            "info",
        )
Exemplo n.º 8
0
class IOperationalObjective(IProject):
    """
        OperationalObjective schema, field ordering
    """
    representative_responsible = LocalRolesField(
        title=_(u"Representative responsible"),
        # description=_(u"Choose principals that will be representative responsible for this project."),
        value_type=schema.Choice(
            vocabulary=
            u'imio.project.pst.content.operational.representative_responsible_vocabulary',
        ),
        required=True,
        min_length=1,
    )
    form.widget('representative_responsible',
                AjaxChosenMultiFieldWidget,
                populate_select=True)

    administrative_responsible = LocalRolesField(
        title=_(u"Administrative responsible"),
        # description=_(u"Choose principals that will be administrative responsible for this project."),
        value_type=schema.Choice(
            vocabulary=u'imio.project.core.content.project.manager_vocabulary',
        ),
        required=True,
        min_length=1,
    )
    form.widget('administrative_responsible',
                AjaxChosenMultiFieldWidget,
                populate_select=True)

    manager = LocalRolesField(
        title=_c(u"Manager"),
        # description=_c(u"Choose principals that will manage this project."),
        value_type=schema.Choice(
            vocabulary='imio.project.core.content.project.manager_vocabulary'),
        required=True,
        min_length=1,
    )
    form.widget('manager', AjaxChosenMultiFieldWidget, populate_select=True)
Exemplo n.º 9
0
 def migrate_pst_action_fields(self):
     for brain in self.pc(portal_type="pstaction"):
         action = brain.getObject()
         action.manager = [
             m[:-13] for m in action.manager if m.endswith('_actioneditor')
         ]
         if base_hasattr(action, 'work_plan') and action.work_plan:
             title = translate(_(
                 "Work plan: ${action_title}",
                 mapping={'action_title': safe_unicode(action.Title())}),
                               context=getRequest())
             task = api.content.create(container=action,
                                       title=title,
                                       type='task')
             task.task_description = action.work_plan.raw
Exemplo n.º 10
0
class BudgetSplitForm(EditForm):

    label = _(u"Split action budget")
    fields = Fields(IPSTAction).select('budget_split')
    fields['budget_split'].widgetFactory = DataGridFieldFactory

    def getContent(self):
        if base_hasattr(self.context, 'symbolic_link'):
            return self.context._link
        else:
            return self.context

    @button.buttonAndHandler(PMF('Save'), name='save')
    def handleAdd(self, action):

        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        self.applyChanges(data)
        IStatusMessage(self.request).addStatusMessage(
            _(u"Budget split saved"),
            "info",
        )

    @button.buttonAndHandler(PMF(u'return_to_view'), name='cancel')
    def handleCancel(self, action):
        self.request.response.redirect(self.request.get('URL1'))

    def datagridUpdateWidgets(self, subform, widgets, widget):
        widget.columns[0]['mode'] = HIDDEN_MODE
        widgets['uid'].mode = HIDDEN_MODE

    def updateWidgets(self):
        super(EditForm, self).updateWidgets()
        self.widgets['budget_split'].allow_reorder = False
        self.widgets['budget_split'].allow_insert = False
        self.widgets['budget_split'].allow_delete = False
        self.widgets['budget_split'].auto_append = False
        # Prevent pickling error when auto_append = False
        self.widgets['budget_split'].value = [
            {} if raw == NO_VALUE else raw
            for raw in self.widgets['budget_split'].value
        ]
Exemplo n.º 11
0
class IPSTProjectSpace(IProjectSpace):
    """
        PST Project schema
    """
    strategicobjective_fields = schema.List(
        title=_c(u"${type} fields display",
                 mapping={'type': _('StrategicObjective')}),
        description=_(
            u'Warning ! Completion of these fields requires a good knowledge of the TAL language. '
            u'Be sure to get help from the product support team.'),
        required=False,
        value_type=DictRow(title=_(u'Field'),
                           schema=IStrategicObjectiveFieldsSchema,
                           required=False),
    )
    directives.widget('strategicobjective_fields',
                      DataGridFieldFactory,
                      display_table_css_class='listing',
                      allow_reorder=True,
                      auto_append=False)

    operationalobjective_fields = schema.List(
        title=_c(u"${type} fields display",
                 mapping={'type': _('OperationalObjective')}),
        description=_(
            u'Warning ! Completion of these fields requires a good knowledge of the TAL language. '
            u'Be sure to get help from the product support team.'),
        required=False,
        value_type=DictRow(title=_(u'Field'),
                           schema=IOperationalObjectiveFieldsSchema,
                           required=False),
    )
    directives.widget('operationalobjective_fields',
                      DataGridFieldFactory,
                      display_table_css_class='listing',
                      allow_reorder=True,
                      auto_append=False)

    pstaction_fields = schema.List(
        title=_c(u"${type} fields display", mapping={'type': _('PSTAction')}),
        description=_(
            u'Warning ! Completion of these fields requires a good knowledge of the TAL language. '
            u'Be sure to get help from the product support team.'),
        required=False,
        value_type=DictRow(title=_(u'Field'),
                           schema=IPSTActionFieldsSchema,
                           required=False),
    )
    directives.widget('pstaction_fields',
                      DataGridFieldFactory,
                      display_table_css_class='listing',
                      allow_reorder=True,
                      auto_append=False)

    # this field will be hidden
    pstsubaction_fields = schema.List(
        title=_c(u"${type} fields display",
                 mapping={'type': _('PSTSubAction')}),
        required=False,
        value_type=DictRow(title=_(u'Field'),
                           schema=IPSTActionFieldsSchema,
                           required=False),
    )
    directives.widget('pstsubaction_fields',
                      DataGridFieldFactory,
                      display_table_css_class='listing',
                      allow_reorder=True,
                      auto_append=False)

    strategicobjectives_columns = schema.List(
        title=_(u"StrategicObjective columns"),
        # description=_c(u'Put fields on the right to display it. Flags are : ...'),
        value_type=schema.Choice(
            vocabulary=StrategicObjectivesColumnsVocabulary),
    )

    operationalobjectives_columns = schema.List(
        title=_(u"OperationalObjective columns"),
        # description=_c(u'Put fields on the right to display it. Flags are : ...'),
        value_type=schema.Choice(
            vocabulary=OperationalObjectivesColumnsVocabulary),
    )

    pstactions_columns = schema.List(
        title=_(u"PSTAction columns"),
        #  description=_c(u'Put fields on the right to display it. Flags are : ...'),
        value_type=schema.Choice(vocabulary=PstactionColumnsVocabulary),
    )

    tasks_columns = schema.List(
        title=_(u"Tasks columns"),
        # description=_c(u'Put fields on the right to display it. Flags are : ...'),
        value_type=schema.Choice(vocabulary=TasksColumnsVocabulary),
    )

    strategicobjective_budget_states = schema.List(
        title=_c(u"${type} budget globalization states",
                 mapping={'type': _('StrategicObjective')}),
        description=_c(
            u'Put states on the right for which you want to globalize budget fields.'
        ),
        required=False,
        value_type=schema.Choice(
            vocabulary=u'imio.project.pst.SOReviewStatesVocabulary'),
    )

    operationalobjective_budget_states = schema.List(
        title=_c(u"${type} budget globalization states",
                 mapping={'type': _('OperationalObjective')}),
        # description=_c(u'Put states on the right for which you want to globalize budget fields.'),
        required=False,
        value_type=schema.Choice(
            vocabulary=u'imio.project.pst.OOReviewStatesVocabulary'),
    )

    pstaction_budget_states = schema.List(
        title=_c(u"${type} budget globalization states",
                 mapping={'type': _('PSTAction')}),
        # description=_c(u'Put states on the right for which you want to globalize budget fields.'),
        required=False,
        value_type=schema.Choice(
            vocabulary=u'imio.project.pst.PSTActionReviewStatesVocabulary'),
    )

    # this field will be hidden
    pstsubaction_budget_states = schema.List(
        title=_c(u"${type} budget globalization states",
                 mapping={'type': _('PSTSubAction')}),
        # description=_c(u'Put states on the right for which you want to globalize budget fields.'),
        required=False,
        value_type=schema.Choice(
            vocabulary=u'imio.project.pst.PSTActionReviewStatesVocabulary'),
    )

    directives.omitted('project_fields')
    directives.omitted('project_budget_states')
    # when pstaction_fields modified pstsubaction_fields is updated with his values
    directives.omitted('pstsubaction_fields')
    directives.omitted('pstsubaction_budget_states')

    @invariant
    def validateSettings(data):
        mandatory_check(data, field_constraints)
        position_check(data, field_constraints)
Exemplo n.º 12
0
 def budget_split_total_invariant(data):
     budget_split = getattr(data, 'budget_split', [])
     if budget_split and sum([line.get('percentage') for line in budget_split]) != 100.0:
         raise Invalid(_(u'The sum of all percentages must amount to 100 %.'))