Jump to >

This documentation covers the in-development release of Djblets. You can see the latest stable docs or all previous versions.

djblets.avatars.forms

Forms for Djblets’ avatar support.

class AvatarServiceConfigForm(*args, **kwargs)[source]

An avatar service configuration form.

avatar_service_id = None[source]

The avatar service ID of the associated service.

get_extra_context()[source]

Return extra rendering context.

Returns

Extra rendering context.

Return type

dict

class AvatarSettingsForm(*args, **kwargs)[source]

The avatar settings form.

This allows users to select the avatar service they wish to use and, if necessary, configure it (e.g., by uploading an avatar).

avatar_service_registry = None[source]

The avatar service registry. Subclasses must override this.

property is_multipart[source]

Whether or not the form is multi-part.

The form is multi-part when there is an enabled avatar service that has a multi-part configuration form.

Returns

Whether or not the form is multi-part.

Return type

bool

property js_bundle_names[source]

Yield the bundle names necessary.

Each avatar service can specify a configuration form that may specify JS bundles. Since those forms are not registered through the page, we must add them this way.

Yields

unicode – The names of the JS bundles to load on the page.

property css_bundle_names[source]

Yield the CSS bundle names.

Each avatar service can specify a configuration form that may specify CSS bundles. Since those forms are not registered through the page, we must add them this way.

Yields

unicode – The names of the CSS bundles to load on the page.

clean_avatar_service_id()[source]

Clean the avatar_service_id field.

This ensures that the value corresponds to a valid and enabled avatar service.

Returns

The avatar service ID.

Return type

unicode

Raises

django.core.exceptions.ValidationError – Raised when the avatar service ID is invalid.

clean()[source]

Clean the form.

This will clean the avatar service configuration form of the selected avatar service (if it is configurable) and raise an exception if it is not valid.

This will cache any sub-form errors so that they can be rendered to the user when rendering the form.

Returns

The form’s cleaned data.

Return type

dict

Raises

ValidationError – Raised when the form for the selected avatar service is invalid.

save()[source]

Save the avatar settings.

This method attempts to save

get_extra_context()[source]

Return the extra context for rendering the form.

Returns

The extra rendering context.

Return type

dict

get_js_model_data()[source]

Return the JS model data for the form.

Returns

A dictionary of the model data for the form.

Return type

dict