File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 4141from readthedocs .domains .querysets import DomainQueryset
4242from readthedocs .domains .validators import check_domains_limit
4343from readthedocs .notifications .models import Notification as NewNotification
44+ from readthedocs .oauth .constants import GITHUB
4445from readthedocs .oauth .constants import GITHUB_APP
4546from readthedocs .projects import constants
4647from readthedocs .projects .exceptions import ProjectConfigurationError
@@ -1080,6 +1081,24 @@ def is_github_project(self):
10801081 def is_github_app_project (self ):
10811082 return self .remote_repository and self .remote_repository .vcs_provider == GITHUB_APP
10821083
1084+ @property
1085+ def old_github_remote_repository (self ):
1086+ """
1087+ Get the old GitHub OAuth repository for GitHub App projects.
1088+
1089+ This is mainly used for projects that migrated to the new GitHub App,
1090+ but its users have not yet connected their accounts to the new GitHub App.
1091+ We still need to reference the old repository for permissions when using GH as SSO method.
1092+ """
1093+ from readthedocs .oauth .models import RemoteRepository
1094+
1095+ if self .is_github_app_project :
1096+ return RemoteRepository .objects .filter (
1097+ vcs_provider = GITHUB ,
1098+ remote_id = self .remote_repository .remote_id ,
1099+ ).first ()
1100+ return None
1101+
10831102 @property
10841103 def is_gitlab_project (self ):
10851104 from readthedocs .oauth .services import GitLabService
You can’t perform that action at this time.
0 commit comments