Skip to content

Commit

Permalink
Fix: Customise django admin panel
Browse files Browse the repository at this point in the history
Signed-off-by: George J Padayatti <george.padayatti@igrant.io>
  • Loading branch information
georgepadayatti committed Apr 5, 2024
1 parent b341108 commit 711a56c
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 4 deletions.
8 changes: 7 additions & 1 deletion config/admin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from django.contrib import admin
from .models import DataSource,Verification, VerificationTemplate, ImageModel
from customadminsite.admin import myadminsite

# Register your models here.
admin.site.register(DataSource)
admin.site.register(Verification)
admin.site.register(VerificationTemplate)
admin.site.register(ImageModel)
admin.site.register(ImageModel)

myadminsite.register(DataSource)
myadminsite.register(Verification)
myadminsite.register(VerificationTemplate)
myadminsite.register(ImageModel)
3 changes: 2 additions & 1 deletion connection/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from .models import Connection
from customadminsite.admin import myadminsite

# Register your models here.
admin.site.register(Connection)
myadminsite.register(Connection)
Empty file added customadminsite/__init__.py
Empty file.
22 changes: 22 additions & 0 deletions customadminsite/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from django.contrib.admin import AdminSite
from django.contrib.auth.forms import AuthenticationForm


# Register your models here.
class MyAdminSite(AdminSite):
"""
App-specific admin site implementation
"""

login_form = AuthenticationForm

site_header = 'Dataspace Administration'

def has_permission(self, request):
"""
Checks if the current user has access.
"""
return request.user.is_active


myadminsite = MyAdminSite(name='myadmin')
5 changes: 5 additions & 0 deletions customadminsite/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class CustomadminsiteConfig(AppConfig):
name = 'customadminsite'
Empty file.
3 changes: 3 additions & 0 deletions customadminsite/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions customadminsite/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions customadminsite/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
3 changes: 2 additions & 1 deletion data_disclosure_agreement/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from .models import DataDisclosureAgreement
from customadminsite.admin import myadminsite

# Register your models here.
admin.site.register(DataDisclosureAgreement)
myadminsite.register(DataDisclosureAgreement)
1 change: 1 addition & 0 deletions dataspace_backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# Application definition

INSTALLED_APPS = [
"customadminsite",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
Expand Down
4 changes: 3 additions & 1 deletion dataspace_backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from customadminsite.admin import myadminsite

urlpatterns = [
path("admin/", admin.site.urls),
path("admin/", myadminsite.urls),
path("superadmin/", admin.site.urls),
path("onboard/", include("onboard.urls")),
path("config/", include("config.urls")),
path('webhook/', include("webhook.urls")),
Expand Down

0 comments on commit 711a56c

Please sign in to comment.