Skip to content
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

Display avatars in user search #4939

Merged
merged 5 commits into from Jun 9, 2021
Merged

Conversation

tomasr8
Copy link
Member

@tomasr8 tomasr8 commented Jun 9, 2021

When searching users, instead of the default icon, avatars are displayed.
If the user does not have an avatar, the default avatar with the first letter of
the first name is used.

The group search still displays the default result icon.

Before:
Screenshot from 2021-06-08 16-41-21
After:
Screenshot from 2021-06-08 18-07-55
Screenshot from 2021-06-09 10-47-43

The `avatar_url` field is added to results from `/user/search`
and from `/api/principals`. The modification of the second
endpoint is needed because the results are used by the user search
modal.

The `avatar_url` always contains a valid url. If the user
does not have a profile picture set, a default avatar url is
returned instead.
If the user has set a profile picture, it will
be displayed in the search result instead of
the default result icon.

This change only affects user search even though
the code is shared between users and groups. Groups
still use the default `resultIcon` passed to `SearchFactory`,
if the `avatarURL` field of the search result does not exist.
@tomasr8 tomasr8 requested a review from ThiefMaster June 9, 2021 09:39
indico/modules/core/controllers.py Outdated Show resolved Hide resolved
indico/modules/users/util.py Outdated Show resolved Hide resolved
indico/modules/users/controllers.py Outdated Show resolved Hide resolved
Copy link
Member

@ThiefMaster ThiefMaster left a comment

Choose a reason for hiding this comment

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

Tested it locally and it works great! :) Just one more small naming suggestion...

@ThiefMaster ThiefMaster merged commit 9a23f94 into indico:master Jun 9, 2021
@ThiefMaster ThiefMaster deleted the search-avatars branch June 9, 2021 13:06
pferreir pushed a commit to pferreir/indico that referenced this pull request Oct 12, 2021
* Add `avatar_url` to user search results

The `avatar_url` field is added to results from `/user/search`
and from `/api/principals`. The modification of the second
endpoint is needed because the results are used by the user search
modal.

* Show avatars in user search

If the user has set a profile picture, it will
be displayed in the search result instead of
the default result icon.

This change only affects user search even though
the code is shared between users and groups. Groups
still use the default `resultIcon` passed to `SearchFactory`,
if the `avatarURL` field of the search result does not exist.
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.

None yet

2 participants