org.forms.parliamentarian

Classes

ParliamentarianForm

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

Module Contents

class org.forms.parliamentarian.ParliamentarianForm(*args: Any, **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)
    ...
gender[source]
first_name[source]
last_name[source]
picture[source]
private_address[source]
private_address_addition[source]
private_address_zip_code[source]
private_address_city[source]
date_of_birth[source]
place_of_origin[source]
occupation[source]
academic_title[source]
salutation[source]
phone_private[source]
phone_mobile[source]
phone_business[source]
email_primary[source]
email_secondary[source]
website[source]
remarks[source]
interest_ties[source]
interest_tie_errors: dict[int, str][source]
on_request() None[source]
process_obj(obj: onegov.parliament.models.parliamentarian.Parliamentarian) None[source]

Called by process() if an object was passed.

Do not use this function directly. To process an object, you should call form.process(obj=obj) instead.

populate_obj(obj: object, *args: Any, **kwargs: Any) 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.

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.

interest_ties_to_json(interest_ties: dict[str, Any]) str[source]
json_to_interest_ties(text: str | None) list[dict[str, str]][source]