Beispiel #1
0
def get_list_schema():
    """
    Return a list schema for user datas
    """
    schema = BaseListsSchema().clone()

    schema['search'].description = u"Nom, prénom, entreprise"

    schema.insert(
        0,
        colander.SchemaNode(
            colander.Integer(),
            name='situation_situation',
            widget=get_deferred_select(CaeSituationOption,
                                       empty_filter_msg=u"Tous les status"),
            validator=get_deferred_select_validator(CaeSituationOption),
            missing=colander.drop,
        ))

    schema.insert(0, conseiller_filter_node_factory())
    antenne_filter_node = colander.SchemaNode(
        colander.Integer(),
        name="situation_antenne_id",
        widget=get_deferred_select(AntenneOption,
                                   empty_filter_msg=u"Toutes les antennes"),
        validator=get_deferred_select_validator(AntenneOption),
        missing=colander.drop)
    schema.insert(0, antenne_filter_node)
    return schema
def get_list_schema():
    """
    Return a list schema for user datas
    """
    schema = BaseListsSchema().clone()

    schema['search'].description = u"Nom, prénom, entreprise"

    schema.insert(0, colander.SchemaNode(
        colander.Integer(),
        name='situation_situation',
        widget=get_deferred_select(
            CaeSituationOption, empty_filter_msg=u"Tous les status"
        ),
        validator=get_deferred_select_validator(CaeSituationOption),
        missing=colander.drop,
    ))

    schema.insert(0, conseiller_filter_node_factory(
        name='situation_follower_id'
    ))

    antenne_filter_node = colander.SchemaNode(
        colander.Integer(),
        name="situation_antenne_id",
        widget=get_deferred_select(
            AntenneOption, empty_filter_msg=u"Toutes les antennes"
        ),
        validator=get_deferred_select_validator(AntenneOption),
        missing=colander.drop
    )
    schema.insert(0, antenne_filter_node)

    return schema
Beispiel #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
Beispiel #4
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
Beispiel #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))
Beispiel #6
0
class IncomeStatementMeasureGrid(DBBASE):
    """
    A grid of measures, one grid per month/year couple

    """
    __tablename__ = 'income_statement_measure_grid'
    __table_args__ = default_table_args
    id = Column(Integer, primary_key=True)
    datetime = Column(
        DateTime(),
        default=datetime.datetime.now,
        info={"colanderalchemy": {
            'title': u"Heure et date de création"
        }})
    month = Column(Integer, info={'colanderalchemy': {'title': u"Mois"}})
    year = Column(Integer, info={'colanderalchemy': {'title': u"Année"}})

    company_id = Column(ForeignKey('company.id', ondelete="cascade"),
                        info={
                            "colanderalchemy": {
                                'title':
                                u"Entreprise associée à cette opération",
                                "widget":
                                get_deferred_select(
                                    Company,
                                    keys=('id', lambda c: u"%s %s" %
                                          (c.name, c.code_compta)))
                            }
                        })
    company = relationship('Company')
    upload_id = Column(
        ForeignKey('accounting_operation_upload.id', ondelete="cascade"),
        info={"colanderalchemy": {
            'title': u"Related upload"
        }},
    )
    upload = relationship('AccountingOperationUpload')
    measures = relationship(
        "IncomeStatementMeasure",
        primaryjoin="IncomeStatementMeasureGrid.id=="
        "IncomeStatementMeasure.grid_id",
        cascade="all,delete,delete-orphan",
    )

    _autonomie_service = IncomeStatementMeasureGridService

    def get_company_id(self):
        return self.company_id

    @classmethod
    def get_years(cls, company_id):
        return cls._autonomie_service.get_years(cls, company_id)

    def get_measure_by_type(self, measure_type_id):
        return self._autonomie_service.get_measure_by_type(
            self, measure_type_id)
Beispiel #7
0
class TvaPayment(colander.MappingSchema):
    amount = colander.SchemaNode(
        AmountType(5),
        title=u"Montant de l'encaissement",
    )
    tva_id = colander.SchemaNode(colander.Integer(),
                                 title=u"Tva liée à cet encaissement",
                                 widget=forms.get_deferred_select(
                                     Tva, mandatory=True, keys=('id', 'name')),
                                 validator=deferred_tva_id_validator)
Beispiel #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)
    )
Beispiel #9
0
class CompetenceOption(ConfigurableOption):
    """
    A competence model (both for the main one and the sub-competences)

    :param int required_id: The id of the bareme element needed
    """
    __table_args__ = default_table_args
    __colanderalchemy_config__ = {
        "title":
        u"une compétence",
        "validation_msg":
        u"La grille de compétences a bien été configurées",
        "help_msg":
        u"Définissez des compétences, celles-ci sont \
composées: <ul><li>D'un libellé</li><li>D'un niveau de référence</li>\
<li>D'un ensemble de sous-compétences (définies par un libellé)</li></ul>"
    }
    id = get_id_foreignkey_col('configurable_option.id')
    requirement = Column(Float(),
                         default=0,
                         info={
                             'colanderalchemy': {
                                 "title":
                                 u"Niveau de référence pour cette compétence",
                                 "widget":
                                 get_deferred_select(
                                     CompetenceScale,
                                     mandatory=True,
                                     keys=('value', 'label'),
                                 )
                             }
                         })

    @classmethod
    def query(cls, active=True, *args):
        query = super(CompetenceOption, cls).query(*args)
        query = query.filter_by(active=active)
        return query

    def __json__(self, request):
        return dict(
            id=self.id,
            label=self.label,
            requirement=self.requirement,
            children=[child.__json__(request) for child in self.children],
        )

    @classmethod
    def __radar_datas__(cls):
        result = []
        for option in cls.query():
            result.append({'axis': option.label, 'value': option.requirement})
        return result
Beispiel #10
0
class CompetenceRequirement(colander.MappingSchema):
    deadline_id = forms.id_node()
    deadline_label = colander.SchemaNode(
        colander.String(),
        widget=deform.widget.TextInputWidget(readonly=True),
        title=u"Pour l'échéance",
        missing=colander.drop,
    )
    scale_id = colander.SchemaNode(
        colander.Integer(),
        title=u"Niveau requis",
        description=u"Sera mis en évidence dans l'interface",
        widget=forms.get_deferred_select(CompetenceScale))
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)
    )
Beispiel #12
0
class InvoicePayments(colander.MappingSchema):
    """
        Conditions de paiement de la facture
    """
    payment_conditions_select = colander.SchemaNode(
        colander.String(),
        widget=forms.get_deferred_select(PaymentConditions),
        title=u"",
        missing=colander.drop,
    )

    payment_conditions = forms.textarea_node(
        title="",
        default=deferred_default_payment_condition,
    )
Beispiel #13
0
class IncomeStatementMeasure(DBBASE):
    """
    Stores a income_statement measure associated to a given company
    """
    __tablename__ = 'income_statement_measure'
    __table_args__ = default_table_args
    id = Column(Integer, primary_key=True)
    label = Column(String(255),
                   info={"colanderalchemy": {
                       'title': u"Libellé"
                   }})
    value = Column(
        Float(precision=2),
        default=0,
        info={"colanderalchemy": {
            'title': u"Montant"
        }},
    )
    measure_type_id = Column(
        ForeignKey('income_statement_measure_type.id'),
        info={
            "colanderalchemy": {
                'title': u"Type d'indicateur",
                "widget": get_deferred_select(IncomeStatementMeasureType),
            }
        })
    measure_type = relationship(
        IncomeStatementMeasureType,
        primaryjoin="IncomeStatementMeasureType.id=="
        "IncomeStatementMeasure.measure_type_id",
        info={"colanderalchemy": {
            'exclude': True
        }},
    )
    grid_id = Column(
        ForeignKey('income_statement_measure_grid.id', ondelete="cascade"))

    def __json__(self, request):
        return {
            "id": self.id,
            "label": self.label,
            "value": self.get_value(),
            "measure_type_id": self.measure_type_id
        }

    def get_value(self):
        return -1 * self.value
Beispiel #14
0
class EstimationPayments(colander.MappingSchema):
    """
        Gestion des acomptes
    """
    deposit = colander.SchemaNode(
        colander.Integer(),
        title=u"Acompte à la commande",
        default=0,
        widget=deform.widget.SelectWidget(
            values=get_percents(),
            css_class='col-md-2')
    )
    payment_times = colander.SchemaNode(
        colander.Integer(),
        title=u"Paiement en ",
        default=1,
        widget=deform.widget.SelectWidget(
            values=get_payment_times(),
            css_class='col-md-2'
        )
    )
    paymentDisplay = colander.SchemaNode(
        colander.String(),
        validator=colander.OneOf([x[0] for x in PAYMENTDISPLAYCHOICES]),
        widget=deform.widget.RadioChoiceWidget(values=PAYMENTDISPLAYCHOICES),
        title=u"Affichage des paiements",
        default="SUMMARY")
    payment_lines = EstimationPaymentLines(
        widget=deform.widget.SequenceWidget(
            template=TEMPLATES_URL + 'paymentlines_sequence.pt',
            item_template=TEMPLATES_URL + 'paymentlines_sequence_item.pt',
            min_len=1),
        title=u'',
        description=u"Définissez les échéances de paiement")

    payment_conditions_select = colander.SchemaNode(
        colander.String(),
        widget=forms.get_deferred_select(PaymentConditions),
        title=u"Conditions de paiement prédéfinies",
        missing=colander.drop,
    )

    payment_conditions = forms.textarea_node(
        title=u"Conditions de paiement",
        default=deferred_default_payment_condition,
    )
Beispiel #15
0
class PaymentSchema(colander.MappingSchema):
    """
        colander schema for payment recording
    """
    come_from = forms.come_from_node()
    bank_remittance_id = colander.SchemaNode(
        colander.String(),
        title=u"Identifiant de la remise en banque",
        description=u"Ce champ est un indicateur permettant de \
retrouver la remise en banque à laquelle cet encaissement est associé",
        default=deferred_bank_remittance_id_default,
    )
    amount = colander.SchemaNode(
        AmountType(5),
        title=u"Montant de l'encaissement",
        validator=deferred_total_validator,
        default=deferred_amount_default,
    )
    date = forms.today_node()
    mode = colander.SchemaNode(
        colander.String(),
        title=u"Mode de paiement",
        widget=deferred_payment_mode_widget,
        validator=deferred_payment_mode_validator,
    )
    bank_id = colander.SchemaNode(
        colander.Integer(),
        title=u"Banque",
        missing=colander.drop,
        widget=deferred_bank_widget,
        validator=deferred_bank_validator,
        default=forms.get_deferred_default(BankAccount),
    )
    tva_id = colander.SchemaNode(colander.Integer(),
                                 title=u"Tva liée à cet encaissement",
                                 widget=forms.get_deferred_select(
                                     Tva, mandatory=True, keys=('id', 'name')),
                                 validator=deferred_tva_id_validator)
    resulted = colander.SchemaNode(
        colander.Boolean(),
        title=u"Soldé",
        description="""Indique que le document est soldé (
ne recevra plus de paiement), si le montant indiqué correspond au
montant de la facture celle-ci est soldée automatiquement""",
        default=False,
    )
Beispiel #16
0
class TreasuryMeasure(DBBASE):
    """
    Stores a treasury measure associated to a given company
    """
    __tablename__ = 'treasury_measure'
    __table_args__ = default_table_args
    id = Column(Integer, primary_key=True)
    label = Column(String(255),
                   info={"colanderalchemy": {
                       'title': u"Libellé"
                   }})
    value = Column(
        Float(precision=2),
        default=0,
        info={"colanderalchemy": {
            'title': u"Montant"
        }},
    )
    measure_type_id = Column(ForeignKey('treasury_measure_type.id'),
                             info={
                                 "colanderalchemy": {
                                     'title':
                                     u"Type d'indicateur",
                                     "widget":
                                     get_deferred_select(TreasuryMeasureType),
                                 }
                             })
    measure_type = relationship(
        TreasuryMeasureType,
        primaryjoin="TreasuryMeasureType.id==TreasuryMeasure.measure_type_id",
        info={"colanderalchemy": {
            'exclude': True
        }},
    )
    grid_id = Column(ForeignKey('treasury_measure_grid.id'))

    def __todict__(self, request):
        return {
            "id": self.id,
            "label": self.label,
            "value": self.value,
            "measure_type_id": self.measure_type_id
        }
Beispiel #17
0
class AccountingOperation(DBBASE):
    __tablename__ = 'accounting_operation'
    __table_args__ = default_table_args
    id = Column(Integer, primary_key=True)
    date = Column(
        Date(),
        default=datetime.date.today,
        info={"colanderalchemy": {
            'title': u"Date de l'écriture"
        }},
    )
    analytical_account = Column(String(20),
                                info={
                                    'colanderalchemy': {
                                        'title':
                                        u"Compte analytique de l'entreprise"
                                    }
                                })
    general_account = Column(
        String(20),
        info={'colanderalchemy': {
            'title': u"Compte général de l'opération"
        }})
    label = Column(
        String(80),
        info={'colanderalchemy': {
            'title': u"Libellé"
        }},
    )
    debit = Column(
        Float(precision=2),
        info={'colanderalchemy': {
            'title': u"Débit"
        }},
    )
    credit = Column(
        Float(precision=2),
        info={'colanderalchemy': {
            'title': u"Crédit"
        }},
    )
    balance = Column(
        Float(precision=2),
        info={'colanderalchemy': {
            'title': u"Solde"
        }},
    )
    company_id = Column(ForeignKey('company.id', ondelete="CASCADE"),
                        info={
                            "colanderalchemy": {
                                'title':
                                u"Entreprise associée à cette opération",
                                "widget":
                                get_deferred_select(
                                    Company,
                                    keys=('id', lambda c: u"%s %s" %
                                          (c.name, c.code_compta)))
                            }
                        })
    company = relationship(
        'Company',
        info={"colanderalchemy": {
            'exclude': True
        }},
    )
    upload_id = Column(
        ForeignKey('accounting_operation_upload.id', ondelete="CASCADE"))

    def __json__(self, request):
        return dict(
            analytical_account=self.analytical_account,
            general_account=self.general_account,
            date=self.date,
            label=self.label,
            debit=self.debit,
            credit=self.credit,
            balance=self.balance,
            company_id=self.company_id,
        )

    def total(self):
        return self.debit - self.credit
Beispiel #18
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))
Beispiel #19
0
class TreasuryMeasureGrid(DBBASE):
    """
    A grid of measures

    1. Trésorerie du jour : somme des comptes 5 ;
    2. Impôts, taxes et cotisations dues : somme des comptes 42,43 et 44 ;
    3. Fournisseurs à payer : sommes des comptes 40 ;
    4. Trésorerie de référence : somme des trois indicateurs précédents (1,2,3);
    5. Salaires à payer : somme des comptes 425 ;
    6. Notes de dépenses à payer : somme des comptes 421 ;
    7. Clients à encaisser : somme des 41 ;
    8. Trésorerie future : somme de la trésorerie de référence et des trois
    indicateurs précédents (5,6,7) ;
    9. Liste des entrées pour les comptes 1xxxxx,2xxxxx et 3xxxxx.
    """
    __tablename__ = 'treasury_measure_grid'
    __table_args__ = default_table_args
    id = Column(Integer, primary_key=True)
    datetime = Column(
        DateTime(),
        default=datetime.datetime.now,
        info={"colanderalchemy": {
            'title': u"Heure et date de création"
        }})
    date = Column(Date(),
                  info={"colanderalchemy": {
                      'title': u"Date du dépôt"
                  }})
    company_id = Column(ForeignKey('company.id', ondelete="cascade"),
                        info={
                            "colanderalchemy": {
                                'title':
                                u"Entreprise associée à cette opération",
                                "widget":
                                get_deferred_select(
                                    Company,
                                    keys=('id', lambda c: u"%s %s" %
                                          (c.name, c.code_compta)))
                            }
                        })
    company = relationship('Company')
    upload_id = Column(
        ForeignKey('accounting_operation_upload.id', ondelete="cascade"),
        info={"colanderalchemy": {
            'title': u"Related upload"
        }},
    )
    upload = relationship('AccountingOperationUpload')
    measures = relationship(
        "TreasuryMeasure",
        primaryjoin="TreasuryMeasureGrid.id==TreasuryMeasure.grid_id",
        cascade="all,delete,delete-orphan",
    )

    _autonomie_service = TreasuryMeasureGridService

    @classmethod
    def last(cls, company_id):
        return cls._autonomie_service.last(cls, company_id)

    def __todict__(self, request):
        """
        Compile the different measures and return a dict representation of
        the grid
        """
        result = {
            "date": self.date,
            "id": self.id,
            "upload_id": self.upload_id
        }
        result["measures"] = measures_dict = {}

        for type_ in TreasuryMeasureType.query():
            measures_dict[type_.internal_id] = [{
                'value': 0,
                'label': type_.label
            }]

        for measure in self.measures:
            measures_dict[measure.measure_type.internal_id] = [
                measure.__todict__(request)
            ]

        ref_treasury = 0
        for i in range(1, 4):
            if i in measures_dict:
                ref_treasury += measures_dict[i][0]['value']

        measures_dict[4] = [{
            "label": u"Trésorerie de référence",
            "value": ref_treasury
        }]

        for i in range(5, 8):
            if i in measures_dict:
                ref_treasury += measures_dict[i][0]['value']

        measures_dict[8] = [{
            "label": u"Trésorerie future",
            "value": ref_treasury,
        }]

        if 9 in measures_dict:
            ref_treasury += measures_dict[9][0]['value']

        measures_dict[10] = [{
            'label': u"Résultat de l'entreprise",
            "value": ref_treasury,
        }]
        return result

    @classmethod
    def get_years(cls):
        return cls._autonomie_service.get_years(cls)

    def get_first_measure(self):
        return self._autonomie_service.measure_by_internal_id(self, 1)

    def get_company_id(self):
        return self.company_id
Beispiel #20
0
class CompetenceRequirement(DBBASE):
    __colanderalchemy_config__ = {
        "title": u"un niveau de référence",
        "validation_msg": u"Les niveaux de référence de la grille de \
compétences ont bien été configurés",
        "help_msg": u"Pour chaque compétence, définissez les niveaux de \
référence à chaque échéance."
    }
    competence_id = Column(
        ForeignKey('competence_option.id'),
        primary_key=True,
        info={'colanderalchemy': get_hidden_field_conf()},
    )
    deadline_id = Column(
        ForeignKey('competence_deadline.id'), primary_key=True,
        info={'colanderalchemy': get_hidden_field_conf()},
    )
    requirement = Column(
        Float(),
        default=0,
        info={
            'colanderalchemy': {
                "title": u"Niveau de référence",
                "widget": get_deferred_select(
                    CompetenceScale,
                    mandatory=True,
                    keys=('value', 'label'),
                )
            }
        }
    )

    competence = relationship(
        'CompetenceOption',
        backref=backref(
            'requirements',
            info={
                'colanderalchemy': {
                    "title": u"Niveaux de référence pour cette compétence",
                },
            }
        ),
        info={
            'colanderalchemy': {"exclude": True},
        }
    )
    deadline = relationship(
        "CompetenceDeadline",
        backref=backref(
            'requirements',
            info={
                'colanderalchemy': {"exclude": True},
            }
        ),
        info={
            'colanderalchemy': {"exclude": True},
        }
    )

    def __json__(self, request):
        return dict(
            deadline_id=self.deadline_id,
            competence_id=self.competence_id,
            reqirement=self.requirement,
            deadline_label=self.deadline.label,
        )
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))