Merge pull request #5437 from ryanpetrello/monkey-patch-oauth2-side-effect

fix an nuanced bug which can cause OAuth2 migrations to fail

Reviewed-by: Seth Foster
             https://github.com/fosterseth
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-12-04 15:32:39 +00:00 committed by GitHub
commit f629822596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -86,7 +86,14 @@ def oauth2_getattribute(self, attr):
# Custom method to override
# oauth2_provider.settings.OAuth2ProviderSettings.__getattribute__
from django.conf import settings
val = settings.OAUTH2_PROVIDER.get(attr)
val = None
if 'migrate' not in sys.argv:
# certain Django OAuth Toolkit migrations actually reference
# setting lookups for references to model classes (e.g.,
# oauth2_settings.REFRESH_TOKEN_MODEL)
# If we're doing an OAuth2 setting lookup *while running* a migration,
# don't do our usual "Configure Tower in Tower" database setting lookup
val = settings.OAUTH2_PROVIDER.get(attr)
if val is None:
val = object.__getattribute__(self, attr)
return val