admin-users #7
0
admin/__init__.py
Normal file
0
admin/__init__.py
Normal file
3
admin/admin.py
Normal file
3
admin/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
6
admin/apps.py
Normal file
6
admin/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class AdminConfig(AppConfig):
|
||||||
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
|
name = "admin"
|
0
admin/migrations/__init__.py
Normal file
0
admin/migrations/__init__.py
Normal file
3
admin/models.py
Normal file
3
admin/models.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
12
admin/templates/admin_panel.html
Normal file
12
admin/templates/admin_panel.html
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<h3>{{ subtitle }}</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
20
admin/templates/admin_users.html
Normal file
20
admin/templates/admin_users.html
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<h3>{{ subtitle }}</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
{% for u in users %}
|
||||||
|
{{ u.email }}
|
||||||
|
{{ u.is_admin }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
3
admin/tests.py
Normal file
3
admin/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
9
admin/urls.py
Normal file
9
admin/urls.py
Normal file
|
@ -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"),
|
||||||
|
]
|
27
admin/views.py
Normal file
27
admin/views.py
Normal file
|
@ -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
|
|
@ -79,6 +79,26 @@
|
||||||
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
|
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
|
||||||
<div class="position-sticky pt-5">
|
<div class="position-sticky pt-5">
|
||||||
<ul class="nav flex-column">
|
<ul class="nav flex-column">
|
||||||
|
{% if user.is_admin %}
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="admin {% if path in 'panel users' %}active {% endif %}nav-link fw-bold" data-bs-toggle="collapse" data-bs-target="#ul_admin" aria-expanded="false" aria-controls="ul_admin" href="javascript:void()">
|
||||||
|
<i class="bi bi-person-fill-gear icon_sidebar"></i>
|
||||||
|
{% trans 'Admin' %}
|
||||||
|
</a>
|
||||||
|
<ul class="flex-column mb-2 ul_sidebar accordion-collapse {% if path in 'panel users' %}expanded{% else %}collapse{% endif %}" id="ul_admin" data-bs-parent="#sidebarMenu">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link{% if path == 'panel' %} active2{% endif %}" href="{% url 'admin:panel' %}">
|
||||||
|
{% trans 'Panel' %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link{% if path == 'users' %} active2{% endif %}" href="{% url 'admin:users' %}">
|
||||||
|
{% trans 'Users' %}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="admin {% if path == 'unassigned_devices' %}active {% endif %}nav-link fw-bold" data-bs-toggle="collapse" data-bs-target="#ul_devices" aria-expanded="false" aria-controls="ul_devices" href="javascript:void()">
|
<a class="admin {% if path == 'unassigned_devices' %}active {% endif %}nav-link fw-bold" data-bs-toggle="collapse" data-bs-target="#ul_devices" aria-expanded="false" aria-controls="ul_devices" href="javascript:void()">
|
||||||
<i class="bi bi-laptop icon_sidebar"></i>
|
<i class="bi bi-laptop icon_sidebar"></i>
|
||||||
|
|
|
@ -35,7 +35,7 @@ ALLOWED_HOSTS = []
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
"django.contrib.admin",
|
# "django.contrib.admin",
|
||||||
"django.contrib.auth",
|
"django.contrib.auth",
|
||||||
"django.contrib.contenttypes",
|
"django.contrib.contenttypes",
|
||||||
"django.contrib.sessions",
|
"django.contrib.sessions",
|
||||||
|
@ -53,6 +53,7 @@ INSTALLED_APPS = [
|
||||||
"lot",
|
"lot",
|
||||||
"documents",
|
"documents",
|
||||||
"dashboard",
|
"dashboard",
|
||||||
|
"admin",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,5 +23,6 @@ urlpatterns = [
|
||||||
path("dashboard/", include("dashboard.urls")),
|
path("dashboard/", include("dashboard.urls")),
|
||||||
path("evidence/", include("evidence.urls")),
|
path("evidence/", include("evidence.urls")),
|
||||||
path("device/", include("device.urls")),
|
path("device/", include("device.urls")),
|
||||||
|
path("admin/", include("admin.urls")),
|
||||||
path("lot/", include("lot.urls")),
|
path("lot/", include("lot.urls")),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue