djblets.avatars.services.url¶
An avatar service for setting absolute URLs for avatars.
- class URLAvatarService(settings_manager_class)[source]¶
- Bases: - AvatarService- An avatar service for settings absolute URLs for avatars. - This avatar service is not available to users and is meant to be used by bots from extensions to provide their own avatars. - Automation users can be configured to use this service with the following code: - from djblets.avatars.services import URLAvatarService avatar_services = get_avatar_service_registry() service = avatar_services.get_avatar_service( URLAvatarService.avatar_service_id) service.setup( user, { '1x': 'http://example.com/static/avatar.png', '2x': 'http://example.com/static/avatar@2x.png', }) - avatar_service_id = 'url'[source]¶
- The avatar service’s ID. - This must be unique for every avatar service subclass. 
 - 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. 
 - setup(user, urls)[source]¶
- Set up this avatar service for the given user. - The user will be configured to use this service as their avatar service and the given URLs will be used for their avatars. - Parameters:
- user ( - django.contrib.auth.models.User) – The user to set the URLs for.
- urls ( - dict) – A dictionary mapping resolutions (‘1x’, ‘2x’, etc.) to absolute URLs.
 
 
 - get_avatar_urls_uncached(user, size)[source]¶
- Return the avatar URLs for the requested user. - Parameters:
- user ( - django.contrib.auth.models.User) – The user whose avatar URLs are to be fetched.
- size ( - int) – The size (in pixels) the avatar is to be rendered at.
 
- Returns:
- A dictionary mapping resolutions (‘1x’, ‘2x’, etc.) to the user’s avatar URLs. 
- Return type:
 
 - 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:
 
 - __annotations__ = {}¶
 
