Skip to main content

A panel for Django Debug Toolbar (DjDT) to display the current user's permissions.

Project description

Permission panel for Django Debug Toolbar Pypi

License coverage Django versions Python versions

A simple DjDT panel displaying the permissions granted to the current user, how the current user obtained each one of them (directly or through a group membership), and the resulting consolidated permissions set.

djdt-permission_capture

Installation (on top of Django Debug Toolbar)

First, install django-debug-toolbar (instructions here), then:

  1. Install permission panel, either with Pip or Poetry:

    pip install 'git+https://github.com/baudhuina/djdt-permissions.git@1.0.0#egg=djdt_permissions'
    

    or complete your project's pyproject.toml file with XXX TO BE COMPLETED and run poetry install or poetry update.

  2. Add djdt_permission to INSTALLED_APPS, make sure it's below django.toolbar:

    Please note that just as the Debug Toolbar, this panel is not supposed to be installed if 'DEBUG' is False.

    if DEBUG == True:
       INSTALLED_APPS += [
        ...
        'debug_toolbar',
        'djdt_permissions',
        ...
       ]
    
  3. Register the new panel by adding path djdt_permissions.panels.PermissionsPanel to setting DEBUG_TOOLBAR_PANELS (which is entirely conditional to DEBUG). The sequence of the panels defines their order in the toolbar.

    DEBUG_TOOLBAR_PANELS = [
         'djdt_permissions.panels.PermissionsPanel',
         'debug_toolbar.panels.history.HistoryPanel',
         'debug_toolbar.panels.versions.VersionsPanel',
         # ... any other panel.
     ]
    
  4. (optional) If you want the panel to be disabled by default, add its full path in the DEBUG_TOOLBAR_CONFIG[DISABLE_PANELS] set.

    DEBUG_TOOLBAR_CONFIG = {
        "DISABLE_PANELS":  {
             'djdt_permissions.panels.permissions_panelPermissionsPanel',
             # any other panel to disable
         },
        # other config settings.
    ]
    

Usage

The Permission Panel is used just as any other panel of the Django Debug Toolbar:

  • Open DJdT overlay;
  • Enable, disable, consult the panel at will...

Installing the test project

Would you wish to modify/contribute to this project...

NB: The commands below assume that your DJANGO_SETTINGS_MODULEis not set, and that the settings will be the default value from manage.py, i.e.'test_project/settings. If it is set to another value, add a --setings=test_project.settingsoption to allmanage.py` commands.

  1. Fork the GIT repo from GitHub. It contains a Django test project.
  2. Install dependencies: poetry install.
  3. Apply migrations: manage.py migrate.
  4. Run server: manage.py runserver.
  5. Point your browser at http://localhost:8000.

Running the tests

Once the test project is installed (see above), run the tests without coverage measurement:

manage.py test

or with coverage measurement (report will be in coverage_html/index.html):

coverage run -m manage test [-v2]

To run the tests for all supported python and django combinations:

tox

Contact me

alain.baudhuin@skynet.be

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djdt_permissions-1.0.2.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

djdt_permissions-1.0.2-py3-none-any.whl (9.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page