endi.forms package

Subpackages

Submodules

endi.forms.accounting module

Accounting module related schemas

class endi.forms.accounting.CreditAmountRangeSchema(*args, **kw)

Bases : Schema

Used to filter on a range of credit amount

class endi.forms.accounting.DebitAmountRangeSchema(*args, **kw)

Bases : Schema

Used to filter on a range of debit amount

class endi.forms.accounting.PeriodSchema(*args, **kw)

Bases : Schema

A form used to select a period

endi.forms.accounting.accounting_closure_year_validator(node, year)
endi.forms.accounting.complex_total_validator(node, value)

Validate the complex total syntax

endi.forms.accounting.get_add_edit_accounting_operation_schema()

Build a schema for AccountingOperation add/edit

endi.forms.accounting.get_admin_accounting_closure_schema(subclass)

Build the schema for accounting closure add

Paramètres:

subclass (class) – The child class we want to edit

(AcccountingClosure)

endi.forms.accounting.get_admin_accounting_measure_type_schema(subclass, total=False)

Build the schema for accounting measure type edit/add

Total types are more complex and can be :

  • The sum of categories

  • A list of account prefix (like the common type of measure_types)

Paramètres:

subclass (class) – The child class we want to edit

(IncomeStatementMeasureTypeCategory or TreasuryMeasureTypeCategory) :param bool total: Are we editing a total type ?

endi.forms.accounting.get_admin_accounting_type_category_schema(subclass)

Build the schema for accounting type category add/edit

Paramètres:

subclass (class) – The child class we want to edit

(IncomeStatementMeasureTypeCategory or TreasuryMeasureTypeCategory)

endi.forms.accounting.get_admin_general_ledger_account_wording_schema(subclass)

Build the schema for account wording add

Paramètres:

subclass (class) – The child class we want to edit

(AcccountingClosure)

endi.forms.accounting.get_balance_sheet_measures_list_schema()

Build the schema used to list balance sheet measures

Renvoie:

A form schema

Type renvoyé:

colander.Schema

endi.forms.accounting.get_company_general_ledger_operations_list_schema()

Build a schema for company general ledger listing operations

endi.forms.accounting.get_deferred_complex_total_description(category_class, type_class)

Returns a deferred description for the complex total configuration

endi.forms.accounting.get_deferred_widget_categories(category_class)

Returns a deferred widget used to select one or more categories

endi.forms.accounting.get_income_statement_measures_list_schema()

Build the schema used to list income statement measures

Renvoie:

A form schema

Type renvoyé:

colander.Schema

endi.forms.accounting.get_operation_list_schema()

Build a schema listing operations

endi.forms.accounting.get_treasury_measures_list_schema()

Build the schema used to list treasury measures

Renvoie:

A form schema

Type renvoyé:

colander.Schema

endi.forms.accounting.get_upload_list_schema()

Build a schema for Accounting Operation upload listing

endi.forms.accounting.get_upload_treasury_list_schema()

Build the schema used to list treasury measure grids by upload

endi.forms.activity module

Activity related form schemas

New activity creation Activity search schema

class endi.forms.activity.Attendance(*args, **kw)

Bases : Schema

class endi.forms.activity.Attendances(*args, **kw)

Bases : SequenceSchema

class endi.forms.activity.CreateActivitySchema(*args, **kw)

Bases : Schema

Activity creation schema

class endi.forms.activity.NewActivitySchema(*args, **kw)

Bases : CreateActivitySchema

New activity Schema, used to initialize an activity, provides an option to start it directly

class endi.forms.activity.RecordActivitySchema(*args, **kw)

Bases : Schema

Schema for activity recording

endi.forms.activity.get_actions()
endi.forms.activity.get_activity_modes()
endi.forms.activity.get_activity_types()
endi.forms.activity.get_deferred_select_type(default=False)
endi.forms.activity.get_list_schema(is_admin=False)
endi.forms.activity.get_subaction_options()

endi.forms.bank_remittance module

BankRemittance handling forms schemas

class endi.forms.bank_remittance.RemittanceDateSchema(*args, **kw)

Bases : Schema

Schema for the remittance date input

endi.forms.bank_remittance.get_bank_remittances_list_schema()

Return the schema for the bank remittances search list

endi.forms.commercial module

Form schemas for commercial handling

class endi.forms.commercial.CommercialFormSchema(*args, **kw)

Bases : Schema

class endi.forms.commercial.CommercialSetFormSchema(*args, **kw)

Bases : Schema

endi.forms.commercial.get_years(kw)

endi.forms.company module

Company form schemas

endi.forms.company.company_node(multiple=False, **kw)

Return a schema node for company selection

endi.forms.company.customize_company_schema(schema)
endi.forms.company.get_company_schema(admin=False, excludes=()) SchemaNode

Build company add/edit form schema

endi.forms.company.get_default_employee_from_request(request) Optional[User]

Preselects the employee if there is only one or if it is the currently logged user, else no default : up for selection.

endi.forms.company.get_deferred_company_attr_default(attrname)

Build a deferred default value returning the value of the company attribute attrname

NB : Expects the request.context to be a company or to have a request.context.company

Paramètres:

attrname (str) – Name of the company attribute to retrieve

Type renvoyé:

colander.deferred

endi.forms.company.get_deferred_company_choices(widget_options)

Build a deferred for company selection widget

Available widget_options :

default_option

A default option that will be inserted in the list

active_only

Should we restrict the query to active companies ?

query

default None: All companies are returned

Can be a callable or a list of fixed elements The callable should return a list of 2-uples (id, label) The function should take a kw parameter. kw are the colander schema binding parameters

endi.forms.company.get_employees_from_request(request) Iterable[User]
endi.forms.company.get_list_schema(company=False)

Return a schema for filtering companies list

endi.forms.competence module

endi.forms.competence.restrict_user_id(form, kw)

Restrict the user selection to the current user

endi.forms.csv_import module

endi.forms.custom_types module

Custom colander types

class endi.forms.custom_types.AmountType(precision=2)

Bases : Number

preformat an amount before considering it as a float object then *100 to store it into database

deserialize(node, cstruct)
num(value)

preformat the value before passing it to the float function

serialize(node, appstruct)
class endi.forms.custom_types.CsvTuple

Bases : SchemaType

deserialize(node, cstruct)
serialize(node, appstruct)
class endi.forms.custom_types.Integer

Bases : Number

Fix https://github.com/Pylons/colander/pull/35

num

alias de int

serialize(node, appstruct)
class endi.forms.custom_types.QuantityType

Bases : Number

Preformat entry supposed to be numeric entries

num(value)

preformat the value before passing it to the float function

endi.forms.custom_types.specialfloat(self, value)

preformat the value before passing it to the float function

endi.forms.duplicate module

class endi.forms.duplicate.DuplicateSchema(*args, **kw)

Bases : Schema

colander schema for duplication recording

class endi.forms.duplicate.EditMetadataSchema(*args, **kw)

Bases : Schema

Colander schema for moving a task from a phase to another

endi.forms.duplicate.get_all_phases(request)
endi.forms.duplicate.get_all_projects(request)
endi.forms.duplicate.get_current_customer_id_from_request(request)

Return the current customer from the given request

context is a Task here, so it has a customer_id

endi.forms.duplicate.get_current_project_from_request(request)
endi.forms.duplicate.get_phases_options(request)
endi.forms.duplicate.get_project_options(request)
endi.forms.duplicate.remove_some_fields(schema, kw)

endi.forms.expense module

Form models related to the expenses configuration * expense status configuration * period selection * expenseline configuration

class endi.forms.expense.BookMarkSchema(*args, **kw)

Bases : Schema

Schema for bookmarks

class endi.forms.expense.ExpensePaymentSchema(*args, **kw)

Bases : Schema

Schéma de saisie des paiements des notes de dépenses

class endi.forms.expense.ExpenseSeq(*args, **kw)

Bases : SequenceSchema

endi.forms.expense.customize_schema(schema)

Add custom field configuration to the schema

Paramètres:

schema (obj) – colander Schema

endi.forms.expense.expense_type_node(**kw)
endi.forms.expense.get_add_edit_line_schema(factory, expense_sheet=None)

Build a schema for expense line

Paramètres:

model (class) – The model for which we want to generate the schema

Rerturns:

A SQLAlchemySchemaNode schema

endi.forms.expense.get_add_edit_sheet_schema()

Return a schema for expense add/edit

Only month and year are available for edition

Type renvoyé:

colanderalchemy.SQLAlchemySchemaNode

endi.forms.expense.get_deferred_expense_type_choices(widget_options)
endi.forms.expense.get_list_schema()

Build a form schema for expensesheet listing

endi.forms.export module

Form schemas for accounting exports

class endi.forms.export.AccountingExportLogEntryListSchema(*args, **kw)

Bases : BaseListsSchema

validator(form, value)
class endi.forms.export.AllSchema(*args, **kw)

Bases : Schema

class endi.forms.export.BPFYearSchema(*args, **kw)

Bases : Schema

Schema for BPF export (agregate of BusinessBPFData)

class endi.forms.export.CategoryNode(*args, **kw)

Bases : SchemaNode

default = <colander.deferred object>
schema_type

alias de String

widget = <deform.widget.HiddenWidget object>
class endi.forms.export.ExpenseAllSchema(*args, **kw)

Bases : AllSchema

widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.ExpenseNumberSchema(*args, **kw)

Bases : Schema

widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.ExpensePaymentAllSchema(*args, **kw)

Bases : AllSchema

title = 'Exporter les paiements des notes de dépenses non exportés'
widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.ExpensePaymentPeriodSchema(*args, **kw)

Bases : PeriodSchema

title = 'Exporter les paiements des notes de dépenses sur la période donnée'
widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.ExpenseSchema(*args, **kw)

Bases : Schema

Schema for sage expense export

widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.ExportedFieldNode(*args, **kw)

Bases : SchemaNode

default = False
description = 'enDI retient les éléments qui ont déjà été exportés, vous pouvez décider ici de les inclure'
label = 'Inclure les éléments déjà exportés ?'
missing = False
schema_type

alias de Boolean

widget = <deform.widget.CheckboxWidget object>
class endi.forms.export.InvoiceAllSchema(*args, **kw)

Bases : AllSchema

title = 'Exporter les factures non exportées'
widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.InvoiceDoctypeNode(*args, **kw)

Bases : SchemaNode

default = 'all'
missing = 'all'
schema_type

alias de String

title = ''
widget = <deform.widget.RadioChoiceWidget object>
class endi.forms.export.InvoiceNumberSchema(*args, **kw)

Bases : InvoicesRangeSchema

Extends the date+number selector

With filter on accountancy export status.

widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.InvoicePeriodSchema(*args, **kw)

Bases : PeriodSchema

widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.InvoicesRangeSchema(*args, **kw)

Bases : Schema

Form schema for an invoice number selection (year + number)

validator(form, value)

Validate the number range

class endi.forms.export.OnlyAutoValidatedFieldNode(*args, **kw)

Bases : SchemaNode

default = False
description = 'Si vous cochez cette case, seule les écritures provenant de documents autovalidés seront exportées.'
label = 'Uniquement les documents autovalidés ?'
missing = False
schema_type

alias de Boolean

widget = <deform.widget.CheckboxWidget object>
class endi.forms.export.PaymentAllSchema(*args, **kw)

Bases : AllSchema

title = 'Exporter les encaissements non exportées'
widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.PaymentDoctypeNode(*args, **kw)

Bases : InvoiceDoctypeNode

widget = <deform.widget.RadioChoiceWidget object>
class endi.forms.export.PaymentModeNode(*args, **kw)

Bases : SchemaNode

default = ''
missing = <colander.drop>
schema_type

alias de String

title = 'Mode de paiement'
widget = <colander.deferred object>
class endi.forms.export.PaymentPeriodSchema(*args, **kw)

Bases : PeriodSchema

title = 'Exporter les encaissements des factures sur une période donnée'
widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.PeriodSchema(*args, **kw)

Bases : Schema

A form used to select a period

validator(form, value)

Validate the period

class endi.forms.export.SupplierInvoiceAllSchema(*args, **kw)

Bases : AllSchema

title = 'Exporter les factures fournisseurs non exportées'
widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.SupplierInvoiceDoctypeNode(*args, **kw)

Bases : InvoiceDoctypeNode

widget = <deform.widget.RadioChoiceWidget object>
class endi.forms.export.SupplierInvoiceNumberSchema(*args, **kw)

Bases : Schema

widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.SupplierInvoicePeriodSchema(*args, **kw)

Bases : PeriodSchema

title = 'Exporter les factures fournisseurs sur une période donnée'
widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.SupplierInvoiceSchema(*args, **kw)

Bases : Schema

Schema for sage supplier invoice export

title = 'Exporter les factures fournisseurs par enseigne'
widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.SupplierPaymentAllSchema(*args, **kw)

Bases : AllSchema

title = 'Exporter les paiements fournisseurs non exportés'
widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.SupplierPaymentDoctypeNode(*args, **kw)

Bases : InvoiceDoctypeNode

widget = <deform.widget.RadioChoiceWidget object>
class endi.forms.export.SupplierPaymentNumberSchema(*args, **kw)

Bases : Schema

title = "Exporter les paiements d'une facture fournisseur"
widget = <deform_extensions.GridFormWidget object>
class endi.forms.export.SupplierPaymentPeriodSchema(*args, **kw)

Bases : PeriodSchema

title = "Exporter les paiements fournisseurs d'une période donnée"
widget = <deform_extensions.GridFormWidget object>
endi.forms.export.accounting_exporter_choices_query() Iterable[User]
endi.forms.export.get_accounting_export_log_schema()

endi.forms.fields module

class endi.forms.fields.DateRangeSchema(*args, **kw)

Bases : Schema

A form used to select a period

name = 'date_range'
preparer(values)
validator(node, appstruct)
widget = <endi.forms.widgets.DateRangeMappingWidget object>
class endi.forms.fields.YearPeriodSchema(*args, **kw)

Bases : Schema

A form used to select a period

validator(form, value)

Validate the period

endi.forms.files module

class endi.forms.files.CustomFileUploadWidget(*args, **kwargs)

Bases : FileUploadWidget

File upload widget that handles:
  • filters when deserializing

  • file deletion (via a checkbox)

    filters

    An optionnal list (or simple filter) that will be fired on the datas (for example in order to reduce image sizes)

show_delete_control (default :False)

Display a checkbox to allow deleting the file from form (« clearing » file field).

deserialize(field, pstruct)

The deserialize method of a widget must deserialize a pstruct value to a cstruct value and return the cstruct value. The pstruct argument is a value resulting from the parse method of the Peppercorn package. The field argument is the field object to which this widget is attached.

template = 'fileupload.pt'
class endi.forms.files.FileNode(*args, **kw)

Bases : SchemaNode

A main file upload node class

Use this node in a custom schema. Then, on submit :

>>> class Schema(colander.Schema):
        filenodename = FileNode(title="Fichier")

# You need to pass the name before merging the appstruct >>> f_object = File(

parent=parent_obj, name=appstruct[“filenodename”][“name”]

) >>> merge_session_with_post(f_object, appstruct) >>> dbsession.add(f_object)

after_bind(node, kw)
default_max_size = 1048576
schema_type

alias de FileData

title = 'Choix du fichier'
validator(node, value)

Build a file size validator

widget = <colander.deferred object>
class endi.forms.files.FileTypeNode(*args, **kw)

Bases : SchemaNode

after_bind(node, kw)
schema_type

alias de Integer

title = 'Type de document'
widget = <colander.deferred object>
class endi.forms.files.FileUploadSchema(*args, **kw)

Bases : Schema

class endi.forms.files.ImageNode(*args, **kw)

Bases : FileNode

after_bind(node, kw)
validator(node, value)

Build a file size validator

class endi.forms.files.SessionDBFileUploadTempStore(request, filters=None)

Bases : SessionFileUploadTempStore

A session based File upload temp store

Is necessary for deform’s upload widget to be able to keep the datas when there are errors on form validation

request

The current request object

filter_data(fbuf)

Pass file datas through filters

class endi.forms.files.UserDatasFileUploadSchema(*args, **kw)

Bases : FileUploadSchema

Return the specific form schema for userdata’s file upload

filter_by_userdata(kw)
get_career_path_label()

génère un label pour l’étape de parcours

Paramètres:

node (obj) – L’étape de parcours

endi.forms.files.get_businesstype_filetype_template_upload_schema()

Return the form schema for business type / file type template upload

endi.forms.files.get_deferred_filtered_image_upload_widget(filters: list)

Build a deferrred returning a file upload widget filtering the incoming images

>>> from endi.utils.image import ImageResizer, ImageRatio
>>> filters = [ ImageRatio(4,1), ImageResizer(400, 100),]
>>> class MySchema(colander.Schema):
...     image = ImageNode(
...         widget=get_deferred_filtered_image_upload_widget(filters)
...     )
endi.forms.files.get_file_upload_schema()
endi.forms.files.get_template_upload_schema()

Return the form schema for template upload

endi.forms.holiday module

form schemas for holiday declaration

class endi.forms.holiday.HolidaySchema(*args, **kw)

Bases : Schema

class endi.forms.holiday.HolidaysList(*args, **kw)

Bases : SequenceSchema

class endi.forms.holiday.HolidaysSchema(*args, **kw)

Bases : Schema

class endi.forms.holiday.SearchHolidaysSchema(*args, **kw)

Bases : Schema

endi.forms.holiday.date_validator(form, value)

endi.forms.job module

Job related forms

endi.forms.job.get_list_schema()

Return the schema for the job list search form

endi.forms.jsonschema module

class endi.forms.jsonschema.ArrayTypeConverter(dispatcher: TypeConversionDispatcher)

Bases : TypeConverter

convert_type(schema_node, converted)
Type renvoyé:

dict

convert_validator = <endi.forms.jsonschema.ValidatorConversionDispatcher object>
type = 'array'
class endi.forms.jsonschema.BaseStringTypeConverter(dispatcher: TypeConversionDispatcher)

Bases : TypeConverter

convert_type(schema_node, converted)
Type renvoyé:

dict

format = None
type = 'string'
class endi.forms.jsonschema.BooleanTypeConverter(dispatcher: TypeConversionDispatcher)

Bases : TypeConverter

type = 'boolean'
exception endi.forms.jsonschema.ConversionError

Bases : Exception

class endi.forms.jsonschema.DateTimeTypeConverter(dispatcher: TypeConversionDispatcher)

Bases : BaseStringTypeConverter

format = 'date-time'
class endi.forms.jsonschema.DateTypeConverter(dispatcher: TypeConversionDispatcher)

Bases : BaseStringTypeConverter

format = 'date'
class endi.forms.jsonschema.IntegerTypeConverter(dispatcher: TypeConversionDispatcher)

Bases : NumberTypeConverter

type = 'integer'
exception endi.forms.jsonschema.NoSuchConverter

Bases : ConversionError

class endi.forms.jsonschema.NumberTypeConverter(dispatcher: TypeConversionDispatcher)

Bases : TypeConverter

convert_validator = <endi.forms.jsonschema.ValidatorConversionDispatcher object>
type = 'number'
class endi.forms.jsonschema.ObjectTypeConverter(dispatcher: TypeConversionDispatcher)

Bases : TypeConverter

convert_type(schema_node, converted)
Type renvoyé:

dict

type = 'object'
class endi.forms.jsonschema.StringTypeConverter(dispatcher: TypeConversionDispatcher)

Bases : BaseStringTypeConverter

convert_validator = <endi.forms.jsonschema.ValidatorConversionDispatcher object>
class endi.forms.jsonschema.TimeTypeConverter(dispatcher: TypeConversionDispatcher)

Bases : BaseStringTypeConverter

format = 'time'
class endi.forms.jsonschema.TypeConversionDispatcher(converters=None)

Bases : object

converters = {<class 'colander.Boolean'>: <class 'endi.forms.jsonschema.BooleanTypeConverter'>, <class 'colander.Date'>: <class 'endi.forms.jsonschema.DateTypeConverter'>, <class 'colander.DateTime'>: <class 'endi.forms.jsonschema.DateTimeTypeConverter'>, <class 'colander.Float'>: <class 'endi.forms.jsonschema.NumberTypeConverter'>, <class 'colander.Integer'>: <class 'endi.forms.jsonschema.IntegerTypeConverter'>, <class 'colander.Mapping'>: <class 'endi.forms.jsonschema.ObjectTypeConverter'>, <class 'colander.Sequence'>: <class 'endi.forms.jsonschema.ArrayTypeConverter'>, <class 'colander.String'>: <class 'endi.forms.jsonschema.StringTypeConverter'>, <class 'colander.Time'>: <class 'endi.forms.jsonschema.TimeTypeConverter'>}
class endi.forms.jsonschema.TypeConverter(dispatcher: TypeConversionDispatcher)

Bases : object

convert_type(schema_node: SchemaNode, converted: dict) dict
convert_validator(schema_node: SchemaNode) dict
type = ''
class endi.forms.jsonschema.ValidatorConversionDispatcher(*converters)

Bases : object

convert_all_validator(schema_node, validator)
Type renvoyé:

dict

endi.forms.jsonschema.convert_length_validator_factory(max_key: str, min_key: str) Callable
endi.forms.jsonschema.convert_oneof_validator_factory(null_values: Iterable = (None,)) Callable
endi.forms.jsonschema.convert_range_validator(schema_node: SchemaNode, validator: Callable) dict
Type renvoyé:

dict

endi.forms.jsonschema.convert_regex_validator(schema_node: SchemaNode, validator)
Type renvoyé:

dict

endi.forms.jsonschema.convert_to_jsonschema(schema_node: Union[Schema, SQLAlchemySchemaNode], converters: Optional[dict] = None) dict

Convert a colander schema to jsonschema format

Paramètres:
  • schema_node (colander.Schema) – The Colander Schema

  • converters (dict, optional) – prepopulated jsonschema dict, defaults to None

Renvoie:

A jsonschema representation of the form

Type renvoyé:

dict

endi.forms.jsonschema.finalize_conversion(converted)
Type renvoyé:

dict

endi.forms.lists module

class endi.forms.lists.BaseListsSchema(*args, **kw)

Bases : Schema

Base List schema used to validate the common list view options raw search pagination arguments sort parameters

add_custom(node)

Add behavior modified to let items_per_page at the end

add_latest(node)

Add items behind items_per_page

endi.forms.payments module

endi.forms.payments.get_amount_topay(kw)

Retrieve the amount to be paid regarding the context

endi.forms.progress_invoicing module

Form schemas used to edit an Invoice in progress_invoicing edition mode

class endi.forms.progress_invoicing.NewInvoiceSchema(*args, **kw)

Bases : Schema

endi.forms.progress_invoicing.force_two_digits_percent(value)

Limit a float entry to two digits

endi.forms.progress_invoicing.get_edit_product_schema()

Build an edition schema used to validate the Product edition

Renvoie:

An colanderalchemy SQLAlchemySchemaNode object

endi.forms.progress_invoicing.get_edit_work_schema()

Build an edition schema used to validate the Work edition

Renvoie:

An colanderalchemy SQLAlchemySchemaNode object

endi.forms.progress_invoicing.get_edit_workitem_schema()

Build an edition schema used to validate the WorkItem edition

Renvoie:

An colanderalchemy SQLAlchemySchemaNode object

endi.forms.progress_invoicing.get_new_invoice_schema()

Build a colander schema for invoice add in progressing mode

endi.forms.statistics module

endi.forms.statistics.customize_criterion_schema(criterion_type, schema, edit=False)
endi.forms.statistics.get_criterion_add_edit_schema(criterion_type, edit=False)

Returns add / edit schema for Stat criterion

endi.forms.statistics.get_defererd_uniq_validator(model, attribute)

Build a unique attribute value validator

Paramètres:
  • model (cls) – The SQLAlchemy model

  • attribute (str) – The attribute expected to be unique

endi.forms.statistics.get_entry_add_edit_schema()
endi.forms.statistics.get_sheet_add_edit_schema()
endi.forms.statistics.is_list(value)

endi.forms.treasury_files module

class endi.forms.treasury_files.MailSchema(*args, **kw)

Bases : Schema

class endi.forms.treasury_files.MailSendingSchema(*args, **kw)

Bases : Schema

class endi.forms.treasury_files.MailsSchema(*args, **kw)

Bases : SequenceSchema

endi.forms.validators module

colander validators

endi.forms.validators.validate_image_mime(node, value)

Validate mime types for image files

endi.forms.widgets module

class endi.forms.widgets.CleanMappingWidget(**kw)

Bases : MappingWidget

template = 'clean_mapping.pt'
class endi.forms.widgets.CleanSequenceWidget(**kw)

Bases : SequenceWidget

template = 'clean_sequence.pt'
class endi.forms.widgets.DateRangeMappingWidget(**kw)

Bases : MappingWidget

template = 'daterange_mapping.pt'
class endi.forms.widgets.FixedLenSequenceWidget(**kw)

Bases : SequenceWidget

item_template = 'fixed_len_sequence_item.pt'
template = 'fixed_len_sequence.pt'

endi.forms.workshop module

class endi.forms.workshop.AttendanceEntry(*args, **kw)

Bases : Schema

Relationship edition Allows to edit the attendance status

class endi.forms.workshop.Attendances(*args, **kw)

Bases : Schema

Attendance registration schema

class endi.forms.workshop.ParticipantsSequence(*args, **kw)

Bases : SequenceSchema

Schema for the list of participants

class endi.forms.workshop.TimeslotAttendanceEntries(*args, **kw)

Bases : SequenceSchema

class endi.forms.workshop.TimeslotSchema(*args, **kw)

Bases : Schema

class endi.forms.workshop.TimeslotsSequence(*args, **kw)

Bases : SequenceSchema

class endi.forms.workshop.WorkshopSchema(*args, **kw)

Bases : Schema

Schema for workshop creation/edition

validator(node, value)

Check maximum participants - check number of participants < max_participants - use max_participants = 0 for disabling this verification

endi.forms.workshop.get_deferred_tags_choices(widget_options)

Build a deferred for tags selection widget

endi.forms.workshop.get_filter_info1()
endi.forms.workshop.get_info1()
endi.forms.workshop.get_info_field(title)

returns a simple node factorizing recurent datas

endi.forms.workshop.get_list_schema(company=False, user=False, include_open=False, is_current_user=False, default_company_value=<colander.null>)

Return a schema for filtering workshop list

Paramètres:
  • company (bool) – The view is related to a company

  • user (bool) – The view is related to a user

  • include_open (bool) – Include open workshops

  • is_current_user (bool) – The view is related to the current user

endi.forms.workshop.range_validator(form, values)

Ensure start_time is before end_time

endi.forms.workshop.remove_workshop_manager_fields(node, kw)

Remove fields specific to workshop managers

endi.forms.workshop.workshop_tags_node(multiple=False, **kw)

Return a schema node for tags selection

Module contents

Main deferreds functions used in enDI

The widgets provided here are model agnostic

class endi.forms.CustomModelSchemaNode(*args, **kw)

Bases : SchemaNode

Using colanderalchemy, it generates a schema regarding a given model, for relationships, it provides a schema for adding related datas. We want to be able to configure relationships to existing datas (for example to configurable options)

This SchemaNode subclass provides the methods expected in colanderalchemy for serialization/deserialization, it allows us to insert custom schemanode in colanderalchemy SQLAlchemySchemaNode

dictify(instance)

Return the datas needed to fill the form

objectify(value)

Return the related object that have been configured

class endi.forms.CustomModelSequenceSchemaNode(*args, **kw)

Bases : SchemaNode

dictify(values)
objectify(ids)
endi.forms.DeferredAll(*validators)

Like colander.All validator but supporting deferred validators

*validators

one or several colander validators, which can be deferred or not.

Renvoie:

a deferred validator

endi.forms.clean_html_preparer(text: str) str

Preparer that clean all the html for us

endi.forms.colander_invalid_on_multiple_nodes(node: SchemaNode, childnames: List[str], message: str)

Build colander.Invalid on a node and some of its children at once

To be used in a colander schema node validator

endi.forms.come_from_node(**kw)

Return a form node for storing the come_from page url

endi.forms.customize_field(schema, field_name, widget=None, validator=None, **kw)

Customize a form schema field

Paramètres:
  • schema (obj) – the colander form schema

  • field_name (str) – The name of the field to customize

  • widget (obj) – a custom widget

  • validator (obj) – A custom validator

  • kw (dict) – Keyword args set as attributes on the schema field

endi.forms.deferred_id_validator(deferred_query)

Validate that the id belongs to one of the rows from a query

Paramètres:

deferred_query – a function returning a query, and receiving standard colander.deferred arguments

endi.forms.file_appstruct(request, file_id)

Build a form appstruct suitable for a colander File Node from a File instance

Paramètres:

instance :rtype: dict

endi.forms.flatten_appstruct(appstruct)

return a flattened appstruct, suppose all keys in the dict and subdict are unique

endi.forms.flatten_appstruct_to_key_value(appstruct, path=[], res={})

return a flattened path/value dictionnary the key contains keys/indexes/attribute names with dot “.” separator

endi.forms.force_iterable_preparer(value)

Force the value to be an iterable in case the frontend sends a single value in place of a list

endi.forms.get_date_input(**kw)

Return a date input displaying a french user friendly format

endi.forms.get_datetime_input(**kw)

Return a datetime input displaying a french user friendly format

endi.forms.get_deferred_default(model, default_key='default', id_key='id')

Return a deferred for default model selection

model

Option model having at least an id and a default attribute

default_key

A boolean attr defining which element is the default one

id_key

The default value attr

endi.forms.get_deferred_model_select(model, multi=False, mandatory=False, keys=('id', 'label'), filters=[], empty_filter_msg='', widget_class=<class 'deform.widget.SelectWidget'>)

Return a deferred select widget based on the given model

model

Option model having at least two attributes id and label

multi

Should it support multiple item selection

mandatory

Is it a mandatory entry, if not, we insert a void value default: False

keys

a 2-uple describing the (value, label) of the select’s options

filters

see _add_filter_to_model_query

widget_class

A deform widget to use. Should be compatible with the default deform.widget.SelectWidget

endi.forms.get_deferred_model_select_checkbox(model, keys=('id', 'label'), filters=[], widget_options={})

Return a deferred select widget based on the given model

model

Option model having at least two attributes id and label

keys

a 2-uple describing the (value, label) of the select’s options

filters

list of 2-uples allowing to filter the model query (attr/value)

widget_options

deform widget options

endi.forms.get_deferred_model_select_validator(model, id_key='id', filters=[])

Return a deferred validator based on the given model

model

Option model having at least two attributes id and label

id_key

The model attr used to store the related object in db (mostly id)

filters

see _add_filter_to_model_query

endi.forms.get_deferred_select(model, multi=False, mandatory=False, keys=('id', 'label'), filters=[], empty_filter_msg='', widget_class=<class 'deform.widget.SelectWidget'>)

Return a deferred select widget based on the given model

model

Option model having at least two attributes id and label

multi

Should it support multiple item selection

mandatory

Is it a mandatory entry, if not, we insert a void value default: False

keys

a 2-uple describing the (value, label) of the select’s options

filters

see _add_filter_to_model_query

widget_class

A deform widget to use. Should be compatible with the default deform.widget.SelectWidget

endi.forms.get_deferred_select_validator(model, id_key='id', filters=[])

Return a deferred validator based on the given model

model

Option model having at least two attributes id and label

id_key

The model attr used to store the related object in db (mostly id)

filters

see _add_filter_to_model_query

endi.forms.get_excluded(title=None)

Return a colanderalchemy info dict for excluded columns (includes a title for other sqla inspection tools like sqla_inspect library)

endi.forms.get_fileupload_widget(store_url, store_path, session, default_filename=None, filters=None)

return a file upload widget

Paramètres:

filters (list) – Callable filters than can filter the uploaded files

endi.forms.get_hidden_field_conf(title=None)

Return the model’s info conf to get a colanderalchemy hidden widget

endi.forms.get_model_checkbox_list_node(model, model_attrs=('id', 'label'), filters=[], **kw)

Build a colander node representing a list of items presented in a checkbox list

endi.forms.get_model_select_option_values(node, bind_params, model, keys, filters=(), add_default=True, empty_filter_msg='')

Build option list that can be used by SelectWidget and CheckboxListWidget

Paramètres:
  • model (obj) – The model to query

  • keys (tuple) – A 2-uple (idkey, labelkey) to query on the model (it’s

possible to pass callables getting the model as only argument) :param list filters: List of 2-uples (key, value) :param bool add_default: Should we add a default void value :returns: a list of 2-uples

endi.forms.get_month_options()
endi.forms.get_month_select_widget(widget_options)

Return a select widget for month selection

endi.forms.get_radio(values, mandatory=True, **kw)

Return a radio widget with the provided options

values

options as expected by the deform select widget (a sequence of 2-uples: (id, label))

endi.forms.get_select(values, multi=False, mandatory=True)

Return a select widget with the provided options

values

options as expected by the deform select widget (a sequence of 2-uples: (id, label))

endi.forms.get_select_validator(options)

return a validator for the given options

options

options as expected by the deform select widget (a sequence of 2-uples : (id, label))

endi.forms.get_sequence_child_item(model, required=False, child_attrs=('id', 'label'), filters=[])

Return the schema node to be used for sequence of related elements configuration

Usefull in a many to many or one to many relationships. Needed to be able to configure a sequence of relations to existing objects

e.g:

ICPE_codes = relationship(

« ICPECode », secondary=ICPE_CODE_ASSOCIATION_TABLE, info={

“colanderalchemy”:{

“title”: _(« Code(s) ICPE »), “children”: forms.get_sequence_child_item(model)

}

}, backref= »company_info »,

)

Paramètres:
  • model (obj) – The model used for child items

  • required (bool) – At least one element is required ?

  • child_attrs (tuple) – The child attributes used to build the options in

the form (“id_attr”, “label_attr”) in most cases id_attr is used as foreign key and label_attr is the model’s attribute used for display :param filters: see _add_filter_to_model_query for details

endi.forms.get_sequence_child_item_id_node(model, **kw)

Build a child item SchemaNode compatible with colanderalchemy’s serialization technic it provides a node with dictify and objectify methods

It can be used when editing M2M or O2M relationships

Paramètres:

model (obj) – The model we relay

endi.forms.get_year_select_deferred(query_func, default_val=None)

return a deferred widget for year selection :param query_func: the query function returning a list of years (taks kw as parameters)

endi.forms.id_node()

Return a node for id recording (usefull in edition forms for retrieving original objects)

endi.forms.mail_node(**kw)

Return a generic customized mail input field

endi.forms.mail_validator()

Return an email entry validator with a custom error message

endi.forms.max_len_validator(length)

Build a colander length validator for max length

endi.forms.merge_session_with_post(model, app_struct, remove_empty_values=True)

Merge Deform validated datas with SQLAlchemy’s objects Allow to spare some lines of assigning datas to the object before writing to database

model

The sqlalchemy model

app_struct

The datas retrieved for example from a form

remove_empty_values

should we remove the colander.null / None values or set them on model.

endi.forms.mk_choice_node_factory(base_node_factory, resource_name, resource_name_plural=None, **parent_kw)

Specialize a node factory using Select2Widget to an item chooser among a list of items.

Typical use: field in add/edit form (think ForeignKey)

Paramètres:
  • base_node_factory (function) – a base node factory

  • str (resource_name_plural) – the name of the resource to be selected (used in widget strings and as default title)

  • str – the pluralized form of the resource name

endi.forms.mk_filter_node_factory(base_node_factory, empty_filter_msg, **parent_kw)

Specialize a a node factory using Select2Widget to a list filtering node factory.

Paramètres:
  • base_node_factory (function) – a base node factory

  • str (empty_filter_msg) – the name of the list item for « no filter » (used in widget strings)

endi.forms.month_select_node(**kw)

Return a select widget for month selection

endi.forms.now_node(**kw)

Return a schema node for time selection, defaulted to « now »

endi.forms.popup_node(**kw)

Return a form node for storing the come_from page url

endi.forms.public_file_appstruct(request, config_key, file_object)

Build a form appstruct suitable for a colander File Node from a ConfigFile instance

Paramètres:
  • request (obj) – The Pyramid request

  • config_key (str) – The config key under which the file is stored :param

obj file_object: A endi.models.files.ConfigFile instance :rtype: dict

endi.forms.range_validator(appstruct)

Validate that start and end keys are in the good order (dates, amounts …)

Paramètres:

appstruct (dict) – The validated datas containing a start and a

end key

endi.forms.reorder_schema(schema, child_order)

reorder a schema folowing the child_order

Paramètres:
  • schema (obj) – The colander schema colander.Schema

  • child_order (tuple) – The children order

Renvoie:

The schema

Type renvoyé:

colander.Schema

endi.forms.richtext_widget(options=None, widget_options=None, admin=False)

Return a text area widget

endi.forms.status_filter_node(status_options, name='status', title='Statut', default='all')

« Filter by status » SchemaNode for listings

endi.forms.textarea_node(**kw)

Return a node for storing Text objects

richtext (True / False)

should we provide a rich text widget if True, richtext_options dict values will be passed to the CKEditor library

admin (True / False)

Should we provide a widget with all options

widget_options

Options passed to the widget’s class

endi.forms.today_node(**kw)

Return a schema node for date selection, defaulted to today

endi.forms.truncate_preparer(max_len)

Build a truncate function to be used as a schemaNode preparer The function truncate a string to limit its length to the max number of characters

Paramètres:

max_len (str) – The max number of characters

Renvoie:

A preparer function

endi.forms.uniq_entries_preparer(cstruct)

Add this one as a preparer to a colander.SchemaNode of type Sequence in order to remove duplicates and None values

endi.forms.year_filter_node(query_func, **kw)
endi.forms.year_select_node(query_func, **kw)

Return a year select node with defaults and missing values

Paramètres:

query_func – a function to call that return the years we want to display