-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Annotate admin_order_field to also accept a BaseExpression #9
Conversation
Pull Request Test Coverage Report for Build 347679241
💛 - Coveralls |
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.
Nice find @brianhelba! Thank you.
Implementation-wise it looks great, but I think the new functionality should be covered by the tests as well. Would you mind integrating the new case into the tests? If you need any help please let me know.
(...and while you at it, don't forget to add yourself to the CONTRIBUTORS.md
:) )
@escaped Thanks for the quick review and feedback.
|
@escaped The tests are failing, but it looks to me like it might be an issue with |
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.
Nice work. Some minor changes and the PR is ready to be merged.
I inspected the output of the CI pipeline and it looks like we need to make some minor adjustments to make it pass.
Furthermore, yes, there is an issue with master
which states that isort
is not configured correctly. I have to fix this in another project, but as it is just a warning and it should not affect this PR.
Please have a look at my comments and let me know if you need any help. Thank you.
@escaped Thanks for all the guidance. The good news is that I found a way to further simplify the tests. Using The bad news is that Django's use of |
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.
Great work. Thank you, it's ready for merging :) Will definitely publish it this week (even though I left one discussion point).
from mypy import api | ||
|
||
from .test_decorator import OPTIONS | ||
|
||
|
||
def safe_repr(value): |
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.
Nice work! Today I learned something new :)
I like the solution; it's clever, but maybe too clever in a way that it will be hard for others to understand what's going on. So, I am a bit on a fence, and maybe we should just be explicit and redefine everything instead of importing the OPTIONS
.
OPTIONS = [
('admin_order_field', '"radius"'),
('admin_order_field', 'Lower(F("person_name"))'),
('boolean', 'True'),
('empty_value_display', '"Undefined"'),
('short_description', '"Is big?"'),
]
if django.VERSION[:2] <= (1, 11):
OPTIONS.append(('allow_tags', "True"))
I know you put a lot of effort into solving this issue, so I am curious to hear what you think about this.
Django's docs state:
Internally, Django looks for the property
resolve_expression
on non-stringadmin_order_field
values. This is provided byBaseExpression
.