djblets.integrations.views¶
Views for working with integrations.
- class IntegrationListContextViewMixin¶
Bases:
NeedsIntegrationManagerMixin
A mixin for views that display lists of integrations.
This allows for custom views that display details on the available integrations and all configurations.
- request: HttpRequest¶
The HTTP request for the view.
This must be set in subclasses.
- get_integration_js_view_data() Dict ¶
Return data for a JavaScript view for the page.
This will include the list of available integrations IDs, a mapping of integration IDs to details, and a list of all configurations.
- Returns:
The data for the JavaScript view.
- Return type:
- get_add_config_url(integration: Integration) str ¶
Return the URL for adding a new configuration.
This can be overridden by subclasses to return a URL for another namespace or to add additional keyword arguments for the lookup.
- Parameters:
integration (
djblets.integrations.integration.Integration
) – The integration to add configurations for.- Returns:
The Add Configuration URL for the integration.
- Return type:
- get_edit_config_url(config: BaseIntegrationConfig) str ¶
Return the URL for editing a configuration.
This can be overridden by subclasses to return a URL for another namespace or to add additional keyword arguments for the lookup.
- Parameters:
config (
djblets.integrations.models.BaseIntegrationConfig
) – The configuration to return the URL for.- Returns:
The URL for editing the configuration.
- Return type:
- get_configs_queryset() QuerySet[BaseIntegrationConfig] ¶
Return a queryset for integration configs.
Subclasses can override this to provide a more strict query to filter down the configurations.
- Returns:
A queryset for fetching integration configurations.
- Return type:
- __annotations__ = {'request': 'HttpRequest'}¶
- class BaseIntegrationListView(**kwargs)¶
Bases:
IntegrationListContextViewMixin
,TemplateView
Base class for a view that lists available integrations.
This view handles the display of all available integrations, along with any existing configurations.
This is meant to be subclassed to either fine-tune the queries for configurations (for instance, by limiting to a particular user or organization) or to add access control.
- dispatch(*args, **kwargs) HttpResponseBase ¶
Handle the request to the view.
This will first check to make sure the user is logged in.
- Parameters:
- Returns:
The resulting HTTP response.
- Return type:
- get_context_data(**kwargs) Dict ¶
Return context data for the template.
By default, this returns a dictionary with a sole
integrations
key, which contains data on each available integration and all saved configurations.
- __annotations__ = {}¶
- class BaseAdminIntegrationListView(**kwargs)¶
Bases:
BaseIntegrationListView
Base class for an admin view that lists available integrations.
This builds upon
BaseIntegrationListView
, adding access checks to ensure that only administrators can access it.- template_name = 'integrations/admin/integration_list.html'¶
- dispatch(*args, **kwargs) HttpResponseBase ¶
Handle the request to the view.
This will first check to make sure the user is logged in and is a staff member.
- Parameters:
- Returns:
The resulting HTTP response.
- Return type:
- __annotations__ = {'request': 'HttpRequest'}¶
- class BaseIntegrationConfigFormView(**kwargs)¶
Bases:
NeedsIntegrationManagerMixin
,FormView
Base class for a view that manages an integration configuration.
This view handles the display of a form for either creating a new integration configuration or updating an existing one.
This is meant to be subclassed to either fine-tune the queries for configurations (for instance, by limiting to a particular user or organization) or to add access control.
- dispatch(request: HttpRequest, *args, **kwargs) HttpResponseBase ¶
Handle the request to the view.
This will first check to make sure the user is logged in. It then looks up the appropriate configuration ID from the URL before passing it on to the view.
- Parameters:
request (
django.http.HttpRequest
) – The HTTP request from the client.*args (
tuple
) – Positional arguments to pass to the view.**kwargs (
dict
) – Keyword arguments to pass to the view.
- Keyword Arguments:
- Returns:
The resulting HTTP response.
- Return type:
- Raises:
django.http.Http404 – The integration or configuration with the given ID was not found.
- delete(request: HttpRequest, *args, **kwargs) HttpResponseBase ¶
Handle HTTP DELETE requests.
This will delete the integration configuration.
- Parameters:
request (
django.http.HttpRequest
) – The HTTP request from the client.*args (
tuple
) – Positional arguments passed to the view.**args (
dict
) – Keyword arguments passed to the view.
- Returns:
The resulting HTTP response.
- Return type:
- get_config_query_kwargs(**kwargs) Dict ¶
Return query arguments for fetching an integration configuration.
This can be subclassed to return additional arguments used when fetching configurations, based on the needs of the application. For example, limiting it by user or organization.
By default, this doesn’t return any additional query arguments.
- get_form_kwargs() Dict ¶
Return keyword arguments to pass to the form.
This will, by default, provide
integration
and configurationinstance
keyword arguments to the form during initialization, along with therequest
.Subclases can override it with additional arguments if needed.
- Returns:
A dictionary of keyword arguments to pass to the form.
- Return type:
- get_success_url() str ¶
Return the URL to redirect to when successfully saving the form.
This defaults to returning back to the integrations page. Consumers that have special values to fill out in the URL will need to override this.
- Returns:
The URL to redirect to.
- Return type:
- get_form_class() Type[BaseIntegrationConfig] ¶
Return the class used for the configuration form.
This will return whatever class is specified for that integration.
This function is used internally by Django’s generic views framework. It should not be overridden.
- Returns:
The form sublass used for integration configuration.
- Return type:
- form_valid(form: IntegrationConfigForm) HttpResponse ¶
Handle the saving of a valid configuration form
This will save the configuration and then perform a redirect to the success URL, defined by
get_success_url()
.- Parameters:
form (
djblets.integrations.forms.IntegrationConfigForm
) – The form to save.- Returns:
An HTTP response redirecting to the success URL.
- Return type:
- __annotations__ = {}¶
- class BaseAdminIntegrationConfigFormView(**kwargs)¶
Bases:
BaseIntegrationConfigFormView
Base class for an admin view that manages an integration configuration.
This builds upon
BaseIntegrationConfigFormView
, adding access checks to ensure that only administrators can access it.- template_name = 'integrations/admin/configure_integration.html'¶
- dispatch(*args, **kwargs) HttpResponseBase ¶
Handle the request to the view.
This will first check to make sure the user is logged in and is a staff member.
- Parameters:
- Returns:
The resulting HTTP response.
- Return type:
- __annotations__ = {}¶