Skip to content

Commit

Permalink
Update Django allauth to 0.57.0 (#11134)
Browse files Browse the repository at this point in the history
* Update Django allauth to 0.57.0

* Use latest version of 0.57.x
  • Loading branch information
stsewd committed Feb 22, 2024
1 parent 895c53c commit e7a90ed
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion readthedocs/oauth/services/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def provider_id(self):

@property
def provider_name(self):
return registry.by_id(self.provider_id).name
return registry.get_class(self.provider_id).name

def get_session(self):
if self.session is None:
Expand Down
6 changes: 3 additions & 3 deletions readthedocs/oauth/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def attach_webhook(project_pk, user_pk, integration=None):
)
return None

provider = allauth_registry.by_id(service.adapter.provider_id)
provider_class = allauth_registry.get_class(service.adapter.provider_id)

user_accounts = service.for_user(user)
for account in user_accounts:
Expand All @@ -226,7 +226,7 @@ def attach_webhook(project_pk, user_pk, integration=None):
dismissable=True,
attached_to=project,
format_values={
"provider_name": provider.name,
"provider_name": provider_class.name,
"url_docs_webhook": "https://docs.readthedocs.io/page/webhooks.html",
},
)
Expand All @@ -236,7 +236,7 @@ def attach_webhook(project_pk, user_pk, integration=None):
dismissable=True,
attached_to=project,
format_values={
"provider_name": provider.name,
"provider_name": provider_class.name,
"url_connect_account": reverse(
"projects_integrations",
args=[project.slug],
Expand Down
4 changes: 2 additions & 2 deletions readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,8 @@ def git_provider_name(self):
"""Get the provider name for project. e.g: GitHub, GitLab, Bitbucket."""
service = self.git_service_class()
if service:
provider = allauth_registry.by_id(service.adapter.provider_id)
return provider.name
provider_class = allauth_registry.get_class(service.adapter.provider_id)
return provider_class.name
return None

def find(self, filename, version):
Expand Down
8 changes: 7 additions & 1 deletion readthedocs/rtd_tests/tests/test_oauth_sync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import django_dynamic_fixture as fixture
import requests_mock
from allauth.socialaccount.models import SocialAccount, SocialToken
from allauth.socialaccount.models import SocialAccount, SocialApp, SocialToken
from allauth.socialaccount.providers.github.views import GitHubOAuth2Adapter
from django.contrib.auth.models import User
from django.test import TestCase
Expand Down Expand Up @@ -61,13 +61,18 @@ class GitHubOAuthSyncTests(TestCase):

def setUp(self):
self.user = fixture.get(User)
self.socialapp = fixture.get(
SocialApp,
provider=GitHubOAuth2Adapter.provider_id,
)
self.socialaccount = fixture.get(
SocialAccount,
user=self.user,
provider=GitHubOAuth2Adapter.provider_id,
)
self.token = fixture.get(
SocialToken,
app=self.socialapp,
account=self.socialaccount,
)
self.service = GitHubService.for_user(self.user)[0]
Expand Down Expand Up @@ -288,6 +293,7 @@ def test_sync_repositories_only_creates_one_remote_repo_per_vcs_repo(
)
fixture.get(
SocialToken,
app=self.socialapp,
account=user_2_socialaccount,
)

Expand Down
1 change: 1 addition & 0 deletions readthedocs/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ def MIDDLEWARE(self):
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
"allauth.account.middleware.AccountMiddleware",
'dj_pagination.middleware.PaginationMiddleware',
'csp.middleware.CSPMiddleware',
'readthedocs.core.middleware.ReferrerPolicyMiddleware',
Expand Down
2 changes: 1 addition & 1 deletion requirements/deploy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ django==4.2.10
# django-timezone-field
# djangorestframework
# jsonfield
django-allauth==0.51.0
django-allauth==0.57.2
# via -r requirements/pip.txt
django-annoying==0.10.6
# via -r requirements/pip.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/docker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ django==4.2.10
# django-timezone-field
# djangorestframework
# jsonfield
django-allauth==0.51.0
django-allauth==0.57.2
# via -r requirements/pip.txt
django-annoying==0.10.6
# via -r requirements/pip.txt
Expand Down
7 changes: 3 additions & 4 deletions requirements/pip.in
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ django-celery-beat
# TODO: remove this dependency once we upgrade Celery. It should auto-install it.
tzdata

# 0.52.0 requires creating a new email template:
# templates/account/email/acccount_already_exists_message.html
# See https://github.com/readthedocs/readthedocs.org/pull/9853#discussion_r1060496492
django-allauth==0.51.0
# 0.58.0 refactored the built-in templates,
# we need to check if we need to update our custom templates.
django-allauth==0.57.2

requests-oauthlib

Expand Down
2 changes: 1 addition & 1 deletion requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ django==4.2.10
# django-timezone-field
# djangorestframework
# jsonfield
django-allauth==0.51.0
django-allauth==0.57.2
# via -r requirements/pip.in
django-annoying==0.10.6
# via -r requirements/pip.in
Expand Down
2 changes: 1 addition & 1 deletion requirements/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ django==4.2.10
# django-timezone-field
# djangorestframework
# jsonfield
django-allauth==0.51.0
django-allauth==0.57.2
# via -r requirements/pip.txt
django-annoying==0.10.6
# via -r requirements/pip.txt
Expand Down

0 comments on commit e7a90ed

Please sign in to comment.