wuttaweb.forms.widgets
¶
Form widgets
This module defines some custom widgets for use with WuttaWeb.
However for convenience it also makes other Deform widgets available in the namespace:
deform.widget.Widget
(base class)
- class wuttaweb.forms.widgets.BatchIdWidget(**kw)[source]¶
Widget for use with the
id
field of a batch model.This widget is “always” read-only and renders the Batch ID as zero-padded 8-char string
- class wuttaweb.forms.widgets.FileDownloadWidget(request, *args, **kwargs)[source]¶
Widget for use with
FileDownload
fields.This only supports readonly, and shows a hyperlink to download the file. Link text is the filename plus file size.
This is a subclass of
deform.widget.Widget
and uses these Deform templates:readonly/filedownload
- Parameters:
request – Current request object.
url – Optional URL for hyperlink. If not specified, file name/size is shown with no hyperlink.
- class wuttaweb.forms.widgets.GridWidget(request, grid, *args, **kwargs)[source]¶
Widget for fields whose data is represented by a grid.
This is a subclass of
deform.widget.Widget
but does not use any Deform templates.This widget only supports “readonly” mode, is not editable. It is merely a convenience around the grid itself, which does the heavy lifting.
Instead of creating this widget directly you probably should call
set_grid()
on your form.- serialize(field, cstruct, **kw)[source]¶
This widget simply calls
render_table_element()
on thegrid
to serialize.
- class wuttaweb.forms.widgets.NotesWidget(**kw)[source]¶
Widget for use with “notes” fields.
In readonly mode, this shows the notes with a background to make them stand out a bit more.
Otherwise it effectively shows a
<textarea>
input element.This is a subclass of
deform.widget.TextAreaWidget
and uses these Deform templates:textarea
readonly/notes
- class wuttaweb.forms.widgets.ObjectRefWidget(request, url=None, *args, **kwargs)[source]¶
Widget for use with model “object reference” fields, e.g. foreign key UUID => TargetModel instance.
While you may create instances of this widget directly, it normally happens automatically when schema nodes of the
ObjectRef
(sub)type are part of the form schema; viawidget_maker()
.In readonly mode, this renders a
<span>
tag around themodel_instance
(converted to string).Otherwise it renders a select (dropdown) element allowing user to choose from available records.
This is a subclass of
deform.widget.SelectWidget
and uses these Deform templates:select
readonly/objectref
- class wuttaweb.forms.widgets.PermissionsWidget(request, session=None, *args, **kwargs)[source]¶
Widget for use with Role
permissions
field.This is a subclass of
WuttaCheckboxChoiceWidget
. It uses these Deform templates:permissions
readonly/permissions
- class wuttaweb.forms.widgets.RoleRefsWidget(request, session=None, *args, **kwargs)[source]¶
Widget for use with User
roles
field. This is the default widget for theRoleRefs
type.This is a subclass of
WuttaCheckboxChoiceWidget
.
- class wuttaweb.forms.widgets.UserRefsWidget(request, session=None, *args, **kwargs)[source]¶
Widget for use with Role
users
field. This is the default widget for theUserRefs
type.This is a subclass of
WuttaCheckboxChoiceWidget
; however it only supports readonly mode and does not use a template. Rather, it generates and renders aGrid
showing the users list.
- class wuttaweb.forms.widgets.WuttaCheckboxChoiceWidget(request, session=None, *args, **kwargs)[source]¶
Custom widget for
set
fields.This is a subclass of
deform.widget.CheckboxChoiceWidget
, but adds Wutta-related params to the constructor.- Parameters:
request – Current request object.
session – Optional db session to use instead of
wuttaweb.db.sess.Session
.
It uses these Deform templates:
checkbox_choice
readonly/checkbox_choice
- class wuttaweb.forms.widgets.WuttaDateTimeWidget(request, *args, **kwargs)[source]¶
Custom widget for
datetime.datetime
fields.The main purpose of this widget is to leverage
render_datetime()
for the readonly display.It is automatically used for SQLAlchemy mapped classes where the field maps to a
sqlalchemy.types.DateTime
column. For other (non-mapped) datetime fields, you may have to use it explicitly viaset_widget()
.This is a subclass of
deform.widget.DateTimeInputWidget
and uses these Deform templates:datetimeinput