hawat.forms module¶
This module contains usefull form related classes for Hawat application views.
-
class
hawat.forms.
BaseItemForm
(*args, **kwargs)[source]¶ Bases:
flask_wtf.form.FlaskForm
Class representing generic item action (create/update/delete) form for hawat application.
This form contains support for redirection back to original page.
-
static
is_multivalue
(field_name)[source]¶ Check, if given form field is a multivalue field.
- Parameters
field_name (str) – Name of the form field.
- Returns
True
, if the field can contain multiple values,False
otherwise.- Return type
bool
-
next
= <UnboundField(HiddenField, (), {})>¶
-
static
-
class
hawat.forms.
BaseSearchForm
(formdata=<object object>, **kwargs)[source]¶ Bases:
flask_wtf.form.FlaskForm
Class representing generic item search form for hawat application.
This form contains support for result limiting and paging.
-
static
is_multivalue
(field_name)[source]¶ Check, if given form field is a multivalue field.
- Parameters
field_name (str) – Name of the form field.
- Returns
True
, if the field can contain multiple values,False
otherwise.- Return type
bool
-
limit
= <UnboundField(SelectField, (l'Pager limit:',), {'validators': [<wtforms.validators.Optional object>], 'filters': [<class 'int'>], 'choices': [(5, 5), (10, 10), (20, 20), (25, 25), (50, 50), (100, 100), (200, 200), (250, 250), (500, 500), (1000, 1000), (2500, 2500), (5000, 5000), (10000, 10000), (25000, 25000), (50000, 50000), (100000, 100000)], 'default': 100})>¶
-
page
= <UnboundField(IntegerField, (l'Page number:',), {'validators': [<wtforms.validators.Optional object>, <wtforms.validators.NumberRange object>], 'filters': [<class 'int'>], 'default': 1})>¶
-
submit
= <UnboundField(SubmitField, (l'Search',), {})>¶
-
static
-
class
hawat.forms.
CommaListField
(label=None, validators=None, filters=(), description='', id=None, default=None, widget=None, render_kw=None, _form=None, _name=None, _prefix='', _translations=None, _meta=None)[source]¶ Bases:
wtforms.fields.core.Field
Custom widget representing list of strings as comma separated list.
-
process_formdata
(valuelist)[source]¶ Process data received over the wire from a form.
This will be called during form construction with data supplied through the formdata argument.
- Parameters
valuelist – A list of strings to process.
-
widget
= <wtforms.widgets.core.TextInput object>¶
-
-
class
hawat.forms.
DateTimeLocalField
(label=None, validators=None, format='%Y-%m-%d %H:%M:%S', **kwargs)[source]¶ Bases:
wtforms.fields.core.DateTimeField
DateTimeField that assumes input is in app-configured timezone and converts to UTC for further processing/storage.
-
class
hawat.forms.
ItemActionConfirmForm
(*args, **kwargs)[source]¶ Bases:
hawat.forms.BaseItemForm
Class representing generic item action confirmation form for hawat application.
This form contains nothing else but two buttons, one for confirmation, one for canceling the delete action. Actual item identifier is passed as part of the URL.
-
cancel
= <UnboundField(SubmitField, (l'Cancel',), {})>¶
-
submit
= <UnboundField(SubmitField, (l'Confirm',), {})>¶
-
-
class
hawat.forms.
RadioFieldWithNone
(label=None, validators=None, coerce=<class 'str'>, choices=None, **kwargs)[source]¶ Bases:
wtforms.fields.core.RadioField
RadioField that accepts None as valid choice.
-
class
hawat.forms.
SelectFieldWithNone
(label=None, validators=None, coerce=<class 'str'>, choices=None, **kwargs)[source]¶ Bases:
wtforms.fields.core.SelectField
SelectField that accepts None as valid choice.
-
class
hawat.forms.
SmartDateTimeField
(label=None, validators=None, formats=None, **kwargs)[source]¶ Bases:
wtforms.fields.core.Field
DateTimeField that assumes input is in app-configured timezone and converts to UTC for further processing/storage. This widget allows multiple datetime representations on input and is smart to recognize ISO formated timestamp in UTC on input, which greatly simplifies generating URLs from within the application.
-
process_data
(value)[source]¶ Process the Python data applied to this field and store the result. This will be called during form construction by the form’s kwargs or obj argument. :param value: The python object containing the value to process.
-
process_formdata
(valuelist)[source]¶ Process data received over the wire from a form. This will be called during form construction with data supplied through the formdata argument. :param valuelist: A list of strings to process.
-
utcisoformat
= '%Y-%m-%dT%H:%M:%SZ'¶
-
widget
= <wtforms.widgets.core.TextInput object>¶
-
-
hawat.forms.
check_email
(_form, field)[source]¶ Callback for validating user emails or account logins (usernames).
-
hawat.forms.
check_int_list
(_form, field)[source]¶ Callback for validating list of positive integers.
-
hawat.forms.
check_login
(_form, field)[source]¶ Callback for validating user account logins (usernames).
-
hawat.forms.
check_network_record_list
(_form, field)[source]¶ Callback for validating list of network records.
-
hawat.forms.
check_null_character
(_form, field)[source]¶ Callback for validating string fields which should not contain 0x00.
-
hawat.forms.
check_unique_group
(_form, field)[source]¶ Callback for validating of uniqueness of group name.
-
hawat.forms.
check_unique_login
(_form, field)[source]¶ Callback for validating of uniqueness of user login.
-
hawat.forms.
default_dt
()[source]¶ Create default timestamp for datetime form values with given time delta in days and adjust the result to whole hours.
-
hawat.forms.
default_dt_with_delta
(delta=7)[source]¶ Create default timestamp for datetime form values with given time delta in days and adjust the result to whole hours.
-
hawat.forms.
get_available_group_sources
()[source]¶ Query the database for list of network record sources.