Jump to >

djblets.integrations.views

class IntegrationListContextViewMixin[source]

A mixin for views that display lists of integrations.

This allows for custom views that display details on the available integrations and all configurations.

get_integration_js_view_data()[source]

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

dict

get_add_config_url(integration)[source]

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

unicode

get_edit_config_url(config)[source]

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

unicode

get_configs_queryset()[source]

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

django.db.models.query.QuerySet

class BaseIntegrationListView(**kwargs)[source]

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.

template_name = None[source]

The name of the template used for the page.

This must be provided if subclassing this yourself.

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

Handle the request to the view.

This will first check to make sure the user is logged in.

Parameters
  • *args (tuple) – Arguments to pass to the view.

  • **kwargs (dict) – Keyword arguments to pass to the view.

Returns

The resulting HTTP response.

Return type

django.http.HttpResponse

get_context_data(**kwargs)[source]

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.

Parameters

**kwargs (dict) – Any arguments captured in the URL.

Returns

A dictionary of context data for the template.

Return type

dict

class BaseAdminIntegrationListView(**kwargs)[source]

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.

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

Handle the request to the view.

This will first check to make sure the user is logged in and is a staff member.

Parameters
  • *args (tuple) – Arguments to pass to the view.

  • **kwargs (dict) – Keyword arguments to pass to the view.

Returns

The resulting HTTP response.

Return type

django.http.HttpResponse

class BaseIntegrationConfigFormView(**kwargs)[source]

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.

template_name = None[source]

The name of the template used for the page.

This must be provided if subclassing this yourself.

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

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
  • *args (tuple) – Positional arguments to pass to the view.

  • **kwargs (dict) – Keyword arguments to pass to the view.

Returns

The resulting HTTP response.

Return type

django.http.HttpResponse

Raises

django.http.Http404 – The integration or configuration with the given ID was not found.

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

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

django.http.HttpResponse

get_config_query_kwargs(**kwargs)[source]

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.

Parameters

**kwargs (dict) – Any arguments captured in the URL.

Returns

Additional query arguments as a dictionary. This will be turned into keyword arguments for a filter query.

Return type

dict

get_context_data(**kwargs)[source]

Return context data for the configuration page.

Parameters

**kwargs (dict) – Additional keyword arguments that may be passed to this function by the parent views.

Returns

The context to provide on the page.

Return type

dict

get_form_kwargs()[source]

Return keyword arguments to pass to the form.

This will, by default, provide integration and configuration instance keyword arguments to the form during initialization, along with the request.

Subclases can override it with additional arguments if needed.

Returns

A dictionary of keyword arguments to pass to the form.

Return type

dict

get_success_url()[source]

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

unicode

get_form_class()[source]

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

djblets.integrations.forms.IntegrationConfigForm

form_valid(form)[source]

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

django.http.HttpResponse

class BaseAdminIntegrationConfigFormView(**kwargs)[source]

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.

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

Handle the request to the view.

This will first check to make sure the user is logged in and is a staff member.

Parameters
  • *args (tuple) – Arguments to pass to the view.

  • **kwargs (dict) – Keyword arguments to pass to the view.

Returns

The resulting HTTP response.

Return type

django.http.HttpResponse

get_context_data(**kwargs)[source]

Return context data for the configuration page.

Parameters

**kwargs (dict) – Additional keyword arguments that may be passed to this function by the parent views.

Returns

The context to provide on the page.

Return type

dict