class ProductTaskLines(colander.SequenceSchema): taskline = ProductTaskLine( missing="", title=u"", validator=product_match_tva_validator, widget=CleanMappingWidget(), )
def get_upload_list_schema(): """ Build a schema for Accounting Operation upload listing """ schema = BaseListsSchema().clone() del schema['search'] schema.insert( 0, colander.SchemaNode( colander.String(), name='filetype', widget=deform.widget.SelectWidget(values=( ('all', u'Tous les types de fichier'), ('general_ledger', u"Grand livre"), ('analytical_balance', u"Balance analytique"), )), default='all', missing=colander.drop, )) schema.insert( 0, YearPeriodSchema( name='period', widget=CleanMappingWidget(), missing=colander.drop, )) return schema
class ActivityModesSeqConfig(colander.SequenceSchema): """ Sequence schema for activity modes configuration """ activity_mode = ActivityModeConfig( title=u"Mode d'entretien", widget=CleanMappingWidget(), )
class ActivityTypesSeqConfig(colander.SequenceSchema): """ The sequence Schema associated with the ActivityTypeConfig """ activity_type = ActivityTypeConfig( title=u"Nature du rendez-vous", widget=CleanMappingWidget(), )
def get_sequence_model_admin(model, title=u"", excludes=(), **kw): """ Return a schema for configuring sequence of models model The SQLAlchemy model to configure """ node_schema = SQLAlchemySchemaNode( model, widget=CleanMappingWidget(), excludes=excludes, ) node_schema.name = 'data' colanderalchemy_config = getattr(model, '__colanderalchemy_config__', {}) default_widget_options = dict( orderable=True, min_len=1, ) widget_options = colanderalchemy_config.get('seq_widget_options', {}) widget_options.update(kw.get('widget_options', {})) for key, value in widget_options.items(): default_widget_options[key] = value schema = colander.SchemaNode(colander.Mapping()) schema.add( colander.SchemaNode( colander.Sequence(), node_schema, widget=CleanSequenceWidget( **default_widget_options ), title=title, name='datas') ) def dictify(models): return {'datas': [node_schema.dictify(model) for model in models]} def objectify(datas): return [node_schema.objectify(data) for data in datas] schema.dictify = dictify schema.objectify = objectify return schema
def get_upload_list_schema(): """ Build a schema for Accounting Operation upload listing """ schema = BaseListsSchema().clone() del schema['search'] schema.insert( 0, YearPeriodSchema( name='period', widget=CleanMappingWidget(), missing=colander.drop, ) ) return schema
class ActivityActionSeq(colander.SequenceSchema): action = ActivityActionConfig( title=u"Titre", widget=CleanMappingWidget(), )
def get_list_schema(is_global=False, excludes=()): """ Return the estimation list schema :param bool is_global: Should we include global search fields (CAE wide) :param tuple excludes: List of field to exclude :returns: The list schema :rtype: colander.SchemaNode """ schema = forms.lists.BaseListsSchema().clone() del schema['search'] if 'customer' not in excludes: schema.insert( 0, customer_filter_node_factory( is_admin=is_global, name='customer_id', with_estimation=True, )) if "company_id" not in excludes: schema.insert(0, company_filter_node_factory(name='company_id')) schema.insert( 0, PeriodSchema( name='period', title="", validator=colander.Function( forms.range_validator, msg=u"La date de début doit précéder la date de début"), widget=CleanMappingWidget(), missing=colander.drop, )) schema.insert( 0, AmountRangeSchema( name='ttc', title="", validator=colander.Function( forms.range_validator, msg=u"Le montant de départ doit être inférieur ou égale \ à celui de la fin"), widget=CleanMappingWidget(), missing=colander.drop, )) if "status" not in excludes: schema.insert( 0, colander.SchemaNode( colander.String(), name='status', widget=deform.widget.SelectWidget(values=STATUS_OPTIONS), validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]), default='all', missing='all')) if "signed_status" not in excludes: schema.insert( 0, colander.SchemaNode(colander.String(), name='signed_status', widget=deform.widget.SelectWidget( values=SIGNED_STATUS_OPTIONS), validator=colander.OneOf( [s[0] for s in SIGNED_STATUS_OPTIONS]), default='all', missing='all')) if "year" not in excludes: node = forms.year_select_node( name='year', query_func=get_invoice_years, ) schema.insert(0, node) return schema
def get_list_schema(is_global=False, excludes=()): """ Return a schema for invoice listing is_global If True, customer select is only related to the current company """ schema = forms.lists.BaseListsSchema().clone() if 'paid_status' not in excludes: schema.insert( 0, colander.SchemaNode( colander.String(), name='paid_status', widget=deform.widget.SelectWidget(values=PAID_STATUS_OPTIONS), validator=colander.OneOf([s[0] for s in PAID_STATUS_OPTIONS]), missing='all', default='all', )) if 'status' not in excludes: schema.insert( 0, colander.SchemaNode( colander.String(), name='status', widget=deform.widget.SelectWidget(values=STATUS_OPTIONS), validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]), missing='all', default='all', )) schema.insert( 0, colander.SchemaNode( colander.String(), name='doctype', widget=deform.widget.SelectWidget(values=TYPE_OPTIONS), validator=colander.OneOf([s[0] for s in TYPE_OPTIONS]), missing='both', default='both', )) if 'customer' not in excludes: schema.insert( 0, customer_filter_node_factory( is_admin=is_global, name='customer_id', )) if 'company_id' not in excludes: schema.insert(0, company_filter_node_factory(name='company_id')) schema.insert( 0, PeriodSchema( name='period', title="", validator=colander.Function( forms.range_validator, msg=u"La date de début doit précéder la date de début"), widget=CleanMappingWidget(), missing=colander.drop, )) schema.insert( 0, AmountRangeSchema( name='ttc', title="", validator=colander.Function( forms.range_validator, msg=u"Le montant de départ doit être inférieur ou égale \ à celui de la fin"), widget=CleanMappingWidget(), missing=colander.drop, )) if 'year' not in excludes: def get_year_options(kw): values = invoice.get_invoice_years(kw) values.insert(0, u'') return values node = forms.year_select_node(name='year', query_func=get_year_options, missing=-1, description=u"Année fiscale") schema.insert(0, node) schema['search'].description = u"Identifiant du document" return schema
class CompetenceRequirementSeq(colander.SequenceSchema): requirement = CompetenceRequirement( title=u'', widget=CleanMappingWidget(), )
class WorkshopInfo1Seq(colander.SequenceSchema): actions = WorkshopInfo1( title=u'Titre', widget=CleanMappingWidget(), )
class SubCompetencesConfigSchema(colander.SequenceSchema): subcompetence = SubCompetenceConfigSchema(widget=CleanMappingWidget(), )
class WorkshopInfo2Seq(colander.SequenceSchema): child = WorkshopInfo2( title=u"Sous-titre", widget=CleanMappingWidget(), )
def get_list_schema(is_global=False): """ Return the estimation list schema :param bool is_global: Should we include global search fields (CAE wide) :returns: The list schema :rtype: colander.SchemaNode """ schema = forms.lists.BaseListsSchema().clone() del schema['search'] schema.insert(0, company.customer_node(is_global)) if is_global: schema.insert( 0, company.company_node( name='company_id', missing=colander.drop, widget_options={'default': ('', u'Toutes les entreprises')})) schema.insert( 0, PeriodSchema( name='period', title="", validator=colander.Function( forms.range_validator, msg=u"La date de début doit précéder la date de début"), widget=CleanMappingWidget(), missing=colander.drop, )) schema.insert( 0, AmountRangeSchema( name='ttc', title="", validator=colander.Function( forms.range_validator, msg=u"Le montant de départ doit être inférieur ou égale \ à celui de la fin"), widget=CleanMappingWidget(), missing=colander.drop, )) schema.insert( 0, colander.SchemaNode( colander.String(), name='status', widget=deform.widget.SelectWidget(values=STATUS_OPTIONS), validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]), default='all', missing='all')) node = forms.year_select_node( name='year', query_func=get_invoice_years, ) schema.insert(0, node) return schema
class ActivitySubActionSeq(colander.SequenceSchema): subaction = ActionConfig( title=u"", widget=CleanMappingWidget(), )
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))
def get_list_schema(is_admin=False): """ Return a schema for invoice listing is_admin If True, we don't provide the company selection node and we reduce the customers to the current company's """ schema = forms.lists.BaseListsSchema().clone() schema.insert( 0, colander.SchemaNode( colander.String(), name='status', widget=deform.widget.SelectWidget(values=STATUS_OPTIONS), validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]), missing='both', default='both', )) schema.insert( 0, colander.SchemaNode( colander.String(), name='doctype', widget=deform.widget.SelectWidget(values=TYPE_OPTIONS), validator=colander.OneOf([s[0] for s in TYPE_OPTIONS]), missing='both', default='both', )) schema.insert(0, company.customer_node(is_admin)) if is_admin: schema.insert( 0, company.company_node( name='company_id', missing=colander.drop, widget_options={'default': ('', u'Toutes les entreprises')}, )) schema.insert( 0, PeriodSchema( name='period', title="", validator=colander.Function( forms.range_validator, msg=u"La date de début doit précéder la date de début"), widget=CleanMappingWidget(), missing=colander.drop, )) schema.insert( 0, AmountRangeSchema( name='ttc', title="", validator=colander.Function( forms.range_validator, msg=u"Le montant de départ doit être inférieur ou égale \ à celui de la fin"), widget=CleanMappingWidget(), missing=colander.drop, )) def get_year_options(): values = invoice.get_invoice_years() values.insert(0, u'') return values node = forms.year_select_node(name='year', query_func=get_year_options, missing=-1, description=u"Année fiscale") schema.insert(0, node) schema['search'].description = u"Identifiant du document" return schema