Add a fallback avatar service for when other services aren't available.

Review Request #10443 — Created March 12, 2019 and submitted — Latest diff uploaded

Information

Djblets
release-1.0.x

Reviewers

With the existing avatar implementation, users that don't have a usable
avatar service (such as when Gravatars are used but the user has opted
out) would result in an empty space where the avatar would otherwise go.
This could lead to display inconsistencies, unwanted logging, or other
problems.

This change adds a new avatar service that's used as a fallback when no
other service is available. This will show the first two letters of the
username, overlayed on top of a colored background. The background color
is based on the username, helping to provide different visuals for
different users.

Consumers can replace the fallback with some other service by overriding
fallback_service_class on the registry.

To help with styling, both the existing avatars and the new ones have
new namespaced CSS classes (.djblets-o-avatar), which are meant to
replace the .avatar class (though this is still used).

Unit tests pass.

Tested various avatar sizes, making sure the fonts are in proportion.

Diff Revision 2

This is not the most recent revision of the diff. The latest diff is revision 4. See what's changed.

orig
1
2
3
4

Commits

First Last Summary ID Author
Add a fallback avatar service for when other services aren't available.
With the existing avatar implementation, users that don't have a usable avatar service (such as when Gravatars are used but the user has opted out) would result in an empty space where the avatar would otherwise go. This could lead to display inconsistencies, unwanted logging, or other problems. This change adds a new avatar service that's used as a fallback when no other service is available. This will show the first two letters of the username, overlayed on top of a colored background. The background color is based on the username, helping to provide different visuals for different users. Consumers can replace the fallback with some other service by overriding `fallback_service_class` on the registry. To help with styling, both the existing avatars and the new ones have new namespaced CSS classes (`.djblets-o-avatar`), which are meant to replace the `.avatar` class (though this is still used).
e351471795341f25beb63eb23a750ae28221c754 Christian Hammond
djblets/avatars/registry.py
djblets/avatars/tests.py
djblets/avatars/services/__init__.py
djblets/avatars/services/fallback.py
djblets/avatars/templates/avatars/avatar.html
djblets/avatars/templates/avatars/fallback.html
Loading...