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

Refactor unnecessary usages of HttpRequest objects in custom view methods #1539

Open
mikkonie opened this issue Jan 10, 2025 · 0 comments
Open
Assignees
Labels
internal Changes invisible to the user or APIs (e.g. refactoring and optimization)
Milestone

Comments

@mikkonie
Copy link
Collaborator

While doing #1391, I've (again) noticed that in many places we assume the existence of a HttpRequest object when we only need the user object of the current user issuing a request.

However, when we want to reuse code between e.g. UI views, management commands and/or Celery tasks (which happens quite often), a HTTP request may not always be present.

In all cases where we pass a HttpRequest object to custom methods just to get request.user, we should instead pass the current user object directly. The same can be done for possible other request members where the full object is not needed.

For now I'll place this in the v1.2 milestone, but that may still be reconsidered. v1.1 is already quite a large milestone and I want to get working on SODAR v1.1 features ASAP.

@mikkonie mikkonie added the internal Changes invisible to the user or APIs (e.g. refactoring and optimization) label Jan 10, 2025
@mikkonie mikkonie added this to the v1.2.0 milestone Jan 10, 2025
@mikkonie mikkonie changed the title Remove unnecessary usages of HttpRequest objects from custom view methods Refactor unnecessary usages of HttpRequest objects from custom view methods Jan 10, 2025
@mikkonie mikkonie changed the title Refactor unnecessary usages of HttpRequest objects from custom view methods Refactor unnecessary usages of HttpRequest objects in custom view methods Jan 10, 2025
@mikkonie mikkonie self-assigned this Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Changes invisible to the user or APIs (e.g. refactoring and optimization)
Projects
None yet
Development

No branches or pull requests

1 participant