From a6d077aa2d27bc9808835fc84b5a466d2facc942 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 10 Oct 2024 12:28:03 +0200 Subject: [PATCH] resolve conflicts --- dashboard/templates/base.html | 10 +++ evidence/migrations/0001_initial.py | 2 +- .../migrations/0004_alter_annotation_owner.py | 22 ------- lot/migrations/0001_initial.py | 66 ++++++++++++++++++- lot/migrations/0002_lotannotation.py | 52 --------------- ...wner_alter_lotannotation_owner_and_more.py | 36 ---------- lot/models.py | 5 +- user/management/commands/add_user.py | 4 +- 8 files changed, 82 insertions(+), 115 deletions(-) delete mode 100644 evidence/migrations/0004_alter_annotation_owner.py delete mode 100644 lot/migrations/0002_lotannotation.py delete mode 100644 lot/migrations/0003_alter_lot_owner_alter_lotannotation_owner_and_more.py diff --git a/dashboard/templates/base.html b/dashboard/templates/base.html index 5c92024..d2c1612 100644 --- a/dashboard/templates/base.html +++ b/dashboard/templates/base.html @@ -185,7 +185,17 @@ {% endblock messages %}

{{ title }}

+
+ {% csrf_token %} +
+ + + + +
+
+
{{ breadcrumb }} diff --git a/evidence/migrations/0001_initial.py b/evidence/migrations/0001_initial.py index 1a621d0..9ffbf31 100644 --- a/evidence/migrations/0001_initial.py +++ b/evidence/migrations/0001_initial.py @@ -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 diff --git a/evidence/migrations/0004_alter_annotation_owner.py b/evidence/migrations/0004_alter_annotation_owner.py deleted file mode 100644 index 26c9bda..0000000 --- a/evidence/migrations/0004_alter_annotation_owner.py +++ /dev/null @@ -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" - ), - ), - ] diff --git a/lot/migrations/0001_initial.py b/lot/migrations/0001_initial.py index 28b3e8e..538ba90 100644 --- a/lot/migrations/0001_initial.py +++ b/lot/migrations/0001_initial.py @@ -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, ), ), diff --git a/lot/migrations/0002_lotannotation.py b/lot/migrations/0002_lotannotation.py deleted file mode 100644 index aca7de1..0000000 --- a/lot/migrations/0002_lotannotation.py +++ /dev/null @@ -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, - ), - ), - ], - ), - ] diff --git a/lot/migrations/0003_alter_lot_owner_alter_lotannotation_owner_and_more.py b/lot/migrations/0003_alter_lot_owner_alter_lotannotation_owner_and_more.py deleted file mode 100644 index 806c6f1..0000000 --- a/lot/migrations/0003_alter_lot_owner_alter_lotannotation_owner_and_more.py +++ /dev/null @@ -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" - ), - ), - ] diff --git a/lot/models.py b/lot/models.py index 3926f29..764e134 100644 --- a/lot/models.py +++ b/lot/models.py @@ -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) diff --git a/user/management/commands/add_user.py b/user/management/commands/add_user.py index d6d3bd8..73385d8 100644 --- a/user/management/commands/add_user.py +++ b/user/management/commands/add_user.py @@ -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()