From 898846b1df5c77745532a7a5256d52b1436d2bfd Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 3 Oct 2024 17:46:02 +0200 Subject: [PATCH] add base admin panel for admin users --- admin/__init__.py | 0 admin/admin.py | 3 +++ admin/apps.py | 6 ++++++ admin/migrations/__init__.py | 0 admin/models.py | 3 +++ admin/templates/admin_panel.html | 12 ++++++++++++ admin/templates/admin_users.html | 20 ++++++++++++++++++++ admin/tests.py | 3 +++ admin/urls.py | 9 +++++++++ admin/views.py | 27 +++++++++++++++++++++++++++ dashboard/templates/base.html | 20 ++++++++++++++++++++ dhub/settings.py | 3 ++- dhub/urls.py | 1 + 13 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 admin/__init__.py create mode 100644 admin/admin.py create mode 100644 admin/apps.py create mode 100644 admin/migrations/__init__.py create mode 100644 admin/models.py create mode 100644 admin/templates/admin_panel.html create mode 100644 admin/templates/admin_users.html create mode 100644 admin/tests.py create mode 100644 admin/urls.py create mode 100644 admin/views.py diff --git a/admin/__init__.py b/admin/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/admin/admin.py b/admin/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/admin/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/admin/apps.py b/admin/apps.py new file mode 100644 index 0000000..6d596f5 --- /dev/null +++ b/admin/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AdminConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "admin" diff --git a/admin/migrations/__init__.py b/admin/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/admin/models.py b/admin/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/admin/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/admin/templates/admin_panel.html b/admin/templates/admin_panel.html new file mode 100644 index 0000000..6d3bd14 --- /dev/null +++ b/admin/templates/admin_panel.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block content %} +
+
+

{{ subtitle }}

+
+
+ + +{% endblock %} diff --git a/admin/templates/admin_users.html b/admin/templates/admin_users.html new file mode 100644 index 0000000..9f3cd32 --- /dev/null +++ b/admin/templates/admin_users.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block content %} +
+
+

{{ subtitle }}

+
+
+ +
+
+ {% for u in users %} + {{ u.email }} + {{ u.is_admin }} + {% endfor %} +
+
+ +{% endblock %} diff --git a/admin/tests.py b/admin/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/admin/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/admin/urls.py b/admin/urls.py new file mode 100644 index 0000000..6a9d492 --- /dev/null +++ b/admin/urls.py @@ -0,0 +1,9 @@ +from django.urls import path +from admin import views + +app_name = 'admin' + +urlpatterns = [ + path("panel/", views.PanelView.as_view(), name="panel"), + path("users/", views.UsersView.as_view(), name="users"), +] diff --git a/admin/views.py b/admin/views.py new file mode 100644 index 0000000..e95c8c2 --- /dev/null +++ b/admin/views.py @@ -0,0 +1,27 @@ +from django.utils.translation import gettext_lazy as _ +from django.views.generic.base import TemplateView +from dashboard.mixins import DashboardView +from user.models import User + + +class PanelView(DashboardView, TemplateView): + template_name = "admin_panel.html" + title = _("Admin") + breadcrumb = _("admin") + " /" + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + return context + + +class UsersView(DashboardView, TemplateView): + template_name = "admin_users.html" + title = _("Users") + breadcrumb = _("admin / Users") + " /" + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context.update({ + "users": User.objects.filter() + }) + return context diff --git a/dashboard/templates/base.html b/dashboard/templates/base.html index 3d046f1..c8b0a38 100644 --- a/dashboard/templates/base.html +++ b/dashboard/templates/base.html @@ -79,6 +79,26 @@