user-panel #9

Merged
cayop merged 25 commits from user-panel into main 2024-10-11 14:26:36 +00:00
8 changed files with 82 additions and 115 deletions
Showing only changes of commit 0a9596d33b - Show all commits

View File

@ -185,7 +185,17 @@
{% endblock messages %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2">
<h1 class="h2">{{ title }}</h1>
<form method="post" action="{% url 'dashboard:search' %}">
{% csrf_token %}
<div class="input-group rounded">
<input type="search" name="search" class="form-control rounded" placeholder="Search your device..." aria-label="Search" aria-describedby="search-addon" />
<span class="input-group-text border-0" id="search-addon">
<i class="fas fa-search"></i>
</span>
</div>
</form>
</div>
<div class="row border-bottom mb-3">
<div class="col">
<small style="color:#899bbd"><i>{{ breadcrumb }}</i></small>

View File

@ -1,4 +1,4 @@
# Generated by Django 5.0.6 on 2024-10-07 11:38
# Generated by Django 5.0.6 on 2024-10-10 09:46
import django.db.models.deletion
from django.conf import settings

View File

@ -1,22 +0,0 @@
# Generated by Django 5.0.6 on 2024-09-18 10:55
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("evidence", "0003_alter_annotation_type"),
("user", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="annotation",
name="owner",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="user.institution"
),
),
]

View File

@ -1,4 +1,4 @@
# Generated by Django 5.0.6 on 2024-07-27 16:23
# Generated by Django 5.0.6 on 2024-10-10 10:14
import django.db.models.deletion
from django.conf import settings
@ -10,6 +10,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
("user", "0001_initial"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
@ -36,6 +37,15 @@ class Migration(migrations.Migration):
"owner",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="user.institution",
),
),
(
"user",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to=settings.AUTH_USER_MODEL,
),
),
@ -62,6 +72,51 @@ class Migration(migrations.Migration):
),
],
),
migrations.CreateModel(
name="LotAnnotation",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created", models.DateTimeField(auto_now_add=True)),
(
"type",
models.SmallIntegerField(
choices=[(0, "System"), (1, "User"), (2, "Document")]
),
),
("key", models.CharField(max_length=256)),
("value", models.CharField(max_length=256)),
(
"lot",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="lot.lot"
),
),
(
"owner",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="user.institution",
),
),
(
"user",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to=settings.AUTH_USER_MODEL,
),
),
],
),
migrations.CreateModel(
name="LotTag",
fields=[
@ -79,6 +134,15 @@ class Migration(migrations.Migration):
"owner",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="user.institution",
),
),
(
"user",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to=settings.AUTH_USER_MODEL,
),
),

View File

@ -1,52 +0,0 @@
# Generated by Django 5.0.6 on 2024-07-29 15:37
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("lot", "0001_initial"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="LotAnnotation",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created", models.DateTimeField(auto_now_add=True)),
(
"type",
models.SmallIntegerField(
choices=[(0, "System"), (1, "User"), (2, "Document")]
),
),
("key", models.CharField(max_length=256)),
("value", models.CharField(max_length=256)),
(
"lot",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="lot.lot"
),
),
(
"owner",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
],
),
]

View File

@ -1,36 +0,0 @@
# Generated by Django 5.0.6 on 2024-09-18 10:55
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("lot", "0002_lotannotation"),
("user", "0001_initial"),
]
operations = [
migrations.AlterField(
model_name="lot",
name="owner",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="user.institution"
),
),
migrations.AlterField(
model_name="lotannotation",
name="owner",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="user.institution"
),
),
migrations.AlterField(
model_name="lottag",
name="owner",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="user.institution"
),
),
]

View File

@ -6,7 +6,7 @@ from utils.constants import (
STR_EXTEND_SIZE,
)
from user.models import Institution
from user.models import User, Institution
# from device.models import Device
# from evidence.models import Annotation
@ -14,6 +14,7 @@ from user.models import Institution
class LotTag(models.Model):
name = models.CharField(max_length=STR_SIZE, blank=False, null=False)
owner = models.ForeignKey(Institution, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
def __str__(self):
return self.name
@ -32,6 +33,7 @@ class Lot(models.Model):
description = models.CharField(max_length=STR_SIZE, blank=True, null=True)
closed = models.BooleanField(default=True)
owner = models.ForeignKey(Institution, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
type = models.ForeignKey(LotTag, on_delete=models.CASCADE)
def add(self, v):
@ -53,6 +55,7 @@ class LotAnnotation(models.Model):
created = models.DateTimeField(auto_now_add=True)
lot = models.ForeignKey(Lot, on_delete=models.CASCADE)
owner = models.ForeignKey(Institution, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
type = models.SmallIntegerField(choices=Type)
key = models.CharField(max_length=STR_EXTEND_SIZE)
value = models.CharField(max_length=STR_EXTEND_SIZE)

View File

@ -1,6 +1,7 @@
from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model
from user.models import Institution
from lot.models import LotTag
User = get_user_model()
@ -21,7 +22,6 @@ class Command(BaseCommand):
is_admin = kwargs['is_admin']
institution = Institution.objects.get(name=kwargs['institution'])
self.create_user(institution, email, password, is_admin)
self.create_lot_tags()
def create_user(self, institution, email, password, is_admin):
self.u = User.objects.create(
@ -30,5 +30,5 @@ class Command(BaseCommand):
password=password,
is_admin=is_admin,
)
self.u.set_password(self.password)
self.u.set_password(password)
self.u.save()