djangodjango-permissionsdjango-grappellidjango-filebrowser

How to limit access to grappelli filebrowser using django auth permissions?


I need to restrict user access to filebrowser using permissions. For example, only users with permission "can_upload_files" should be able to see Filebrowser in my custom dashboard.

Is this possible?

Thanks!


Solution

  • If the thing you want to accomplish is to simply hide the "Media Management" group from your dashboard, you can use the following conditional in your dashboard.py code:

    if context.get('user').has_perm('accounts.can_upload_files'):
        self.children.append(modules.LinkList(
            _('Media Management'),
            column=2,
            children=[
                {
                    'title': _('FileBrowser'),
                    'url': '/admin/filebrowser/browse/',
                    'external': False,
                },
            ]
        ))
    

    Note that this will not actually limit access to the FileBrowser, simply hide the link.