Skip to content

Commit a485f83

Browse files
committed
Use an absolute URL, including the "https://<domain>" for versions
1 parent b1508c2 commit a485f83

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

readthedocs/builds/models.py

+22-7
Original file line numberDiff line numberDiff line change
@@ -377,14 +377,29 @@ def commit_name(self):
377377
return self.identifier
378378

379379
def get_absolute_url(self):
380-
"""Get absolute url to the docs of the version."""
380+
"""
381+
Get the absolute URL to the docs of the version.
382+
383+
If the version doesn't have a successfully uploaded build, then we return the project's
384+
dashboard page.
385+
386+
Because documentation projects can be hosted on separate domains, this function ALWAYS
387+
returns with a full "http(s)://<domain>/" prefix.
388+
"""
381389
if not self.built and not self.uploaded:
382-
return reverse(
383-
'project_version_detail',
384-
kwargs={
385-
'project_slug': self.project.slug,
386-
'version_slug': self.slug,
387-
},
390+
# TODO: Stop assuming protocol based on settings.DEBUG
391+
# (this pattern is also used in builds.tasks for sending emails)
392+
protocol = "http" if settings.DEBUG else "https"
393+
return "{}://{}{}".format(
394+
protocol,
395+
settings.PRODUCTION_DOMAIN,
396+
reverse(
397+
"project_version_detail",
398+
kwargs={
399+
"project_slug": self.project.slug,
400+
"version_slug": self.slug,
401+
},
402+
),
388403
)
389404
external = self.type == EXTERNAL
390405
return self.project.get_docs_url(

readthedocs/oauth/services/github.py

+2
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ def send_build_status(self, build, commit, status):
472472
commit_status=github_build_status,
473473
user_username=self.user.username,
474474
statuses_url=statuses_url,
475+
target_url=target_url,
476+
status=status,
475477
)
476478
resp = None
477479
try:

readthedocs/projects/tasks/builds.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def before_start(self, task_id, args, kwargs):
422422
def _reset_build(self):
423423
# Reset build only if it has some commands already.
424424
if self.data.build.get("commands"):
425-
log.info("Reseting build.")
425+
log.info("Resetting build.")
426426
api_v2.build(self.data.build["id"]).reset.post()
427427

428428
def on_failure(self, exc, task_id, args, kwargs, einfo):

0 commit comments

Comments
 (0)