websauna.system.crud.listing module

Listing views.

class websauna.system.crud.listing.Column(id, name=None, renderer=None, header_template=None, body_template=None, getter=None, format=None, navigate_view_name=None, navigate_url_getter=None)[source]

Bases: object

Define a column in a listing.

body_template = 'crud/column_body.html'
format = 'MM/DD/YYYY HH:mm'

Arrow formatting string

get_navigate_target(resource, request)[source]

Get URL where clicking the link in the listing should go.

By default, navigate to “show” view of the resource.

Parameters
  • resource (Resource) – Traversal context

  • request (Request) – Current HTTP Request.

get_navigate_url(resource, request, view_name=None)[source]

Get the link where clicking this item should take the user.

By default, navigate to “show” view of the resource.

TODO: Switch resource/request argument order. :type resource: Resource :param resource: Traversal context :type request: Request :param request: Current HTTP Request. :type view_name: Optional[str] :param view_name: Override class’ navigate_view_name.

get_value(view, obj)[source]

Extract value from the object for this column.

Called in listing body.

Parameters
  • view (Any) – View class calling us

  • obj (Any) – The object the list is iterating. Usually an SQLAlchemy model instance.

getter = None
header_template = 'crud/column_header.html'
navigate_url_getter = None

Callback get_navigate_url(request, resource) to resolve the link where the item this column should point to

navigate_view_name = None
class websauna.system.crud.listing.ControlsColumn(id='controls', name='Actions', header_template='crud/column_header_controls.html', body_template='crud/column_body_controls.html')[source]

Bases: websauna.system.crud.listing.Column

Render View / Edit / Delete buttons.

class websauna.system.crud.listing.FriendlyTimeColumn(id, name, navigate_view_name=None, timezone=None, header_template=None, body_template='crud/column_body_friendly_time.html')[source]

Bases: websauna.system.crud.listing.Column

Print both accurate time and humanized relative time.

class websauna.system.crud.listing.StringPresentationColumn(**kwargs)[source]

Bases: websauna.system.crud.listing.Column

Renders the default string presentation of the object.

You can change the stringify method:

StringPresentationColumn(formatter=my_func)

where my_func is callable:

my_func(value)
get_value(view, obj)[source]

Extract value from the object for this column.

Called in listing body.

class websauna.system.crud.listing.Table(columns=None)[source]

Bases: object

Describe table columns to a CRUD listing view.

get_columns()[source]

Return columns.

Return type

List[Column]

Returns

List of columns to be used to render the list view.