Skip to content

Sort group leaders and members alphabetically by displayed name - #7832

Open
smithellis wants to merge 1 commit into
mozilla:mainfrom
smithellis:sort-group-members-by-username
Open

Sort group leaders and members alphabetically by displayed name#7832
smithellis wants to merge 1 commit into
mozilla:mainfrom
smithellis:sort-group-members-by-username

Conversation

@smithellis

Copy link
Copy Markdown
Contributor

The group profile page listed leaders and members in whatever order the database returned, which also made member pagination unstable across pages. Order both lists case-insensitively by the name the page actually renders: the profile's display name when set, falling back to the username, mirroring Profile.display_name.

Fixes #7270

The group profile page listed leaders and members in whatever order the
database returned, which also made member pagination unstable across
pages. Order both lists case-insensitively by the name the page actually
renders: the profile's display name when set, falling back to the
username, mirroring Profile.display_name.

Fixes mozilla#7270

@escattone escattone left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Smith! I hope all is well! Sorry for the delay in getting to this, but it's been crazy busy lately. This looks great, but just needs a small change and then should be good to go. Thanks for the help!

Comment thread kitsune/groups/views.py
Comment on lines +88 to +89
leaders = prof.leaders.all().select_related("profile").order_by(DISPLAY_NAME_ORDER)
members_qs = prof.group.user_set.all().select_related("profile").order_by(DISPLAY_NAME_ORDER)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For both of these, since the profile name doesn't have to be unique, we should guarantee the order for the case when multiple users have the same profile name, by adding a secondary sort column name:

.order_by(DISPLAY_NAME_ORDER, "username")

and also add a test for that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sort the display of group members in alpha order of username

2 participants