Views

class plinth.views.AppView(*args: Any, **kwargs: Any)[source]

A generic view for showing an app’s main page.

The view and it’s template may be customized but by default show the following:

  • Icon for the app

  • Name of the app

  • Description of the app

  • Link to the manual page for the app

  • A button to enable/disable the app

  • A toolbar with common actions such as ‘Run diagnostics’

  • A status section showing the running status of the app

  • A form for configuring the app

The following class properties are available on the view:

‘app_id’ is the mandatory property to set the ID of the app. It is used to retrieve the App instance for the app that is needed for basic information and operations such as enabling/disabling the app.

‘form_class’ is the Django form class that is used by this view. It may be None if the app does not have a configuration form. Default is None.

‘template_name’ is the template used to render this view. By default it is app.html. It may be overridden with a template that derives from app.html to customize the appearance of the app to achieve more complex presentation instead of the simple appearance provided by default.

__init__(*args, **kwargs)[source]

Initialize the view.

property app

Return the app for which this view is configured.

enable_disable_form_valid(form)[source]

Form handling for enabling / disabling apps.

form_valid(form)[source]

Enable/disable a service and set messages.

get_context_data(*args, **kwargs)[source]

Add service to the context data.

get_enable_disable_form()[source]

Return an instance of the app enable/disable form.

If the app can’t be disabled by the user, return None.

get_form(*args, **kwargs)[source]

Return an instance of this view’s form.

Also the form_class for this view to be None.

get_initial()[source]

Return the status of the app to fill in the form.

post(request, *args, **kwargs)[source]

Handle app enable/disable button separately.