-
Notifications
You must be signed in to change notification settings - Fork 72
Reduce dependency on Klass instance in KlassDetailView #279
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
base: main
Are you sure you want to change the base?
Conversation
This is a step on the road of removing the ORM from the template render.
We had a filter that did a complex query at template render time. That logic has now been moved to the view. Flat objects are introduced to passed method to the template instead. The helper function is horrible. We should also improve the method context data structure, but that would require more work on the template, so it's out of scope. Similarly, this makes no effort to add types to the helper function which was previously a template filter.
This adds a `klass` argument, and renames a couple of attributes. Other than that, this is just a move. This function is gnarly. Fixing it can come later.
There's no need for us to re-define this on every iteration.
ghickman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of questions about essentially the same thing. I don't have a strong opinion on which way you go though, more curious to see if reducing the types are useful to you
| class Class: | ||
| db_id: int | ||
| docs_url: str | ||
| docstring: str | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could an empty string serve the same falsey/emptiness need as None here, and reduce the number of types?
| name: str | ||
| value: str | ||
| overridden: bool | ||
| class_url: str | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here, about using empty string instead of None
This is a step on the road of removing the ORM.
This removes ORM objects from the template context, and some logic off the models in the process. The moved code is by no means perfect, but at least it's now in a less inconvenient place.