Jump to >

djblets.integrations.forms

class IntegrationConfigForm(integration, request, *args, **kwargs)[source]

Bases: djblets.forms.forms.key_value_form.KeyValueForm

Base class for an integration settings form.

This makes it easy to provide a basic form for manipulating the settings of an integration configuration. It takes care of loading/saving the values and prompting the user for a name.

Integrations should subclass this and provide additional fields that they want to display to the user. They must provide a Meta class containing the fieldsets they want to display.

Applications can subclass this to provide additional special fields that should be made available to integrations. Integrations would then need to subclass that specialized form. Applications that want to do this will likely need to modify model_fields.

model_fields = (u'name', u'enabled')[source]

A list of fields on the model that should not be saved in settings.

basic_info_fieldset = (None, {u'fields': (u'name', u'enabled'), u'description': _(u'Start by giving this configuration a name so you can easily identify it later. You can also mark this configuration as enabled or disabled.')})[source]

The fieldset containing basic information on the configuration.

Subclasses can override this to provide additional fields, styling, or a description.

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

Initialize the form.

Parameters:
classmethod build_fieldsets()[source]

Build the fieldsets used for the configuration form.

By default, this will prepend basic_info_fieldset to the existing list of fieldsets on Meta (if any).

Subclasses can override this to provide more specialized customization of the form. Since this is working on a form class and not an instance, they should be careful to apply changes only once.

config[source]

The configuration that’s being edited.

If this is a brand new configuration, this will be None until saved.

Any value will be an instance of the subclass of BaseIntegrationConfig provided by the application supporting integrations.

get_key_value(key, default=None)[source]

Return the value for a key.

This will first look for the value from the BaseIntegrationConfig, and will then fall back to looking for the value in the configuration’s settings field.

This is used internally by the parent class, and is not meant to be used directly.

Parameters:
  • key (unicode) – The key in the configuration.
  • default (object) – The default value for the key, if not found.
Returns:

The value from the configuration.

set_key_value(key, value)[source]

Set the value for a key.

This will first look for the key to set in the BaseIntegrationConfig. If it’s there, that field’s value will be set. Otherwise, it will fall back to setting the key in the configuration’s settings field.

This is used internally by the parent class, and is not meant to be used directly.

Parameters:
  • key (unicode) – The key in the configuration.
  • value (object) – The new value.
create_instance()[source]

Create an instance of a configuration.

This is used internally by the parent class, and is not meant to be called by consumers of the form.

Returns:A new integration configuration.
Return type:djblets.integrations.models.BaseIntegrationConfig
save_instance()[source]

Save the configuration.

This is used internally by the parent class, and is not meant to be called by consumers of the form.