Browse Source

Expose Credentials model in Django admin

This is to help troubleshoot 2FA issues without
running manual SQL queries.
pull/537/head
Pēteris Caune 3 years ago
parent
commit
8a154cbaf5
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
1 changed files with 14 additions and 3 deletions
  1. +14
    -3
      hc/accounts/admin.py

+ 14
- 3
hc/accounts/admin.py View File

@ -6,7 +6,7 @@ from django.template.loader import render_to_string
from django.urls import reverse
from django.utils.html import escape
from django.utils.safestring import mark_safe
from hc.accounts.models import Profile, Project
from hc.accounts.models import Credential, Profile, Project
@mark_safe
@ -71,7 +71,7 @@ class TeamFieldset(Fieldset):
class NumChecksFilter(admin.SimpleListFilter):
title = "Checks"
title = "check count"
parameter_name = "num_checks"
@ -116,9 +116,10 @@ class ProfileAdmin(admin.ModelAdmin):
list_filter = (
"user__date_joined",
"last_active_date",
"reports_allowed",
"reports",
"check_limit",
NumChecksFilter,
"theme",
)
fieldsets = (ProfileFieldset.tuple(), TeamFieldset.tuple())
@ -244,3 +245,13 @@ class HcUserAdmin(UserAdmin):
admin.site.unregister(User)
admin.site.register(User, HcUserAdmin)
@admin.register(Credential)
class CredentialAdmin(admin.ModelAdmin):
list_display = ("id", "created", "email", "name")
search_fields = ["id", "code", "name", "user__email"]
list_filter = ["created"]
def email(self, obj):
return obj.user.email

Loading…
Cancel
Save