AKModel.metaviews.status module

class AKModel.metaviews.status.StatusWidget[source]

Bases: ABC

Abstract parent for status page widgets

abstract property required_context_type: str

Which model/context is needed to render this widget?

get_context_data(context) dict[source]

Allow to manipulate the context :return: context (with or without changes)

render(context: {}, request) dict[source]

Render widget based on context

Parameters:
  • context – Context for rendering

  • request – HTTP request, needed for rendering

Returns:

Dictionary containing the rendered/prepared information

render_title(context: {}) str[source]

Render title for widget based on context

By default, the title attribute is used without modification :param context: Context for rendering :return: Rendered title

render_status(context: {}) str[source]

Render status for widget based on context

By default, the status attribute is used without modification :param context: Context for rendering :return: Rendered title

abstract render_body(context: {}, request) str[source]

Render body for widget based on context

Parameters:
  • context – Context for rendering

  • request – HTTP request (needed for rendering)

Returns:

Rendered widget body (HTML)

render_actions(context: {}) list[dict][source]

Render actions for widget based on context

By default, all actions specified for this widget are returned without modification

Parameters:

context – Context for rendering

Returns:

List of actions

class AKModel.metaviews.status.TemplateStatusWidget[source]

Bases: StatusWidget

A StatusWidget that produces its content by rendering a given html template

abstract property template_name: str

Configure the template to use :return: name of the template to use

render_body(context: {}, request) str[source]

Render the body of the widget using the template rendering method from django (load and render template using the provided context)

Parameters:
  • context – context to use for rendering

  • request – HTTP request (needed by django)

Returns:

rendered content (HTML)

class AKModel.metaviews.status.StatusManager[source]

Bases: object

Registry for all status widgets

Allows to register status widgets using the @status_manager.register(name=”xyz”) decorator

register(name: str)[source]

Call this as @status_manager.register(name=”xyz”) to register a status widget

Parameters:

name – name of this widget (only used internally). Has to be unique.

get_by_context_type(context_type: str)[source]

Filter widgets for ones suitable for provided context

Parameters:

context_type – name of the model provided as context

Returns:

a list of all matching widgets

class AKModel.metaviews.status.StatusView(**kwargs)[source]

Bases: ABC, AdminViewMixin, TemplateView

Abstract view: A generic base view to create a status page holding multiple widgets

abstract property provided_context_type: str

Which model/context is provided by this status view?