Skip to content

Commit 8566a62

Browse files
authored
Addons: get final project (e.g. subproject) (#10745)
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
1 parent dcbc255 commit 8566a62

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

readthedocs/proxito/views/hosting.py

+7
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,15 @@ def _resolve_resources(self):
6767
return None, None, None, None
6868

6969
unresolved_domain = self.request.unresolved_domain
70+
71+
# Main project from the domain.
7072
project = unresolved_domain.project
7173

7274
try:
7375
unresolved_url = unresolver.unresolve_url(url)
76+
# Project from the URL: if it's a subproject it will differ from
77+
# the main project got from the domain.
78+
project = unresolved_url.project
7479
version = unresolved_url.version
7580
filename = unresolved_url.filename
7681
build = version.builds.last()
@@ -248,6 +253,8 @@ def _v0(self, project, version, build, filename, user):
248253
" AND IT'S GOING TO CHANGE COMPLETELY -- DO NOT USE IT!"
249254
),
250255
"projects": {
256+
# TODO: return the "parent" project here when the "current"
257+
# project is a subproject/translation.
251258
"current": ProjectSerializerNoLinks(project).data,
252259
},
253260
"versions": {

0 commit comments

Comments
 (0)