Skip to content

Commit fa0458a

Browse files
committed
Changed notification name and moved GitHub to constants
1 parent 57f4291 commit fa0458a

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

readthedocs/builds/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from readthedocs.projects.constants import (
2323
BITBUCKET_COMMIT_URL,
2424
BITBUCKET_URL,
25+
GITHUB,
2526
GITHUB_COMMIT_URL,
2627
GITHUB_URL,
2728
GITHUB_PULL_REQUEST_URL,
@@ -837,7 +838,7 @@ def is_external(self):
837838
@property
838839
def external_version_name(self):
839840
if self.is_external:
840-
if self.project.git_provider_name == 'GitHub':
841+
if self.project.git_provider_name == GITHUB:
841842
return GITHUB_EXTERNAL_VERSION_NAME
842843
# TODO: Add External Version Name for other Git Providers
843844

readthedocs/oauth/notifications.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def get_context_data(self):
5757
return context
5858

5959

60-
class SendBuildStatusFailureNotification(SiteNotification):
60+
class GitBuildStatusFailureNotification(SiteNotification):
6161

6262
context_object_name = 'project'
6363
failure_level = ERROR_PERSISTENT

readthedocs/projects/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,6 @@
355355
)
356356

357357
GITHUB_PR_PULL_PATTERN = 'pull/{id}/head:external-{id}'
358+
359+
# Git provider names
360+
GITHUB = 'GitHub'

readthedocs/projects/tasks.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@
6363
from readthedocs.doc_builder.loader import get_builder_class
6464
from readthedocs.doc_builder.python_environments import Conda, Virtualenv
6565
from readthedocs.oauth.models import RemoteRepository
66-
from readthedocs.oauth.notifications import SendBuildStatusFailureNotification
66+
from readthedocs.oauth.notifications import GitBuildStatusFailureNotification
6767
from readthedocs.oauth.services.github import GitHubService
68+
from readthedocs.projects.constants import GITHUB
6869
from readthedocs.projects.models import APIProject, Feature
6970
from readthedocs.search.utils import index_new_files, remove_indexed_files
7071
from readthedocs.sphinx_domains.models import SphinxDomain
@@ -1891,7 +1892,7 @@ def send_build_status(build_pk, commit, status):
18911892
build = Build.objects.get(pk=build_pk)
18921893
provider_name = build.project.git_provider_name
18931894

1894-
if provider_name == 'GitHub':
1895+
if provider_name == GITHUB:
18951896
# get the service class for the project e.g: GitHubService.
18961897
service_class = build.project.git_service_class()
18971898
try:
@@ -1919,7 +1920,7 @@ def send_build_status(build_pk, commit, status):
19191920
for user in users:
19201921
# Send Site notification about Build status reporting failure
19211922
# to all the users of the project.
1922-
notification = SendBuildStatusFailureNotification(
1923+
notification = GitBuildStatusFailureNotification(
19231924
context_object=build.project,
19241925
extra_context={'provider_name': provider_name},
19251926
user=user,
@@ -1929,12 +1930,12 @@ def send_build_status(build_pk, commit, status):
19291930

19301931
log.info(
19311932
'No social account or repository permission available for %s',
1932-
build.project
1933+
build.project.slug
19331934
)
19341935
return False
19351936

19361937
except Exception:
1937-
log.exception('Send build status task failed for %s', build.project)
1938+
log.exception('Send build status task failed for %s', build.project.slug)
19381939
return False
19391940

19401941
return False

0 commit comments

Comments
 (0)