landsgemeinde.forms.votum

Classes

VotumForm

Base class for handling database models using named files with forms.

Module Contents

class landsgemeinde.forms.votum.VotumForm(formdata: MultiDict[str, Any] | None = None, obj: object | None = None, prefix: str = '', data: dict[str, Any] | None = None, meta: dict[str, Any] | None = None, *, extra_filters: Mapping[str, Sequence[Any]] | None = None, **kwargs: Any)[source]

Bases: onegov.form.forms.NamedFileForm

Base class for handling database models using named files with forms.

Example:

class MyModel(AssociatedFiles):
    pdf = NamedFile()

class MyForm(NamedFileForm):
    pdf = UploadField('PDF')

@MyApp.form(model=MyCollection, form=MyForm, ...)
def add(self, request, form):

    if form.submitted(request):
        self.add(**form.get_useful_data())
        ...
    ...

@MyApp.form(model=MyModel, form=MyForm, ...)
def edit(self, request, form):

    if form.submitted(request):
        form.populate_obj(self)
        ...

    form.process(obj=self)
    ...
request: onegov.landsgemeinde.request.LandsgemeindeRequest[source]
number[source]
state[source]
person_choices[source]
person_name[source]
person_function[source]
person_political_affiliation[source]
person_place[source]
person_picture[source]
start_time[source]
calculated_timestamp[source]
video_timestamp[source]
text[source]
motion[source]
statement_of_reasons[source]
property next_number: int[source]
populate_person_choices() None[source]
on_request() None[source]
get_useful_data() dict[str, Any][source]

Returns the form data in a dictionary, by default excluding data that should not be stored in the db backend.

validate_number(field: wtforms.fields.IntegerField) None[source]
validate_video_timestamp(field: wtforms.fields.StringField) None[source]
populate_obj(obj: onegov.landsgemeinde.models.Votum) None[source]

A reimplementation of wtforms populate_obj function with the addage of optional include/exclude filters.

If neither exclude nor include is passed, the function works like it does in wtforms. Otherwise fields are considered which are included but not excluded.