reviewboard.avatars.registry¶
-
class
AvatarServiceRegistry
[source]¶ Bases:
djblets.registries.mixins.ExceptionFreeGetterMixin
,djblets.avatars.registry.AvatarServiceRegistry
A registry for managing avatar services.
This registry is a special case of Djblets’
AvatarServiceRegistry
that will track the enabled state for avatars, and provide functionality for migrating from older (pre-3.0 and 3.0 through 3.0.3) avatar settings to modern settings.-
LEGACY_AVATARS_MIGRATED_KEY
= u'avatars_migrated'[source]¶ The legacy key for tracking avatar settings migrations.
This was used in Review Board 3.0 through 3.0.3. This is no longer stored in settings, and is used as part of the settings migration process.
-
LEGACY_INTEGRATION_GRAVATARS_KEY
= u'integration_gravatars'[source]¶ The legacy key for enabling Gravatars.
This was used in Review Board 2.0 up until 3.0 and kept in settings through 3.0.3. This is no longer stored in settings, and is used as part of the settings migration process.
-
default_avatar_service_classes
= [<class 'djblets.avatars.services.gravatar.GravatarService'>, <class 'reviewboard.avatars.services.FileUploadService'>, <class 'djblets.avatars.services.url.URLAvatarService'>][source]¶ The default avatar service classes.
-
settings_manager_class
[source]¶ alias of
reviewboard.avatars.settings.UserProfileAvatarSettingsManager
-
avatars_enabled
[source]¶ Whether or not avatars are enabled.
Returns: Whether or not avatars are enabled. Return type: bool
-
get_siteconfig_defaults
()[source]¶ Return defaults for the site configuration.
Returns: The defaults to register for the site configuration. Return type: dict
-
migrate_settings
(siteconfig)[source]¶ Migrate the avatar settings from older databases.
Prior to Review Board 3.0, only Gravatars were supported, and we tracked their enabled state in the
integration_gravatars
key.Review Board 3.0 introduced modern support for avatar backends, and necessitated new settings and a migration path to those settings. It introduced an
avatars_migrated
key to determine if we’ve migrated the old avatar settings from a pre-3.0 database. This meant thatavatars_migrated
had to stick in order to flag the modern avatar state, and that we couldn’t store the default settings in the siteconfig defaults. This led to a migration for every new server, and for every unit test.Starting in 3.0.4, we’ve gotten rid of the old
avatars_migrated
key, and instead check the existence of a storedavatars_enabled
in the siteconfig settings, and stored all defaults on enabled/default avatars in the siteconfig defaults. This means that settings are modern by default, and that there’s less to manage during migration.This function will reconcile the old database settings (pre-3.0 and 3.0 through 3.0.4) with the modern (3.0.4+) settings, removing old settings in the process.
This is meant to be called during initialization before any other avatar-dependent code would run.
Parameters: siteconfig (djblets.siteconfig.models.SiteConfiguration) – The site configuration to migrate. Returns: True
if changes to the settings were made.False
if no changes were made.Return type: bool
-