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]

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.

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

Render a user’s avatar to HTML.

Parameters
  • request (django.http.HttpRequest) – The HTTP request.

  • user (django.contrib.auth.models.User) – The user for whom the avatar is to be rendered.

  • size (int) – The requested avatar size (height and width) in pixels.

  • template_name (unicode, optional) – The name of the template to use for rendering.

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