Closed filipweidemann closed 10 months ago
Patch coverage: 87.50%
and project coverage change: +0.20%
:tada:
Comparison is base (
3940e1c
) 75.00% compared to head (07a1e0f
) 75.21%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@filipweidemann Thanks for creating this PR! Just a quick question: Since you seem to have run black
it is hard for me to identify the actual content changes. I assume it's the file_list
, its sorting and passing the file_list
into the context if it exists. Did I miss anything?
Can you add a test that verifies files are sorted? This feature got lost since a test did not cover it. It would be great if we fixed this for the future.
@fsbraun okay good catch, running black
was not intentional, I just use it for everything by default and forgot to turn it off. I'll fix that and try to add some tests as well.
And yes, file_list
is basically all of the fix, we just have to make sure that it'll only be created when there is no explicit order_by
set, so it is wrapped inside a conditional check and only gets passed into the context of the render function when it is explicitly used, else we just use file_qs
.
Okay @fsbraun, here we go.
I reverted the black
formatting and added some tests with the expected sort behaviour.
I really was not happy with using QuerySet
objects by default and falling back to a list
just to do the sorting inside the Python code.
So I did a quick refactoring and implemented the solution I already talked about inside the PR description.
Currently we are using Coalesce
to create a temporary coalesce_sort_field
that priorititzes the name
field and falls back to the original_filename
for all objects without a set name
. I used Case
to catch the empty strings of the name
field since the default behaviour of Coalesce
does not interpret empty strings and NoneType
equally, but we want to fall back on empty strings as well.
Would be nice if you could have a quick look & maybe kick off the CI again.
If something is still unclear or needs another refactor, let me know. Thanks.
Hey, quick question: when will this get merged & released? I don't want to pressure anyone but a quick estimate would be nice because right now I'm thinking about shipping the fork to prod environments to bridge the gap until the release is there.
But I would obviously avoid that if you're saying that this will be released this week or something :)
Thanks!
@filipweidemann Will release it the next days as 3.0.6. (Merged right now. - I typically do not merge immediately after reviewing to give other community members a chance of looking at it.)
Great stuff, that's all I needed to know. :) Thanks for explaining the workflow and handling the release!
Description
This PR intends to hotfix #1415 by reintroducing the
.sort()
function onfile_qs
inside thefiler/admin/folderadmin.py
logic.We did not modify any existing tests or added new ones because the function is returning rendered HTML and it is currently unclear how we could test this in an elegant way.
We are also aware that there are better ways to accomplish the same result, e.g. by using Django's
QuerySet.annotate
andCoalesce
DB functions to add a correct sort target to the queryset, so that.order_by()
works as intended.However, we did not want to refactor the existing solution right now but rather hotfix the (currently broken) behaviour.
Related resources
Checklist
master