Closed phsetti closed 5 years ago
Hey @phsetti, thanks a lot for your contribution! I tested and everything is working, except the sender
and receiver
fields on the FOIRequest's admin page (i.e. http://localhost:8000/a/foi_requests/foirequest/).
However, any reason for not using the ordering
on the model's Meta
class? Like this: https://github.com/okfn-brasil/pedidosanonimos/blob/cbe26571483b5cf0acd838785635d03b57a2c164/web/foi_requests/models.py#L93-L94
With that change, the ordering is applied everywhere a PublicBody is shown (sorry for not adding this to the original issue, I'm pretty new with Django and I forgot about this).
Hi @vitorbaptista! I think I made a mistake. I thought that only PublicBody
should be ordered on admin not MessageInline
. I will work on it.
The ordering
sort is case sensitive so if you have A name
, a other name
and B name
into you database it would be sort:
A name
B name
a other name
What I did is case insensitive. I tried to find a way using ordering
but I didn't find.
If you want to add this ordering
to every query I can override the PublicBody.object
to always sort by name, but I thought it wasn't desired, what do you think?
@phsetti The public bodies names should always start with an uppercase letter like "Ministério da Justiça", "Prefeitura de São Paulo", etc. As we allow anyone to create new public bodies, this isn't always the case, but from time to time we'll go over the newly created public bodies and clean their names.
In other words, it's OK to just sort by name
instead of lower(name)
, so ordering
is the best way to do it IMHO.
@vitorbaptista done :)
@phsetti Merged! Thanks! :tada:
PublicBody
by name;PublicBody
model;get_queryset()
onPublicBodyAdmin
to order by name;self.fields['receiver'].queryset
onMessageForm
to orderPublicBody
by name.