Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance APIKey ModelAdmin Class #203

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mustafaabughazy
Copy link

Enhance APIKey ModelAdmin Class

  • Adding ("expiry_date", "revoked") to list_filter

  • Adding search_help_text (New in Django 4.0)

  • Adding "revoked" to readonly_fields (Depend on the New revoke action to revoke an APIKey)

  • Adding Organized fieldsets

  • Adding ("revoke", "verify") actions

  • Adding test-cases cover the changes

- Adding ("expiry_date", "revoked") to list_filter
- Adding search_help_text (New in Django 4.0)
- Adding "revoked" to readonly_fields (Depend on the New revoke action to revoke an APIKey)
- Adding Organized fieldsets
- Adding ("revoke", "verify") actions

- Adding test-cases cover the changes
@codecov-commenter
Copy link

codecov-commenter commented May 21, 2022

Codecov Report

Merging #203 (e313772) into master (57d0bc0) will increase coverage by 0.58%.
The diff coverage is 98.55%.

@@            Coverage Diff             @@
##           master     #203      +/-   ##
==========================================
+ Coverage   97.11%   97.70%   +0.58%     
==========================================
  Files          22       22              
  Lines         520      653     +133     
==========================================
+ Hits          505      638     +133     
  Misses         15       15              
Impacted Files Coverage Δ
src/rest_framework_api_key/admin.py 90.32% <94.87%> (+13.39%) ⬆️
tests/test_admin.py 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@florimondmanca
Copy link
Owner

Thanks again @Mustafa-Abu-Ghazy for opening this. As in #204, I need to ask for us to write up what problem these changes help address. If possible, let's do this in an issue explaining what practical problems or limitations currently exist with the default ModelAdmin.

@mustafaabughazy
Copy link
Author

Hi @florimondmanca,

It's not a problem as much it's enhancement for the user experience while dealing with the APIKeyModelAdmin

  • First for the changelist page filters: Current default APIKeyModelAdmin doesn't have tha ability to filter based on the Expiry-Date or the Revoked flag. so I've added them.
  • Second for the search_help_text its a new option in Django 4.0, to add description below the search bar guiding the user by which values could be used for search.
  • Third I thought it's better for the user to have a special action to revoke revoke a key, instead of editing the field manually.
    revoke action is limited to the users have change permission (to keep the same authorization level as before).
  • Fourth, Current ModelAdmin doesn't provide a way for the user to verify the APIKey, so I'v added a verify action to be used for that purpose.

Both of revoke and verify actions add a log into the LogEntry table and will be shown in the instance change history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants