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 %}
+
+
+
+{% endblock %}
diff --git a/admin/templates/admin_users.html b/admin/templates/admin_users.html
new file mode 100644
index 0000000..37fbf96
--- /dev/null
+++ b/admin/templates/admin_users.html
@@ -0,0 +1,39 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+
+
+
+
+
+
+ Email |
+ is Admin |
+ |
+ |
+
+
+
+
+ {% for u in users %}
+ {{ u.email }} |
+ {{ u.is_admin }} |
+ |
+ |
+
+ {% endfor %}
+
+
+
+
+
+{% endblock %}
diff --git a/admin/templates/delete_user.html b/admin/templates/delete_user.html
new file mode 100644
index 0000000..5aa402d
--- /dev/null
+++ b/admin/templates/delete_user.html
@@ -0,0 +1,38 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+
+{% load django_bootstrap5 %}
+
+
+ Are you sure than want remove the lot {{ object.name }} with {{ object.devices.count }} devices.
+
+
+
+
+{% endblock %}
diff --git a/admin/templates/user.html b/admin/templates/user.html
new file mode 100644
index 0000000..1ea00d8
--- /dev/null
+++ b/admin/templates/user.html
@@ -0,0 +1,32 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+
+
+{% load django_bootstrap5 %}
+
+{% 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..cd79c3f
--- /dev/null
+++ b/admin/urls.py
@@ -0,0 +1,12 @@
+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"),
+ path("users/new", views.CreateUserView.as_view(), name="new_user"),
+ path("users/edit/", views.EditUserView.as_view(), name="edit_user"),
+ path("users/delete/", views.DeleteUserView.as_view(), name="delete_user"),
+]
diff --git a/admin/views.py b/admin/views.py
new file mode 100644
index 0000000..bcc8889
--- /dev/null
+++ b/admin/views.py
@@ -0,0 +1,89 @@
+from django.urls import reverse_lazy
+from django.shortcuts import get_object_or_404
+from django.utils.translation import gettext_lazy as _
+from django.views.generic.base import TemplateView
+from django.views.generic.edit import (
+ CreateView,
+ UpdateView,
+ DeleteView,
+)
+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
+
+
+class CreateUserView(DashboardView, CreateView):
+ template_name = "user.html"
+ title = _("User")
+ breadcrumb = _("admin / User") + " /"
+ success_url = reverse_lazy('admin:users')
+ model = User
+ fields = (
+ "email",
+ "password",
+ "is_admin",
+ )
+
+ def form_valid(self, form):
+ form.instance.institution = self.request.user.institution
+ form.instance.set_password(form.instance.password)
+ response = super().form_valid(form)
+ return response
+
+
+class DeleteUserView(DashboardView, DeleteView):
+ template_name = "delete_user.html"
+ title = _("Delete user")
+ breadcrumb = "admin / Delete user"
+ success_url = reverse_lazy('admin:users')
+ model = User
+ fields = (
+ "email",
+ "password",
+ "is_admin",
+ )
+
+ def form_valid(self, form):
+ response = super().form_valid(form)
+ return response
+
+
+class EditUserView(DashboardView, UpdateView):
+ template_name = "user.html"
+ title = _("Edit user")
+ breadcrumb = "admin / Edit user"
+ success_url = reverse_lazy('admin:users')
+ model = User
+ fields = (
+ "email",
+ "is_admin",
+ )
+
+ def get_form_kwargs(self):
+ pk = self.kwargs.get('pk')
+ self.object = get_object_or_404(self.model, pk=pk)
+ #self.object.set_password(self.object.password)
+ kwargs = super().get_form_kwargs()
+ return kwargs
diff --git a/dashboard/mixins.py b/dashboard/mixins.py
index 07004ee..8b70934 100644
--- a/dashboard/mixins.py
+++ b/dashboard/mixins.py
@@ -47,7 +47,9 @@ class DashboardView(LoginRequiredMixin):
dev_ids = self.request.session.pop("devices", [])
self._devices = []
- for x in Annotation.objects.filter(value__in=dev_ids).filter(owner=self.request.user).distinct():
+ for x in Annotation.objects.filter(value__in=dev_ids).filter(
+ owner=self.request.user.institution
+ ).distinct():
self._devices.append(Device(id=x.value))
return self._devices
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 @@