Skip to content

feat(backend): Add user profile - #9116

Merged
SchrodingersGat merged 74 commits into
inventree:masterfrom
matmair:feat(backend)-Add-user-profile
Mar 4, 2025
Merged

SchrodingersGat merged 74 commits into
inventree:masterfrom
matmair:feat(backend)-Add-user-profile

Conversation

@matmair

@matmair matmair commented Feb 20, 2025 •

Copy link
Copy Markdown
Member

This PR:

  • Adds user profiles containing basic info needed for commercial ops
  • Adds endpoints to get users profiles
  • Enables persisting of preferred language
  • Enables persisting of theme settings
  • Adds user and group info pages
  • Adds user hover and link to detail pages

UI for "normal" users to discover users and groups
grafik
grafik
grafik
grafik

Hover for user / owner / Group Pill
grafik

To address in later PRs:

  • Add avatar pictures to users
  • Add avatar picture to groups
  • Inline self-service group joining

Closes invenhost#107
Closes invenhost#117
Closes #7528

@matmair matmair added enhancement This is an suggested enhancement or new feature api Relates to the API User Interface Related to the frontend / User Interface labels Feb 20, 2025
@matmair matmair added this to the 1.0.0 milestone Feb 20, 2025
@matmair matmair self-assigned this Feb 20, 2025
@netlify

netlify Bot commented Feb 20, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit 73f73b8
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/67c5e1af629ec50008d0eefb

@codecov

codecov Bot commented Feb 20, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 92.74611% with 28 lines in your changes missing coverage. Please review.

Project coverage is 86.17%. Comparing base (ac96ba4) to head (73f73b8).
Report is 212 commits behind head on master.

Files with missing lines Patch % Lines
src/backend/InvenTree/users/models.py 86.53% 7 Missing ⚠️
src/backend/InvenTree/users/serializers.py 93.93% 4 Missing ⚠️
src/frontend/src/components/details/Details.tsx 71.42% 2 Missing and 2 partials ⚠️
src/frontend/src/functions/auth.tsx 82.60% 4 Missing ⚠️
src/frontend/src/tables/settings/GroupTable.tsx 33.33% 2 Missing and 2 partials ⚠️
src/frontend/src/pages/core/CoreIndex.tsx 75.00% 2 Missing ⚠️
src/frontend/src/pages/core/UserDetail.tsx 90.90% 0 Missing and 2 partials ⚠️
src/backend/InvenTree/InvenTree/metadata.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9116      +/-   ##
==========================================
+ Coverage   86.08%   86.17%   +0.09%     
==========================================
  Files        1182     1187       +5     
  Lines       52177    52449     +272     
  Branches     2187     2212      +25     
==========================================
+ Hits        44916    45200     +284     
+ Misses       6706     6690      -16     
- Partials      555      559       +4     
Flag Coverage Δ
backend 88.06% <89.56%> (+<0.01%) ⬆️
migrations 42.97% <54.34%> (+0.02%) ⬆️
pui ∅ <89.74%> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matmair matmair added the full-run Always do a full QC CI run label Feb 21, 2025
@matmair matmair closed this Feb 21, 2025
@matmair matmair reopened this Feb 21, 2025
@matmair

matmair commented Mar 2, 2025

Copy link
Copy Markdown
Member Author

@SchrodingersGat thank you for the review - I have addressed the issues you raised.
Should we add a title or position field too? I have found that pretty handy in my org of +10k ppl

@SchrodingersGat

Copy link
Copy Markdown
Member

@SchrodingersGat thank you for the review - I have addressed the issues you raised. Should we add a title or position field too? I have found that pretty handy in my org of +10k ppl

Yeah, that makes sense, happy for that addition :)

@matmair

matmair commented Mar 3, 2025

Copy link
Copy Markdown
Member Author

@SchrodingersGat done!

@SchrodingersGat

Copy link
Copy Markdown
Member

@matmair still looks like the profile settings cannot be edited by non-admin users:

image

@matmair

matmair commented Mar 3, 2025

Copy link
Copy Markdown
Member Author

should be fixed now

@SchrodingersGat

Copy link
Copy Markdown
Member

@matmair nice work here, thanks for making the fixes. This is a great new feature :)

@SchrodingersGat
SchrodingersGat merged commit 0d1ab4e into inventree:master Mar 4, 2025
@SchrodingersGat
SchrodingersGat deleted the feat(backend)-Add-user-profile branch March 4, 2025 11:57
simonkuehling pushed a commit to simonkuehling/InvenTree that referenced this pull request Mar 4, 2025
* Add user profile

* fix choice set

* ensure primary_group is valid

* add missing migrations

* fix tests

* merge migrations

* add migration test

* add new model to ruleset

* ensure changed to the m2m conenction also validate primary grups

* move signals

* fix import?

* patch user language through

* use set methods correctly

* bump api

* refactoring to make debugging and extending easier

* fix dum recurrsion problem

* fix user pk lookup

* rename migration

* add user and group page

* cleanup

* add hoverCard for user / owner / group render

* include owner_model in owner responses

* move user serializers to users

* add profile to list

* add brief serializer for profiles

* ensure profile is present in most apis

* extend rendered data

* store and observe langauge in profile

* reduce unneeded complexity

* enable access to full profle (including internal fields) in me serializer

* move theme to a single object

* persist theme settings

* fix radius lookup

* remove debug message

* fix filter

* remove unused field

* remove image fields

* add setting to control showing profiles

* fix settings

* update test

* fix theme reload

* Add contact UI

* Add profile edit screen

* fix test

* Add testing for user theme panel

* fix var name

* complete coverage of theme

* Add test for new pages

* make test more reliable in strict mode

* remove step

* fix ref

* add verbose names

* fix used setting

* extend tests

* fix permissions

* fix lookup

* use lookup to enuse ursls stay valid

* update migrations

* Add position field

* fix permissions
SchrodingersGat added a commit that referenced this pull request Mar 4, 2025
* increase character limits on all link fields to 2000

* update test to still trigger

* Don't fail when diff is too big for echo (#9205)

* Reduce severity of error message (#9209)

- Currently flooding sentry.io with reports

* Disable pagination for ConfigList class (#9210)

* [API] Auth login error (#9212)

Fixes #9211

* [UI] Table Update (#9220)

- Retain user selection for pageSize

* renumber migrations after merge from master

* Remove quick actions (#9222)

* Remove placeholder components

- No function
- Cleanup for 1.0.0

* Remove Placeholder.tsx

* feat(backend): Add user profile (#9116)

* Add user profile

* fix choice set

* ensure primary_group is valid

* add missing migrations

* fix tests

* merge migrations

* add migration test

* add new model to ruleset

* ensure changed to the m2m conenction also validate primary grups

* move signals

* fix import?

* patch user language through

* use set methods correctly

* bump api

* refactoring to make debugging and extending easier

* fix dum recurrsion problem

* fix user pk lookup

* rename migration

* add user and group page

* cleanup

* add hoverCard for user / owner / group render

* include owner_model in owner responses

* move user serializers to users

* add profile to list

* add brief serializer for profiles

* ensure profile is present in most apis

* extend rendered data

* store and observe langauge in profile

* reduce unneeded complexity

* enable access to full profle (including internal fields) in me serializer

* move theme to a single object

* persist theme settings

* fix radius lookup

* remove debug message

* fix filter

* remove unused field

* remove image fields

* add setting to control showing profiles

* fix settings

* update test

* fix theme reload

* Add contact UI

* Add profile edit screen

* fix test

* Add testing for user theme panel

* fix var name

* complete coverage of theme

* Add test for new pages

* make test more reliable in strict mode

* remove step

* fix ref

* add verbose names

* fix used setting

* extend tests

* fix permissions

* fix lookup

* use lookup to enuse ursls stay valid

* update migrations

* Add position field

* fix permissions

* Fix font size in location column (#9230)

* [WIP] Background reports (#9199)

* Update report generation progress

* Add shim task for offloading report printing

* Cleanup

* Add detail endpoints for label and report outputs

* Display report printing progress in UI

* Implement similar for label printing

* Reduce output for CI

* Add plugin slug

* Bump API version

* Ensure it works with machine printing

* Fix null comparison

* Fix SKU link

* Update playwright tests

* Massively reduce log output when printing

* handle null values in existing db data

* fix test to pass at max character limit again

---------

Co-authored-by: Matthias Mair <[email protected]>
Co-authored-by: Oliver <[email protected]>
Co-authored-by: Joe Rogers <[email protected]>
@matmair

matmair commented Mar 5, 2025

Copy link
Copy Markdown
Member Author

@jacobfelknor would you be interested in getting this integrated with the LDAP sync? I have some ideas but would need a user/admin to hash some things out from the consumer side.

@jacobfelknor

Copy link
Copy Markdown
Contributor

I'm happy to take a look. It will probably be a few days before I can commit some time to it

@matmair

matmair commented Mar 6, 2025

Copy link
Copy Markdown
Member Author

Great; No time pressure whatsoever on this issue.
I would be interested into a few insights before I start dev:

  1. which of the new profile fields you would show on the hover cards
  2. what behaviour you would expect with LDAP sync: should there be a default mapping into profiles
  3. should synced arguments be locked or still editable; would that make sense as a setting

@jacobfelknor

Copy link
Copy Markdown
Contributor

Sorry for the delay on this, but I'm hoping to have some time to take a look over the next couple days

@jacobfelknor

jacobfelknor commented Mar 20, 2025 •

Copy link
Copy Markdown
Contributor

@matmair alright, to answer your questions

  1. which of the new profile fields you would show on the hover cards

I think the minimal set of name, active, and status message would be all I need/expect.

I can see how having job title/location would be helpful for large organizations, so that makes sense too if you'd like it. I do like adding whether the user is an administrator and perhaps the primary group if set.

  1. what behaviour you would expect with LDAP sync: should there be a default mapping into profiles
  2. should synced arguments be locked or still editable; would that make sense as a setting

I tend to follow GitLab's example on these kinds of questions. They keep it pretty simple. They obtain email, name, and group membership from LDAP. Only the email address is locked (since that is the login method). It has a setting for whether users can change their Display Name. Everything else in the user profile (job title, location, etc) can be edited freely and isn't populated directly from LDAP

I have noticed that right now in InvenTree the email from LDAP is attached to the Django user object, but doesn't get populated in the profile email addresses. I think this is the biggest deal for our instance moving forward. I think I can add this with the django_auth_ldap.backend.populate_user signal

@matmair

matmair commented Mar 24, 2025

Copy link
Copy Markdown
Member Author

Thank you for your feedback, I will file a PR to sync these fields

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

Labels

api Relates to the API enhancement This is an suggested enhancement or new feature full-run Always do a full QC CI run User Interface Related to the frontend / User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User facing user/group info page System: Save user language setting Default language is overwriten by browser language settings

3 participants