Add the avatar services registry
Review Request #7809 — Created Dec. 15, 2015 and submitted
Information | |
---|---|
brennie | |
Review Board | |
release-2.6.x | |
|
|
7810 | |
Reviewers | |
reviewboard | |
The avatar services registry is a new object for managing avatar
services, which are defined to provide Review Board multiple ways of
displaying user avatars. Currently, the only supported avatar service
is the Gravatar (http://gravatar.com) service, which is what Review
Board supported previously.This patch, however, does not migrate to use the new avatar services.
Generated serach indexes have also been added to
.gitignore
.
Ran unit tests.
Used this in an upcoming patch.
Description | From | Last Updated |
---|---|---|
Should use ugettext_lazy |
|
|
Docstring? |
|
|
Since we render with a size specified, we should probably include width and height parameters in this tag. Also, can … |
|
|
We should mark_safe this. |
|
|
Col: 25 E241 multiple spaces after ':' |
![]() |
|
Col: 29 E241 multiple spaces after ':' |
![]() |
|
Col: 19 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 23 E241 multiple spaces after ':' |
![]() |
|
Col: 28 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 22 E241 multiple spaces after ':' |
![]() |
|
Col: 22 E241 multiple spaces after ':' |
![]() |
|
Col: 17 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 28 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 31 E241 multiple spaces after ':' |
![]() |
|
Col: 31 E241 multiple spaces after ':' |
![]() |
|
Col: 23 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 32 E241 multiple spaces after ':' |
![]() |
|
I know it wasn't already, but can we alphabetize this list? |
|
|
Perhaps we should rename these so they start with avatar_service so they all bunch together? |
|
|
Let's go into a little more detail on this, at the very least saying "avatar services," but ideally clarifying what … |
|
|
Swap these. |
|
|
Ordering is backwards. |
|
|
Similar comment to my other review. We should have a capital letter after the ":", since that's typically how errors … |
|
|
Blank line between these. |
|
|
A property should generally have the same type as both the getter and setter. In this case, we're using a … |
|
|
~ before the class path? |
|
|
Localized? |
|
|
Seeing a lot of inconsistency with the class paths in the docs. Some say reviewboard.accounts.avatars.services, some reviewboard.avatars.service, and some reviewboard.avatars.services. |
|
|
Might wrap better as: raise ItemLookupError( '...' % service) Same below. Also, these should be localized. |
|
|
I'm not sure it's clear what this really means, as written. Same below. Can we say what saving means, or … |
|
|
Sort of hitting a parse error with this sentence. |
|
|
Not necessarily true. Maybe: Whether the registry of avatars was newly populated by this call. If ``False``, the registry was … |
|
|
We know we're saving below, so probably no need to do that here. |
|
|
Should pass the service ID as a parameter, rather than a format string. |
|
|
"set"/"unsetting" doesn't mean a lot outside of the internals of the registries, I don't think. Maybe we can reword this? |
|
|
This is an internal detail I'd really rather not expose. It's cheap to fetch the SiteConfiguration, since we cache it, … |
|
|
Since this is something that developers will be interacting with, this should go into a lot more detail on what … |
|
|
This should go into more detail on what's expected and what's provided to the template. |
|
|
How about "The user whose avatar URL will be retrieved." |
|
|
Let's add "in pixels," and that this will be applied to both the width and the height. |
|
|
"... to HTML." This should go into more detail about how it's rendered (using template), and that it can be … |
|
|
Let's cache these on the request, taking into account the user ID and size. This will give us a nice … |
|
|
Let's have this in its own file. Refer to my thoughts at the top about directory structure. |
|
|
Two blank lines. |
|
|
This is kind of oddly written, and doesn't make it clear that service_id can impact this. This should be more … |
|
|
Let's pass the values as keyword arguments, in case we extend down the road. |
|
|
Col: 23 E241 multiple spaces after ':' |
![]() |
|
Col: 25 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 23 E241 multiple spaces after ':' |
![]() |
|
Col: 19 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 28 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 29 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 31 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 31 E241 multiple spaces after ':' |
![]() |
|
Col: 32 E241 multiple spaces after ':' |
![]() |
|
Col: 22 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 28 E241 multiple spaces after ':' |
![]() |
|
Col: 17 E241 multiple spaces after ':' |
![]() |
|
Col: 22 E241 multiple spaces after ':' |
![]() |
|
Col: 31 E241 multiple spaces after ':' |
![]() |
|
Col: 39 E241 multiple spaces after ':' |
![]() |
|
Col: 32 E241 multiple spaces after ':' |
![]() |
|
Col: 25 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 23 E241 multiple spaces after ':' |
![]() |
|
Col: 19 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 28 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 29 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 31 E241 multiple spaces after ':' |
![]() |
|
Col: 22 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 28 E241 multiple spaces after ':' |
![]() |
|
Col: 17 E241 multiple spaces after ':' |
![]() |
|
Col: 22 E241 multiple spaces after ':' |
![]() |
|
Two blank lines. |
|
|
This needs more detail on what this does and how it works, for people not familiar with what we're doing. |
|
|
This shouldn't have to be called here. It's already managed by the middleware and app initialize stuff, and when setting … |
|
|
This makes me nervous. Can we just set the things we need? |
|
|
'django_reset' imported but unused |
![]() |
|
'from settings_local import *' used; unable to detect undefined names |
![]() |
|
'PIPELINE_CSS' imported but unused |
![]() |
|
'PIPELINE_JS' imported but unused |
![]() |
|
Col: 23 E241 multiple spaces after ':' |
![]() |
|
Things are misaligned here. Can we just shift this to be pep-8 style (even though it's not quite as pretty … |
|
|
Col: 31 E241 multiple spaces after ':' |
![]() |
|
Col: 24 E241 multiple spaces after ':' |
![]() |
|
Col: 25 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 23 E241 multiple spaces after ':' |
![]() |
|
Col: 19 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 28 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 29 E241 multiple spaces after ':' |
![]() |
|
Col: 30 E241 multiple spaces after ':' |
![]() |
|
Col: 31 E241 multiple spaces after ':' |
![]() |
|
Col: 22 E241 multiple spaces after ':' |
![]() |
|
Col: 26 E241 multiple spaces after ':' |
![]() |
|
Col: 28 E241 multiple spaces after ':' |
![]() |
|
Col: 17 E241 multiple spaces after ':' |
![]() |
|
Col: 22 E241 multiple spaces after ':' |
![]() |
|
This should all fit on one line. |
|
|
'django_reset' imported but unused |
![]() |
|
'from settings_local import *' used; unable to detect undefined names |
![]() |
|
'PIPELINE_CSS' imported but unused |
![]() |
|
'PIPELINE_JS' imported but unused |
![]() |
|
'django_reset' imported but unused |
![]() |
|
'from settings_local import *' used; unable to detect undefined names |
![]() |
|
'PIPELINE_CSS' imported but unused |
![]() |
|
'PIPELINE_JS' imported but unused |
![]() |
-
-
-
-
reviewboard/accounts/avatars/services.py (Diff revision 1) Since we render with a size specified, we should probably include
width
andheight
parameters in this tag.Also, can you double check that things are properly escaped when rendering this?
-
-
reviewboard/admin/siteconfig.py (Diff revision 1) I know it wasn't already, but can we alphabetize this list?
Change Summary:
Address David's issues.
-
-
reviewboard/admin/siteconfig.py (Diff revisions 1 - 2) Perhaps we should rename these so they start with
avatar_service
so they all bunch together?
-
The directory structure's feeling a bit deep. I get that avatars relate to accounts, but they're not necessarily a part of an account. I can see, for instance, us enhancing this later to let us get an avatar for a remote service, like a GitHub account, without having a local account. Maybe.
Anyway, room for debate here, but I feel like
reviewboard.avatars
is a fine namespace for this. Allows this to really be solely about avatars, without needing to be, like, a utility service of accounts (which the current directory structure implies).It also allows us to more easily break
services.py
up intoservices/base.py
andservices/gravatar.py
. That'll be good down the road, in case we want to add some other built-in services (github.py
,custom_url.py
, or whatever). -
reviewboard/accounts/avatars/errors.py (Diff revision 2) Let's go into a little more detail on this, at the very least saying "avatar services," but ideally clarifying what this means more.
-
-
-
reviewboard/accounts/avatars/registry.py (Diff revision 2) Similar comment to my other review. We should have a capital letter after the ":", since that's typically how errors will be represented (as another exception's message is often used as the "reason" for an error here).
We also usually have a form more like:
Could not register the avatar service %(item)s: This service is already registered.
Also, this one is missing a trailing period.
-
-
reviewboard/accounts/avatars/registry.py (Diff revision 2) A property should generally have the same type as both the getter and setter. In this case, we're using a set value of a list, and a get of a generator. I feel consistency is preferable here, particularly since we're never going to really have more than one or two services enabled here.
-
-
-
reviewboard/accounts/avatars/registry.py (Diff revision 2) Seeing a lot of inconsistency with the class paths in the docs. Some say
reviewboard.accounts.avatars.services
, somereviewboard.avatars.service
, and somereviewboard.avatars.services
. -
reviewboard/accounts/avatars/registry.py (Diff revision 2) Might wrap better as:
raise ItemLookupError( '...' % service)
Same below.
Also, these should be localized.
-
reviewboard/accounts/avatars/registry.py (Diff revision 2) I'm not sure it's clear what this really means, as written. Same below.
Can we say what saving means, or maybe rewrite it if it's something like "Whether or not the list of enabled services should be saved to the database"? "Registry" isn't necessarily as clear.
-
reviewboard/accounts/avatars/registry.py (Diff revision 2) Sort of hitting a parse error with this sentence.
-
reviewboard/accounts/avatars/registry.py (Diff revision 2) Not necessarily true. Maybe:
Whether the registry of avatars was newly populated by this call. If ``False``, the registry was already populated by a previosu call.
Also, do we use this anywhere? Might have missed it.
-
reviewboard/accounts/avatars/registry.py (Diff revision 2) We know we're saving below, so probably no need to do that here.
-
reviewboard/accounts/avatars/registry.py (Diff revision 2) Should pass the service ID as a parameter, rather than a format string.
-
reviewboard/accounts/avatars/registry.py (Diff revision 2) "set"/"unsetting" doesn't mean a lot outside of the internals of the registries, I don't think. Maybe we can reword this?
-
reviewboard/accounts/avatars/registry.py (Diff revision 2) This is an internal detail I'd really rather not expose. It's cheap to fetch the
SiteConfiguration
, since we cache it, so let's just do that here. -
reviewboard/accounts/avatars/services.py (Diff revision 2) Since this is something that developers will be interacting with, this should go into a lot more detail on what this is responsible for, how it's used, and what's expected by an implementor.
-
reviewboard/accounts/avatars/services.py (Diff revision 2) This should go into more detail on what's expected and what's provided to the template.
-
reviewboard/accounts/avatars/services.py (Diff revision 2) How about "The user whose avatar URL will be retrieved."
-
reviewboard/accounts/avatars/services.py (Diff revision 2) Let's add "in pixels," and that this will be applied to both the width and the height.
-
reviewboard/accounts/avatars/services.py (Diff revision 2) "... to HTML."
This should go into more detail about how it's rendered (using
template
), and that it can be overridden for custom behavior. -
reviewboard/accounts/avatars/services.py (Diff revision 2) Let's cache these on the request, taking into account the user ID and size. This will give us a nice speed boost. We should also mention that in the docs.
-
reviewboard/accounts/avatars/services.py (Diff revision 2) Let's have this in its own file. Refer to my thoughts at the top about directory structure.
-
-
reviewboard/accounts/templatetags/avatars.py (Diff revision 2) This is kind of oddly written, and doesn't make it clear that
service_id
can impact this. This should be more explicit. -
reviewboard/accounts/templatetags/avatars.py (Diff revision 2) Let's pass the values as keyword arguments, in case we extend down the road.
-
Oh, also, I feel like this would be a great thing to have in Djblets, since avatars are a very generic concept.

-
Tool: Pyflakes Processed Files: reviewboard/accounts/avatars/tests.py reviewboard/accounts/avatars/registry.py reviewboard/admin/siteconfig.py reviewboard/accounts/avatars/services.py reviewboard/accounts/avatars/errors.py reviewboard/accounts/templatetags/avatars.py Ignored Files: reviewboard/accounts/avatars/__init__.py reviewboard/accounts/templatetags/__init__.py Tool: PEP8 Style Checker Processed Files: reviewboard/accounts/avatars/tests.py reviewboard/accounts/avatars/registry.py reviewboard/admin/siteconfig.py reviewboard/accounts/avatars/services.py reviewboard/accounts/avatars/errors.py reviewboard/accounts/templatetags/avatars.py Ignored Files: reviewboard/accounts/avatars/__init__.py reviewboard/accounts/templatetags/__init__.py
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Change Summary:
Move most of the registry to Djblets (https://reviews.reviewboard.org/r/7844/)
Address issues.
Depends On: |
|
||
---|---|---|---|
Diff: |
Revision 3 (+336 -17) |

-
Tool: Pyflakes Processed Files: reviewboard/admin/siteconfig.py reviewboard/avatars/__init__.py reviewboard/settings.py reviewboard/avatars/registry.py reviewboard/avatars/templatetags/avatars.py reviewboard/avatars/tests.py Ignored Files: reviewboard/avatars/templatetags/__init__.py Tool: PEP8 Style Checker Processed Files: reviewboard/admin/siteconfig.py reviewboard/avatars/__init__.py reviewboard/settings.py reviewboard/avatars/registry.py reviewboard/avatars/templatetags/avatars.py reviewboard/avatars/tests.py Ignored Files: reviewboard/avatars/templatetags/__init__.py
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
reviewboard/settings.py (Diff revision 3) 'from settings_local import *' used; unable to detect undefined names
-
-
-
-
-
reviewboard/avatars/registry.py (Diff revision 3) This needs more detail on what this does and how it works, for people not familiar with what we're doing.
-
reviewboard/avatars/registry.py (Diff revision 3) This shouldn't have to be called here. It's already managed by the middleware and app initialize stuff, and when setting new configuration for the site. This should be able to rely on the existing calls.
-
reviewboard/avatars/tests.py (Diff revision 3) This makes me nervous. Can we just set the things we need?

-
Tool: Pyflakes Processed Files: reviewboard/admin/siteconfig.py reviewboard/avatars/__init__.py reviewboard/settings.py reviewboard/avatars/registry.py reviewboard/avatars/templatetags/avatars.py reviewboard/avatars/tests.py Ignored Files: reviewboard/avatars/templatetags/__init__.py Tool: PEP8 Style Checker Processed Files: reviewboard/admin/siteconfig.py reviewboard/avatars/__init__.py reviewboard/settings.py reviewboard/avatars/registry.py reviewboard/avatars/templatetags/avatars.py reviewboard/avatars/tests.py Ignored Files: reviewboard/avatars/templatetags/__init__.py
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
reviewboard/settings.py (Diff revision 4) 'from settings_local import *' used; unable to detect undefined names
-
-
-
-
reviewboard/admin/siteconfig.py (Diff revision 4) Things are misaligned here. Can we just shift this to be pep-8 style (even though it's not quite as pretty as aligned)?
-

-
Tool: Pyflakes Processed Files: reviewboard/admin/siteconfig.py reviewboard/avatars/__init__.py reviewboard/settings.py reviewboard/avatars/registry.py reviewboard/avatars/templatetags/avatars.py reviewboard/avatars/tests.py Ignored Files: reviewboard/avatars/templatetags/__init__.py Tool: PEP8 Style Checker Processed Files: reviewboard/admin/siteconfig.py reviewboard/avatars/__init__.py reviewboard/settings.py reviewboard/avatars/registry.py reviewboard/avatars/templatetags/avatars.py reviewboard/avatars/tests.py Ignored Files: reviewboard/avatars/templatetags/__init__.py
-
-
reviewboard/settings.py (Diff revision 5) 'from settings_local import *' used; unable to detect undefined names
-
-