A registry for managing avatar services.
This registry is a special case of Djblets’
AvatarServiceRegistrythat 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.
The key for enabling avatars.
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.
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'>]¶
The default avatar service classes.
Whether or not avatars are enabled.
Returns: Whether or not avatars are enabled. Return type: bool
Return defaults for the site configuration.
Returns: The defaults to register for the site configuration. Return type: dict
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
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_migratedkey to determine if we’ve migrated the old avatar settings from a pre-3.0 database. This meant that
avatars_migratedhad 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_migratedkey, and instead check the existence of a stored
avatars_enabledin 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:
Trueif changes to the settings were made.
Falseif no changes were made.
Return type: bool