2

I'm trying to use django-role-permissions but it doesn't assign available_permissions to Group nor to User.

from rolepermissions.roles import AbstractUserRole

class PERMISSIONS:
    CAN_SEE_ALL_INVOICES = 'can_see_all_invoices'
    CAN_SEE_OWN_INVOICES = 'can_see_own_invoices'

class Admin(AbstractUserRole):
    verbose_name = 'Admin'
    available_permissions = {
        PERMISSIONS.CAN_SEE_ALL_INVOICES:True,
    }

class Broker(AbstractUserRole):
    verbose_name = 'Maklér'
    available_permissions = {
        PERMISSIONS.CAN_SEE_ALL_INVOICES: False,
        PERMISSIONS.CAN_SEE_OWN_INVOICES: True,
    }

After sync_roles I checked the admin and also tried to programmatically check the permission for the user that has Broker role and they doesn't have the permission.

How is that possible?

Milano
  • 18,048
  • 37
  • 153
  • 353
  • unfortunately, this is how the library works. You can write your own command to add permissions to group. It is better in terms in performance to have the permissions directly linked to the user, but it needs more storage. On the other hand, it is harder to manage, as you have to re-examine the permissions for all users in a specific group. – Mahdy H. Jun 19 '23 at 09:11

0 Answers0