Skip to content

Commit

Permalink
Merge pull request #975 from ministryofjustice/add-django-admin
Browse files Browse the repository at this point in the history
Enables the Django admin
  • Loading branch information
rossjones authored Jan 13, 2022
2 parents 4c476ab + 11ec7fe commit 8feb2b9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions controlpanel/api/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.contrib import admin
from controlpanel.api.models.user import User


def make_migration_pending(modeladmin, request, queryset):
queryset.update(migration_state=User.PENDING)


make_migration_pending.short_description = "Mark selected users as pending migration"


class UserAdmin(admin.ModelAdmin):
list_display = ("username", "auth0_id", "email", "is_superuser", "migration_state")
actions = [make_migration_pending]
exclude = ("password",)


admin.site.register(User, UserAdmin)
2 changes: 2 additions & 0 deletions controlpanel/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
INSTALLED_APPS = [
# Django channels for asynchronous support
"channels",
# Django Admin
"django.contrib.admin",
# Django auth system
"django.contrib.auth",
# OIDC client
Expand Down
2 changes: 2 additions & 0 deletions controlpanel/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from django.conf import settings
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import include, path
from django_prometheus import exports

urlpatterns = [
path("", include("controlpanel.frontend.urls")),
path("admin/", admin.site.urls),
path("api/cpanel/v1/", include("controlpanel.api.urls")),
path("api/k8s/", include("controlpanel.kubeapi.urls")),
path("oidc/", include("mozilla_django_oidc.urls")),
Expand Down

0 comments on commit 8feb2b9

Please sign in to comment.