예제 #1
0
def set_widgets(schema):
    """
    Customize form widgets

    :param obj schema: The colander Schema to edit
    """
    customize = functools.partial(forms.customize_field, schema)
    if 'vehicle' in schema:
        customize(
            'vehicle',
            widget=forms.get_deferred_select(
                ExpenseKmType,
                keys=(
                    lambda a: u"%s-%s" % (a.label, a.code),
                    lambda a: u"%s (%s)" % (a.label, a.code)
                ),
                filters=[('active', True)]
            )
        )

    if 'civilite' in schema:
        customize(
            'civilite',
            widget=forms.get_select(CIVILITE_OPTIONS),
            validator=forms.get_select_validator(CIVILITE_OPTIONS)
        )

    if 'email' in schema:
        customize('email', validator=forms.mail_validator())
    return schema
예제 #2
0
def deferred_bank_widget(node, kw):
    """
    Renvoie le widget pour la sélection d'une banque
    """
    options = [(bank.id, bank.label) for bank in BankAccount.query()]
    widget = forms.get_select(options)
    return widget
예제 #3
0
def set_widgets(schema):
    """
    Customize form widgets

    :param obj schema: The colander Schema to edit
    """
    customize = functools.partial(forms.customize_field, schema)
    if 'vehicle' in schema:
        customize(
            'vehicle',
            widget=forms.get_deferred_select(
                ExpenseKmType,
                keys=(
                    lambda a: u"%s-%s" % (a.label, a.code),
                    lambda a: u"%s (%s)" % (a.label, a.code)
                ),
                filters=[('active', True)]
            )
        )

    if 'civilite' in schema:
        customize(
            'civilite',
            widget=forms.get_select(CIVILITE_OPTIONS),
            validator=forms.get_select_validator(CIVILITE_OPTIONS)
        )

    if 'email' in schema:
        customize('email', validator=forms.mail_validator())
    return schema
예제 #4
0
def deferred_bank_widget(node, kw):
    """
    Renvoie le widget pour la sélection d'une banque
    """
    options = [(bank.id, bank.label) for bank in BankAccount.query()]
    widget = forms.get_select(options)
    return widget
예제 #5
0
def customize_schema(schema):
    """
    Customize the form schema
    :param obj schema: A CareerStage schema
    """
    customize = functools.partial(customize_field, schema)
    customize('cae_situation_id', get_deferred_select(CaeSituationOption))
    customize("stage_type", get_select(STAGE_TYPE_OPTIONS))
예제 #6
0
def customize_schema(schema):
    """
    Customize the form schema
    :param obj schema: A CareerStage schema
    """
    customize = functools.partial(customize_field, schema)
    customize(
        'cae_situation_id',
        get_deferred_select(CaeSituationOption)
    )
    customize(
        "stage_type",
        get_select(STAGE_TYPE_OPTIONS)
    )
예제 #7
0
def _customize_schema(schema):
    """
    Add common widgets configuration for the customer forms schema

    :param obj schema: The Customer form schema
    """
    schema['civilite'].widget = forms.get_select(CIVILITE_OPTIONS, )
    schema['civilite'].validator = colander.OneOf(
        [a[0] for a in CIVILITE_OPTIONS])
    schema['address'].widget = deform.widget.TextAreaWidget(
        cols=25,
        row=1,
    )
    schema['email'].validator = forms.mail_validator()
    schema['comments'].widget = deform.widget.TextAreaWidget(
        css_class="col-md-8",
        rows=5,
    )
    return schema
예제 #8
0
def customize_schema(schema):
    """
    Customize the form schema
    :param obj schema: A CareerPath schema
    """
    customize = functools.partial(customize_field, schema)
    customize(
        'career_stage_id',
        get_deferred_select(CareerStage, keys=('id', 'name'))
    )
    customize(
        'type_contrat_id',
        get_deferred_select(TypeContratOption)
    )
    customize(
        'employee_quality_id',
        get_deferred_select(EmployeeQualityOption)
    )
    customize(
        "taux_horaire",
        deform.widget.MoneyInputWidget()
    )
    customize(
        "num_hours",
        deform.widget.MoneyInputWidget()
    )
    customize(
        "goals_amount",
        deform.widget.MoneyInputWidget()
    )
    customize(
        "goals_period",
        get_select(PERIOD_OPTIONS)
    )
    customize(
        'type_sortie_id',
        get_deferred_select(TypeSortieOption)
    )
    customize(
        'motif_sortie_id',
        get_deferred_select(MotifSortieOption)
    )
예제 #9
0
def _customize_schema(schema):
    """
    Add common widgets configuration for the customer forms schema

    :param obj schema: The Customer form schema
    """
    schema['civilite'].widget = forms.get_select(
        CIVILITE_OPTIONS,
    )
    schema['civilite'].validator = colander.OneOf(
        [a[0] for a in CIVILITE_OPTIONS]
    )
    schema['address'].widget = deform.widget.TextAreaWidget(
        cols=25,
        row=1,
    )
    schema['email'].validator = forms.mail_validator()
    schema['comments'].widget = deform.widget.TextAreaWidget(
        css_class="col-md-8",
        rows=5,
    )
    return schema
예제 #10
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))
예제 #11
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))