Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addons: small improvements and privacy considerations #11561

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Aug 21, 2024

  • We had a special case in a permissions class, I moved this into the view itself.
  • We are allowing some requests to not have a version, so our normal permission check doesn't work in this case. In case that we don't have a version, we just check for the project permission.
  • If we have a version, we are attaching its latest build, this code was duplicated, and wasn't taking into considerations permissions. In case of temporal sharing tokens, they don't have access to builds.
  • Translations now take into consideration the current user permissions
  • The list of active versions can now be overridden from .com to include versions granted by a temporal access.

Some notes:

  • We are returning some custom 404 responses, but DRF already handles that when using get_object_or_404. Anyway, users won't see any of the messages, since our 404 handler is catching those in production.
  • Returning the full serialized version of translations takes like 40 extra queries, probably it generates more per extra translation. From what I found, most of the queries are due to the serializer returning more related projects fully serialized (main translation, superproject).
  • We are allowing users to override the whole response, we should just allow to override the addons key.
  • This also suffers from https://github.com/readthedocs/readthedocs-corporate/issues/1845

Since to really run the whole code from permissions checks organizations are needed, I'll add tests on .com.

ref https://github.com/readthedocs/readthedocs-corporate/issues/1773

@stsewd
Copy link
Member Author

stsewd commented Aug 22, 2024

This is still missing tests, but those will be in .com, and this PR won't change much. So, marking it as ready for review.

@stsewd stsewd marked this pull request as ready for review August 22, 2024 22:16
@stsewd stsewd requested a review from a team as a code owner August 22, 2024 22:16
@stsewd stsewd requested a review from humitos August 22, 2024 22:16
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I just left a few suggestions and comments 👍🏼

readthedocs/proxito/views/hosting.py Outdated Show resolved Hide resolved
readthedocs/proxito/views/hosting.py Outdated Show resolved Hide resolved
readthedocs/proxito/views/hosting.py Outdated Show resolved Hide resolved
def get(
self,
addons_version,
project,
request,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to receive the request here and passing it to the other methods. We just need the user; which is the only attribute we are using from the request.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +387 to +389
project_translations = project_translations.order_by("language").select_related(
"main_language_project"
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the main_language_project as select related here? Where is it used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used in the serializer, we are doing lots of n+1 queries there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants