Ejemplo n.º 1
0
def get_list_schema():
    schema = forms.lists.BaseListsSchema().clone()

    schema["search"].description = u"Identifiant du document"

    schema.insert(
        0,
        colander.SchemaNode(
            colander.String(),
            name=u"status",
            widget=deform.widget.SelectWidget(values=STATUS_OPTIONS),
            validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]),
            missing="all",
        ),
    )

    schema.insert(0, forms.year_select_node(name="year", title=u"Année", query_func=get_expense_years))

    schema.insert(
        0, forms.month_select_node(title=u"Mois", missing=-1, name="month", widget_options={"default_val": (-1, "")})
    )

    schema.insert(
        0,
        user.user_node(
            title=u"Utilisateur",
            missing=-1,
            name=u"owner_id",
            widget_options={"default_option": (-1, ""), "placeholder": u"Sélectionner un entrepreneur"},
        ),
    )

    return schema
Ejemplo n.º 2
0
def get_list_schema():
    """
    Build a form schema for expensesheet listing
    """
    schema = forms.lists.BaseListsSchema().clone()

    schema['search'].description = u"Identifiant du document"

    schema.insert(0, colander.SchemaNode(
        colander.String(),
        name=u'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, forms.year_select_node(
        name='year',
        title=u"Année",
        query_func=get_expense_years,
    ))

    schema.insert(0, forms.month_select_node(
        title=u"Mois",
        missing=-1,
        default=-1,
        name='month',
        widget_options={'default_val': (-1, '')},
    ))

    schema.insert(0, contractor_filter_node_factory(name=u'owner_id'))

    return schema
Ejemplo n.º 3
0
def get_income_statement_measures_list_schema():
    """
    Build the schema used to list treasury measures

    :returns: A form schema
    :rtype: colander.Schema
    """
    schema = BaseListsSchema().clone()
    del schema['search']
    del schema['page']
    del schema['items_per_page']

    def get_year_options(kw):
        cid = kw['request'].context.get_company_id()
        years = IncomeStatementMeasureGrid.get_years(company_id=cid)
        current_year = datetime.date.today().year
        if current_year not in years:
            years.append(current_year)
        return years

    node = forms.year_select_node(
        name='year',
        query_func=get_year_options,
        title=u"Année"
    )

    schema.insert(0, node)
    return schema
Ejemplo n.º 4
0
def get_list_schema(company=False):
    """
    Return a schema for filtering workshop list
    """
    schema = lists.BaseListsSchema().clone()

    schema.insert(
        0,
        forms.today_node(
            name='date',
            default=colander.null,
            missing=colander.drop,
            description=u"Date de l'atelier",
            widget_options={'css_class': 'input-medium search-query'},
            ))

    schema.insert(
        0,
        trainer_filter_node_factory(name='trainer_id'),
    )

    if not company:
        schema.insert(
            0,
            participant_filter_node_factory(name='participant_id')
        )
        notfilled_node = colander.SchemaNode(
            colander.Boolean(),
            name='notfilled',
            title="",
            description=u"N'afficher que les ateliers non renseignés",
            missing=colander.drop,
        )
        schema.insert(1, notfilled_node)

    year = forms.year_select_node(
        name='year',
        query_func=get_invoice_years,
        widget_options={'default_val': (-1, u"Toutes les années")},
        missing=colander.null,
        description=u"Année"
    )
    schema.insert(0, year)

    info_id_1 = colander.SchemaNode (
            colander.Integer(),
            name='info_1_id',
            missing=colander.drop,
            widget=deferred_filter_info1,
        )
    schema.insert(0, info_id_1)

    schema['search'].description = u"Intitulé de l'atelier"
    return schema
Ejemplo n.º 5
0
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',
            ))

    schema.insert(0, company.customer_node(is_admin))

    if is_admin:
        schema.insert(
            0,
            colander.SchemaNode(
                custom_types.AmountType(),
                name='ttc',
                missing=colander.drop,
                description=u"Montant TTC",
            )
        )

        schema.insert(
            0,
            company.company_node(
                name='company_id',
                missing=colander.drop,
                widget_options={'default': ('', u'Toutes les entreprises')}
            )
        )

    node = forms.year_select_node(
        name='year',
        query_func=invoice.get_invoice_years,
    )

    schema.insert(0, node)

    schema['search'].description = u"Identifiant du document"

    return schema
Ejemplo n.º 6
0
def get_list_schema():
    schema = forms.lists.BaseListsSchema().clone()

    del schema['search']

    schema.insert(0, company.customer_node())

    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'
    ))
    node = forms.year_select_node(
        name='year',
        query_func=get_invoice_years,
    )
    schema.insert(0, node)

    return schema
Ejemplo n.º 7
0
def get_treasury_measures_list_schema():
    """
    Build the schema used to list treasury measures

    :returns: A form schema
    :rtype: colander.Schema
    """
    schema = BaseListsSchema().clone()
    del schema['search']

    def get_year_options(kw):
        return TreasuryMeasureGrid.get_years()

    node = forms.year_select_node(
        name='year',
        query_func=get_year_options,
        missing=-1,
        description=u"Année de dépôt"
    )

    schema.insert(0, node)
    return schema
Ejemplo n.º 8
0
def get_list_schema(company=False):
    """
    Return a schema for filtering workshop list
    """
    schema = lists.BaseListsSchema().clone()

    schema.insert(
        0,
        forms.today_node(
            name='date',
            default=colander.null,
            missing=colander.drop,
            description=u"Date de l'atelier",
            widget_options={'css_class': 'input-medium search-query'},
            ))

    if not company:
        schema.insert(0, user.user_node(
            missing=colander.drop,
            name='participant_id',
            widget_options={
                'default_option': ('', u"- Sélectionner un participant -"),
                }
        ))
        notfilled_node = colander.SchemaNode(
            colander.Boolean(),
            name='notfilled',
            title="",
            description=u"N'afficher que les ateliers non renseignés",
            missing=colander.drop,
        )
        schema.insert(1, notfilled_node)
    year = forms.year_select_node(get_invoice_years)
    year.name = 'year'
    schema.insert(0, year)

    schema['search'].description = u"Intitulé de l'atelier"
    return schema
Ejemplo n.º 9
0
def get_list_schema():
    schema = forms.lists.BaseListsSchema().clone()

    schema['search'].description = u"Identifiant du document"

    schema.insert(0, colander.SchemaNode(
        colander.String(),
        name=u'status',
        widget=deform.widget.SelectWidget(values=STATUS_OPTIONS),
        validator=colander.OneOf([s[0] for s in STATUS_OPTIONS]),
        missing='all',
    ))

    schema.insert(0, forms.year_select_node(
        name='year',
        title=u"Année",
        query_func=get_expense_years,
    ))

    schema.insert(0, forms.month_select_node(
        title=u"Mois",
        missing=-1,
        name='month',
        widget_options={'default_val': (-1, '')},
    ))

    schema.insert(0, user.user_node(
        title=u"Utilisateur",
        missing=-1,
        name=u'owner_id',
        widget_options={
            'default_option': (-1, ''),
            'placeholder': u"Sélectionner un entrepreneur"},
    ))

    return schema
Ejemplo n.º 10
0
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',
            with_invoice=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 '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
Ejemplo n.º 11
0
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',
        )
    )

    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',
        )
    )

    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=deform.widget.MappingWidget(
                template=TEMPLATES_URL + 'clean_mapping.pt',
            ),
            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=deform.widget.MappingWidget(
                template=TEMPLATES_URL + 'clean_mapping.pt',
            ),
            missing=colander.drop,
        )
    )

    node = forms.year_select_node(
        name='year',
        query_func=invoice.get_invoice_years,
    )

    schema.insert(0, node)

    schema['search'].description = u"Identifiant du document"

    return schema
Ejemplo n.º 12
0
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=deform.widget.MappingWidget(
                template=TEMPLATES_URL + 'clean_mapping.pt',
            ),
            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=deform.widget.MappingWidget(
                template=TEMPLATES_URL + 'clean_mapping.pt',
            ),
            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]),
        missing='all'
    ))
    node = forms.year_select_node(
        name='year',
        query_func=get_invoice_years,
    )
    schema.insert(0, node)

    return schema
Ejemplo n.º 13
0
def get_list_schema(is_admin=False):
    schema = lists.BaseListsSchema().clone()

    schema.insert(
        0,
        forms.today_node(
            name="date_range_end",
            default=colander.null,
            missing=colander.drop,
            description=u"Et le",
            widget_options={'css_class': 'input-medium search-query'},
        )
    )

    schema.insert(
        0,
        forms.today_node(
            name="date_range_start",
            default=colander.null,
            missing=colander.drop,
            description=u"Entre le",
            widget_options={'css_class': 'input-medium search-query'},
        )
    )

    schema.insert(0, colander.SchemaNode(
        colander.Integer(),
        name='type_id',
        widget=get_deferred_select_type(True),
        validator=deferred_type_validator,
        missing=colander.drop))

    schema.insert(0, colander.SchemaNode(
        colander.String(),
        name='status',
        widget=deform.widget.SelectWidget(values=STATUS_SEARCH),
        validator=colander.OneOf([s[0] for s in STATUS_SEARCH]),
        missing=colander.drop))

    schema.insert(0, colander.SchemaNode(
        colander.String(),
        name='user_status',
        widget=deform.widget.SelectWidget(values=ATTENDANCE_STATUS_SEARCH),
        validator=colander.OneOf([s[0] for s in ATTENDANCE_STATUS_SEARCH]),
        missing=colander.drop))

    if is_admin:
        schema.insert(0, participant_filter_node_factory(name='participant_id'))
        schema.insert(0, conseiller_filter_node_factory(name='conseiller_id'))

    year = forms.year_select_node(
        name='year',
        query_func=get_invoice_years,
        widget_options={'default_val': (-1, u"Toutes les années")},
        missing=colander.null,
        description=u"Année"
    )
    schema.insert(0, year)

    del schema['search']
    return schema
Ejemplo n.º 14
0
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
Ejemplo n.º 15
0
def get_list_schema(is_admin=False):
    schema = lists.BaseListsSchema().clone()

    schema.insert(
        0,
        forms.today_node(
            name="date_range_end",
            default=colander.null,
            missing=colander.drop,
            description=u"Et le",
            widget_options={'css_class': 'input-medium search-query'},
        )
    )

    schema.insert(
        0,
        forms.today_node(
            name="date_range_start",
            default=colander.null,
            missing=colander.drop,
            description=u"Entre le",
            widget_options={'css_class': 'input-medium search-query'},
        )
    )

    schema.insert(0, colander.SchemaNode(
        colander.Integer(),
        name='type_id',
        widget=get_deferred_select_type(True),
        validator=deferred_type_validator,
        missing=colander.drop))

    schema.insert(0, colander.SchemaNode(
        colander.String(),
        name='status',
        widget=deform.widget.SelectWidget(values=STATUS_SEARCH),
        validator=colander.OneOf([s[0] for s in STATUS_SEARCH]),
        missing=colander.drop))

    schema.insert(0, colander.SchemaNode(
        colander.String(),
        name='user_status',
        widget=deform.widget.SelectWidget(values=ATTENDANCE_STATUS_SEARCH),
        validator=colander.OneOf([s[0] for s in ATTENDANCE_STATUS_SEARCH]),
        missing=colander.drop))

    if is_admin:
        schema.insert(0, user.user_node(
            missing=colander.drop,
            name='participant_id',
            widget_options={
                'default_option': ("", u"- Sélectionner un participant -"),
            }
            )
        )

        schema.insert(0, user.user_node(
            roles=['manager', 'admin'],
            missing=colander.drop,
            name='conseiller_id',
            widget_options={
                'default_option': ("", u"- Sélectionner un conseiller -"),
            }
            )
        )
    year = forms.year_select_node(get_invoice_years)
    year.name = 'year'
    schema.insert(0, year)

    del schema['search']
    return schema