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

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

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.

Summary ID
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).
43639974c112234e27e6681eab5d145cfa595646

Description From Last Updated

From the comments it looks like your intent was to use the initials if the user has first and last …

daviddavid

W391 blank line at end of file

reviewbotreviewbot

Can we use the full name if it exists?

daviddavid

W391 blank line at end of file

reviewbotreviewbot

These don't impact the result now that it's definitely username-only, so they can be removed.

daviddavid
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

david
  1. 
      
  2. djblets/avatars/services/fallback.py (Diff revision 1)
     
     
    Show all issues

    From the comments it looks like your intent was to use the initials if the user has first and last names defined, but you don't do that here. Can we?

    1. Oops. Originally I did, then I realized that these are going to be used basically when people have opted out of a more identifying avatar. So, for privacy's sake, I switched to not leaking even initials.

  3. Show all issues

    Can we use the full name if it exists?

    1. We used to for avatars, but we changed that specifically because of GDPR and the need for private profiles.

  4. 
      
chipx86
Review request changed
Change Summary:

Fixed the description of FallbackService to not incorrectly claim that the user's full name's initials are used.

Commits:
Summary ID
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).
46e1d0bfa72f0f2bae73b76ecccb5cfa8524921b
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

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. 
      
  2. djblets/avatars/services/fallback.py (Diff revision 3)
     
     
     
    Show all issues

    These don't impact the result now that it's definitely username-only, so they can be removed.

  3. 
      
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-1.0.x (1ac8481)