Skip to content

Add migration page for GitHub App #12112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions readthedocs/core/templatetags/readthedocs/socialaccounts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from allauth.socialaccount.adapter import get_adapter
from allauth.socialaccount.providers.github.provider import GitHubProvider
from django import forms
from django import template

from readthedocs.allauth.providers.githubapp.provider import GitHubAppProvider
from readthedocs.oauth.utils import is_access_revoked as utils_is_access_revoked


register = template.Library()

Expand All @@ -19,3 +23,21 @@ def can_be_disconnected(account):
return True
except forms.ValidationError:
return False


@register.filter
def is_access_revoked(account):
"""Check if access to the account is revoked."""
return utils_is_access_revoked(account)


@register.filter
def has_github_app_account(account):
"""Check if there is a GitHub App account matching this account."""
if account.provider != GitHubProvider.id:
return False

return account.user.socialaccount_set.filter(
provider=GitHubAppProvider.id,
uid=account.uid,
).exists()
Loading