Skip to content

Commit

Permalink
Addons: get final project (e.g. subproject) (#10745)
Browse files Browse the repository at this point in the history
Use `unresolved_url` to get the final project requested from the URL. This is
needed for subproject since it's the only place where it's present.

Previously, we were getting the project from the `unresolved_domain` which does
not give us the `subproject` because it's not present in the domain itself.

Tests will be added in
#10685

Closes readthedocs/readthedocs-corporate#1622
  • Loading branch information
humitos authored Sep 19, 2023
1 parent dcbc255 commit 8566a62
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions readthedocs/proxito/views/hosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,15 @@ def _resolve_resources(self):
return None, None, None, None

unresolved_domain = self.request.unresolved_domain

# Main project from the domain.
project = unresolved_domain.project

try:
unresolved_url = unresolver.unresolve_url(url)
# Project from the URL: if it's a subproject it will differ from
# the main project got from the domain.
project = unresolved_url.project
version = unresolved_url.version
filename = unresolved_url.filename
build = version.builds.last()
Expand Down Expand Up @@ -248,6 +253,8 @@ def _v0(self, project, version, build, filename, user):
" AND IT'S GOING TO CHANGE COMPLETELY -- DO NOT USE IT!"
),
"projects": {
# TODO: return the "parent" project here when the "current"
# project is a subproject/translation.
"current": ProjectSerializerNoLinks(project).data,
},
"versions": {
Expand Down

0 comments on commit 8566a62

Please sign in to comment.