Plugin Views
smarter.apps.plugin.views.plugin This module contains views to implement the card-style list view in the Smarter Dashboard.
- class smarter.apps.plugin.views.plugin.PluginDetailView(*args, **kwargs)[source]
Bases:
DocsBaseViewRenders the detail view for a Smarter dashboard plugin.
This view renders a detailed manifest for a specific plugin, including its configuration and metadata, in YAML format. It is intended for authenticated users and provides error handling for missing or unsupported plugin kinds and names.
- Parameters:
- Returns:
Rendered HTML page with plugin manifest details, or a 404 error page if the plugin is not found or parameters are invalid.
- Return type:
HttpResponse
Note
The plugin name and kind must be provided and valid. Otherwise, a “not found” response is returned.
See also
PluginMetafor plugin metadata retrieval.ApiV1CliDescribeApiViewfor API details.Example usage:
GET /plugin/detail/?name=my_plugin&kind=custom
- get(request, *args, **kwargs)[source]
Handle GET requests to render the plugin manifest detail view. This method processes the incoming request to retrieve the specified plugin’s manifest details and renders them in a user-friendly format. It performs validation on the provided plugin name and kind, retrieves the plugin metadata, and handles any errors that may arise during this process.
Process: 1. Extract and validate ‘name’ and ‘kind’ from kwargs. 2. Retrieve the plugin metadata using the provided name and user context. 3. If the plugin is found, call the API view to get the plugin details 4. Convert the JSON response to YAML format for better readability. 5. Render the plugin manifest detail template with the retrieved data. 6. Handle any errors that occur during the process and return appropriate error responses.
- Parameters:
- Returns:
Rendered HTML page with plugin manifest details, or an error response if the plugin is not found or parameters are invalid.
- Return type:
HttpResponse
-
plugin:
Optional[PluginMeta] = None
- template_path: Optional[str] = 'plugin/manifest_detail.html'
- class smarter.apps.plugin.views.plugin.PluginListView(*args, **kwargs)[source]
Bases:
SmarterAuthenticatedNeverCachedWebViewRender the plugin list view for the Smarter Workbench web console.
This view displays all plugins available to the authenticated user as cards, providing a quick overview and access to plugin details.
- Parameters:
- Returns:
Rendered HTML page with a card for each plugin, or a 404 error page if the user is not authenticated.
- Return type:
HttpResponse
- get(request, *args, **kwargs)[source]
Handle GET requests and return a cleaned HttpResponse.
- Parameters:
request (HttpRequest) – The HTTP request object.
- Returns:
An HttpResponse with the cleaned HTML content.
- Return type:
HttpResponse
-
plugins:
list[PluginMeta]
- template_path: str = 'plugin/plugin_list.html'