Jump to >

djblets.avatars.services.fallback

An avatar service used as a fallback to show something basic for a user.

class FallbackService(settings_manager_class)[source]

Bases: djblets.avatars.services.base.AvatarService

An avatar service used as a fallback.

This will display a simple avatar showing the first two characters of the user’s username, displayed on top of a background with a color based on the username.

This will automatically be used as a fallback if no other avatar backends are usable for the user.

avatar_service_id = 'fallback'[source]

The avatar service’s ID.

This must be unique for every avatar service subclass.

name = 'Fallback'[source]

The avatar service’s human-readable name.

template_name = 'avatars/fallback.html'[source]

The template for rendering the avatar as HTML.

hidden = True[source]

Whether or not the avatar service is hidden from users.

Hidden avatar services are not exposed to users and are intended to be used only internally, such as with extensions providing bots.

render(request, user, size, template_name=None)[source]

Render a user’s avatar to HTML.

Parameters
Returns

The rendered avatar HTML.

Return type

django.utils.safestring.SafeText

get_bg_color(user)[source]

Return a background color for the avatar.

This will compute a basic HSL color for the avatar, based on the username.

Parameters

user (django.contrib.auth.models.User) – The user to generate the color for.

Returns

The resulting HSL color definition.

Return type

unicode

get_avatar_urls_uncached(user, size)[source]

Return the Gravatar URLs for the requested user.

Parameters
Returns

dict: A dictionary containing the URLs of the user’s avatars at normal- and high-DPI.

get_etag_data(user)[source]

Return the ETag data for the user’s avatar.

Parameters

user (django.contrib.auth.models.User) – The user.

Returns

The uniquely identifying information for the user’s avatar.

Return type

list of unicode

__annotations__ = {}