Skip to content

[IA-4884] nfc cards hidden when no external storage module#3047

Open
Crebert08 wants to merge 5 commits into
developfrom
IA-4884-nfc-cards-hidden-when-no-external-storage-module
Open

[IA-4884] nfc cards hidden when no external storage module#3047
Crebert08 wants to merge 5 commits into
developfrom
IA-4884-nfc-cards-hidden-when-no-external-storage-module

Conversation

@Crebert08
Copy link
Copy Markdown
Contributor

@Crebert08 Crebert08 commented May 26, 2026

What problem is this PR solving?

This PR is about rendering the nfc_cards fields on the entity profile when the user has the right module permissions

Related JIRA tickets

IA-4884

Changes

  • Overrided the serializer to check if the user has the core storage permissions
  • Changed the frontend to render this field dynamically
  • Tested the backend behavior
  • Added a function in the instances views to check if the user has the right permissions before returning the full entity object
  • Tested this behavior

How to test

  • Connect to PostgreSQL in docker with sudo docker compose exec db psql -U postgres -d postgres
  • Connect to your database
  • Run this query in docker to see the users without the core storage permissions:
SELECT id, username, email 
FROM auth_user
WHERE is_superuser = FALSE 
  -- 1. Exclude users who have the permission directly
  AND id NOT IN (
      SELECT aup.user_id 
      FROM auth_user_user_permissions aup
      JOIN auth_permission ap ON aup.permission_id = ap.id
      WHERE ap.codename = 'iaso_storages'
  )
  -- 2. Exclude users who have the permission via a group
  AND id NOT IN (
      SELECT aug.user_id 
      FROM auth_user_groups aug
      JOIN auth_group_permissions agp ON aug.group_id = agp.group_id
      JOIN auth_permission ap ON agp.permission_id = ap.id
      WHERE ap.codename = 'iaso_storages'
  )
  -- 3. NEW: Only include users who have MORE THAN 1 unique permission in total
  AND id IN (
      SELECT user_id 
      FROM (
          -- Get all direct permissions
          SELECT user_id, permission_id 
          FROM auth_user_user_permissions
          
          UNION
          
          -- Get all group permissions
          SELECT aug.user_id, agp.permission_id 
          FROM auth_user_groups aug
          JOIN auth_group_permissions agp ON aug.group_id = agp.group_id
      ) AS all_user_permissions
      GROUP BY user_id
      HAVING COUNT(DISTINCT permission_id) > 1
  );
  • Connect to iaso with one of the users without the permissions
  • The NFC Cards fields shouldn't display

Print screen / video

IASO.mp4

Notes

Things that the reviewers should know:

//

Doc

Tell us where the doc can be found (docs folder, wiki, in the code...).

@Crebert08 Crebert08 changed the title Ia 4884 nfc cards hidden when no external storage module [IA-4884] nfc cards hidden when no external storage module May 26, 2026
@Crebert08 Crebert08 marked this pull request as ready for review May 28, 2026 13:57
@Crebert08 Crebert08 requested a review from Phil-V May 28, 2026 14:12
@beygorghor beygorghor added the release Should be released in production at next deploy label May 29, 2026
@beygorghor beygorghor self-requested a review May 29, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release Should be released in production at next deploy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants