Exemplo n.º 1
0
def get_admin_project_type_schema():
    schema = SQLAlchemySchemaNode(ProjectType, includes=("label", ))
    customize_field(
        schema,
        "label",
        validator=get_deferred_unique_label_validator(ProjectType),
    )
    return schema
Exemplo n.º 2
0
def get_admin_file_type_schema():
    """
    Build a schéma to administrate file types

    :rtype: :class:`colanderalchemy.SQLAlchemySchemaNode`
    """
    schema = SQLAlchemySchemaNode(FileType, includes=('label', ))
    customize_field(schema, 'label', title=u"Libellé")
    return schema
Exemplo n.º 3
0
def get_admin_file_type_schema():
    """
    Build a schéma to administrate file types

    :rtype: :class:`colanderalchemy.SQLAlchemySchemaNode`
    """
    schema = SQLAlchemySchemaNode(FileType, includes=('label',))
    customize_field(schema, 'label', title=u"Libellé")
    return schema
Exemplo n.º 4
0
def get_business_edit_schema():
    """
    Build the businedd edition schema

    :rtype: :class:`colander.Schema`
    """
    schema = SQLAlchemySchemaNode(Business, includes=('name', ))
    customize_field(schema, 'name', title=u"Nom de l'affaire")
    return schema
Exemplo n.º 5
0
def get_admin_project_type_schema():
    schema = SQLAlchemySchemaNode(
        ProjectType,
        includes=("label",)
    )
    customize_field(
        schema,
        "label",
        validator=get_deferred_unique_label_validator(ProjectType),
    )
    return schema
Exemplo n.º 6
0
def get_business_edit_schema():
    """
    Build the businedd edition schema

    :rtype: :class:`colander.Schema`
    """
    schema = SQLAlchemySchemaNode(
        Business,
        includes=('name',)
    )
    customize_field(schema, 'name', title=u"Nom de l'affaire")
    return schema
Exemplo n.º 7
0
def get_add_edit_line_schema(factory):
    """
    Build a schema for expense line

    :param class model: The model for which we want to generate the schema
    :rerturns: A SQLAlchemySchemaNode schema
    """
    excludes = ('sheet_id',)
    schema = SQLAlchemySchemaNode(factory, excludes=excludes)

    if factory == ExpenseLine:
        forms.customize_field(
            schema,
            'type_id',
            validator=forms.get_deferred_select_validator(
                ExpenseType,
                filters=[('type', 'expense')]
            ),
            missing=colander.required,
        )
    elif factory == ExpenseKmLine:
        forms.customize_field(
            schema,
            'type_id',
            validator=forms.get_deferred_select_validator(
                ExpenseKmType,
                filters=[('year', datetime.date.today().year)]
            ),
            missing=colander.required,
        )

    forms.customize_field(
        schema,
        'ht',
        typ=AmountType(2),
        missing=colander.required,
    )
    forms.customize_field(
        schema,
        'tva',
        typ=AmountType(2),
        missing=colander.required,
    )
    forms.customize_field(
        schema,
        'km',
        typ=AmountType(2),
        missing=colander.required,
    )
    return schema
Exemplo n.º 8
0
def get_add_edit_line_schema(factory):
    """
    Build a schema for expense line

    :param class model: The model for which we want to generate the schema
    :rerturns: A SQLAlchemySchemaNode schema
    """
    excludes = ('sheet_id', )
    schema = SQLAlchemySchemaNode(factory, excludes=excludes)

    if factory == ExpenseLine:
        forms.customize_field(
            schema,
            'type_id',
            validator=forms.get_deferred_select_validator(ExpenseType,
                                                          filters=[('type',
                                                                    'expense')
                                                                   ]),
            missing=colander.required,
        )
    elif factory == ExpenseKmLine:
        forms.customize_field(
            schema,
            'type_id',
            validator=forms.get_deferred_select_validator(
                ExpenseKmType, filters=[('year', datetime.date.today().year)]),
            missing=colander.required,
        )

    forms.customize_field(
        schema,
        'ht',
        typ=AmountType(2),
        missing=colander.required,
    )
    forms.customize_field(
        schema,
        'tva',
        typ=AmountType(2),
        missing=colander.required,
    )
    forms.customize_field(
        schema,
        'km',
        typ=AmountType(2),
        missing=colander.required,
    )
    return schema
Exemplo n.º 9
0
def get_admin_business_type_schema():
    schema = SQLAlchemySchemaNode(
        BusinessType,
        includes=(
            'label', 'project_type_id', 'other_project_types'
        )
    )
    customize_field(
        schema,
        "label",
        validator=get_deferred_unique_label_validator(BusinessType),
    )
    customize_field(
        schema,
        'project_type_id',
        widget=get_deferred_model_select(ProjectType),
        validator=get_deferred_unique_project_type_default
    )
    customize_field(
        schema,
        'other_project_types',
        children=get_sequence_child_item(ProjectType),
        widget=get_deferred_model_select_checkbox(
            ProjectType,
            filters=[['active', True]],
        )
    )

    return schema
Exemplo n.º 10
0
def _get_business_type_task_mention_schema():
    """
    Build a schema for BusinessTypeTaskMention configuration

    :rtype: :class:`colanderalchemy.SQLAlchemySchemaNode`
    """
    schema = SQLAlchemySchemaNode(
        BusinessTypeTaskMention,
        includes=('task_mention_id', 'business_type_id', 'doctype',
                  'mandatory'),
    )
    customize_field(schema,
                    'doctype',
                    validator=colander.OneOf(
                        ('invoice', 'cancelinvoice', 'estimation')))
    customize_field(
        schema,
        'mandatory',
        typ=colander.String(),
        validator=colander.OneOf(('true', 'false'), ),
        missing=colander.drop,
    )
    return schema
Exemplo n.º 11
0
def _get_business_type_file_type_schema():
    """
    Build a schema for BusinessTypeFileType configuration

    :rtype: :class:`colanderalchemy.SQLAlchemySchemaNode`
    """
    schema = SQLAlchemySchemaNode(
        BusinessTypeFileType,
        includes=(
            'file_type_id', 'business_type_id', 'doctype', 'requirement_type',
            'validation',
        ),
    )
    customize_field(
        schema,
        'doctype',
        validator=colander.OneOf(
            ('invoice', 'cancelinvoice', 'estimation', 'business')
        )
    )
    customize_field(
        schema,
        'requirement_type',
        typ=colander.String(12),
        validator=colander.OneOf(
            (
                'business_mandatory',
                'project_mandatory',
                'mandatory',
                'recommended',
                'optionnal'
            ),
        ),
        missing=colander.drop,
    )
    customize_field(
        schema,
        'validation',
        typ=colander.String(),
        validator=colander.OneOf(
            ('on',),
        ),
        missing=colander.drop,
    )
    return schema
Exemplo n.º 12
0
def get_admin_business_type_schema():
    schema = SQLAlchemySchemaNode(BusinessType,
                                  includes=('label', 'project_type_id',
                                            'other_project_types'))
    customize_field(
        schema,
        "label",
        validator=get_deferred_unique_label_validator(BusinessType),
    )
    customize_field(schema,
                    'project_type_id',
                    widget=get_deferred_model_select(ProjectType),
                    validator=get_deferred_unique_project_type_default)
    customize_field(schema,
                    'other_project_types',
                    children=get_sequence_child_item(ProjectType),
                    widget=get_deferred_model_select_checkbox(
                        ProjectType,
                        filters=[['active', True]],
                    ))

    return schema
Exemplo n.º 13
0
def get_admin_task_mention_schema():
    """
    Build the task mentions admin schema
    """
    schema = SQLAlchemySchemaNode(
        TaskMention,
        includes=(
            "label", "help_text", "title", "full_text", "order",
        )
    )
    customize_field(
        schema,
        "label",
        title=u"Libellé",
        description=u"Libellé utilisé dans l'interface",
    )
    customize_field(
        schema,
        "full_text",
        widget=deform.widget.TextAreaWidget(cols=80, rows=4),
    )
    customize_field(schema, "order", widget=deform.widget.HiddenWidget())
    return schema
Exemplo n.º 14
0
def customize_schema(schema):
    """
    Customize the form schema
    :param obj schema: A UserDatas schema
    """
    customize = functools.partial(customize_field, schema)

    customize(
        'situation_antenne_id',
        get_deferred_select(AntenneOption)
    )

    customize(
        'situation_follower_id',
        get_deferred_user_choice(
            roles=['admin', 'manager'],
            widget_options={
                'default_option': ('', ''),
            }
        )
    )

    customize(
        'coordonnees_civilite',
        get_select(CIVILITE_OPTIONS)
    )

    customize('coordonnees_email1', validator=mail_validator())
    customize('coordonnees_email2', validator=mail_validator())

    customize(
        'coordonnees_address',
        deform.widget.TextAreaWidget(),
    )

    customize(
        "coordonnees_zone_id",
        get_deferred_select(ZoneOption),
    )

    customize(
        "coordonnees_zone_qual_id",
        get_deferred_select(ZoneQualificationOption),
    )

    customize(
        "coordonnees_sex",
        get_select(SEX_OPTIONS),
        get_select_validator(SEX_OPTIONS)
    )

    customize(
        "coordonnees_birthplace",
        deform.widget.TextAreaWidget(),
    )

    customize(
        "coordonnees_family_status",
        get_select(STATUS_OPTIONS),
        get_select_validator(STATUS_OPTIONS),
    )

    customize(
        "coordonnees_children",
        get_select(zip(range(20), range(20)))
    )

    customize(
        "coordonnees_study_level_id",
        get_deferred_select(StudyLevelOption),
    )

    customize(
        "statut_social_status_id",
        get_deferred_select(SocialStatusOption),
    )

    customize(
        "statut_social_status_today_id",
        get_deferred_select(SocialStatusOption),
    )

    customize(
        "activity_typologie_id",
        get_deferred_select(ActivityTypeOption)
    )

    customize(
        "activity_pcs_id",
        get_deferred_select(PcsOption)
    )

    customize(
        "parcours_prescripteur_id",
        get_deferred_select(PrescripteurOption),
    )

    customize(
        "parcours_non_admission_id",
        get_deferred_select(NonAdmissionOption),
    )

    if 'social_statuses' in schema:
        child_schema = schema['social_statuses'].children[0]
        child_schema.widget = CleanMappingWidget()
        customize_field(
            child_schema,
            'social_status_id',
            widget=get_deferred_select(SocialStatusOption)
        )
        customize_field(
            child_schema,
            'step',
            widget=deform.widget.HiddenWidget(),
            default="entry"
        )

    if 'today_social_statuses' in schema:
        child_schema = schema['today_social_statuses'].children[0]
        child_schema.widget = CleanMappingWidget()
        customize_field(
            child_schema,
            'social_status_id',
            widget=get_deferred_select(SocialStatusOption)
        )
        customize_field(
            child_schema,
            'step',
            widget=deform.widget.HiddenWidget(),
            default="today"
        )

    if 'statut_external_activity' in schema:
        child_schema = schema['statut_external_activity'].children[0]
        child_schema.widget = CleanMappingWidget()
        customize_field(
            child_schema,
            'statut_external_activity',
            widget=get_select(CONTRACT_OPTIONS),
        )

    if 'activity_companydatas' in schema:
        child_schema = schema['activity_companydatas'].children[0]
        child_schema.widget = CleanMappingWidget()
        customize_field(
            child_schema,
            'activity_id',
            widget=get_deferred_select(CompanyActivity)
        )

    customize("parcours_goals", deform.widget.TextAreaWidget())
    customize('parcours_status_id', get_deferred_select(ParcoursStatusOption))
Exemplo n.º 15
0
def customize_schema(schema):
    """
    Customize the form schema
    :param obj schema: A UserDatas schema
    """
    customize = functools.partial(customize_field, schema)

    customize(
        'situation_antenne_id',
        get_deferred_select(AntenneOption)
    )

    customize(
        'situation_follower_id',
        get_deferred_user_choice(
            roles=['admin', 'manager'],
            widget_options={
                'default_option': ('', ''),
            }
        )
    )

    customize(
        'coordonnees_civilite',
        get_select(CIVILITE_OPTIONS)
    )

    customize('coordonnees_email1', validator=mail_validator())
    customize('coordonnees_email2', validator=mail_validator())

    customize(
        'coordonnees_address',
        deform.widget.TextAreaWidget(),
    )

    customize(
        "coordonnees_zone_id",
        get_deferred_select(ZoneOption),
    )

    customize(
        "coordonnees_zone_qual_id",
        get_deferred_select(ZoneQualificationOption),
    )

    customize(
        "coordonnees_sex",
        get_select(SEX_OPTIONS),
        get_select_validator(SEX_OPTIONS)
    )

    customize(
        "coordonnees_birthplace",
        deform.widget.TextAreaWidget(),
    )

    customize(
        "coordonnees_family_status",
        get_select(STATUS_OPTIONS),
        get_select_validator(STATUS_OPTIONS),
    )

    customize(
        "coordonnees_children",
        get_select(zip(range(20), range(20)))
    )

    customize(
        "coordonnees_study_level_id",
        get_deferred_select(StudyLevelOption),
    )

    customize(
        "statut_social_status_id",
        get_deferred_select(SocialStatusOption),
    )

    customize(
        "statut_social_status_today_id",
        get_deferred_select(SocialStatusOption),
    )

    customize(
        "activity_typologie_id",
        get_deferred_select(ActivityTypeOption)
    )

    customize(
        "activity_pcs_id",
        get_deferred_select(PcsOption)
    )

    customize(
        "parcours_prescripteur_id",
        get_deferred_select(PrescripteurOption),
    )

    customize(
        "parcours_non_admission_id",
        get_deferred_select(NonAdmissionOption),
    )

    if 'social_statuses' in schema:
        child_schema = schema['social_statuses'].children[0]
        child_schema.widget = CleanMappingWidget()
        customize_field(
            child_schema,
            'social_status_id',
            widget=get_deferred_select(SocialStatusOption)
        )
        customize_field(
            child_schema,
            'step',
            widget=deform.widget.HiddenWidget(),
            default="entry"
        )

    if 'today_social_statuses' in schema:
        child_schema = schema['today_social_statuses'].children[0]
        child_schema.widget = CleanMappingWidget()
        customize_field(
            child_schema,
            'social_status_id',
            widget=get_deferred_select(SocialStatusOption)
        )
        customize_field(
            child_schema,
            'step',
            widget=deform.widget.HiddenWidget(),
            default="today"
        )

    if 'statut_external_activity' in schema:
        child_schema = schema['statut_external_activity'].children[0]
        child_schema.widget = CleanMappingWidget()
        customize_field(
            child_schema,
            'statut_external_activity',
            widget=get_select(CONTRACT_OPTIONS),
        )

    if 'activity_companydatas' in schema:
        child_schema = schema['activity_companydatas'].children[0]
        child_schema.widget = CleanMappingWidget()
        customize_field(
            child_schema,
            'activity_id',
            widget=get_deferred_select(CompanyActivity)
        )

    customize("parcours_goals", deform.widget.TextAreaWidget())
    customize('parcours_status_id', get_deferred_select(ParcoursStatusOption))