From 472d61bdc251ca2e7d89691943b5e592d0ea17b6 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Mon, 7 Oct 2024 16:56:58 +0200 Subject: [PATCH] fix bugs --- dashboard/views.py | 2 +- evidence/migrations/0001_initial.py | 6 ++++-- evidence/models.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dashboard/views.py b/dashboard/views.py index 6153675..7a9a397 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -13,7 +13,7 @@ class UnassignedDevicesView(InventaryMixin): breadcrumb = "Devices / Unassigned Devices" def get_devices(self, user, offset, limit): - return Device.get_unassigned(self.request.user, offset, limit) + return Device.get_unassigned(self.request.user.institution, offset, limit) class LotDashboardView(InventaryMixin, DetailsMixin): diff --git a/evidence/migrations/0001_initial.py b/evidence/migrations/0001_initial.py index e4e0f10..1a621d0 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-04 13:16 +# Generated by Django 5.0.6 on 2024-10-07 11:38 import django.db.models.deletion from django.conf import settings @@ -47,7 +47,9 @@ class Migration(migrations.Migration): ( "user", models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, ), ), diff --git a/evidence/models.py b/evidence/models.py index a30e935..0e077a5 100644 --- a/evidence/models.py +++ b/evidence/models.py @@ -16,7 +16,7 @@ class Annotation(models.Model): created = models.DateTimeField(auto_now_add=True) uuid = models.UUIDField() owner = models.ForeignKey(Institution, on_delete=models.CASCADE) - user = models.ForeignKey(User, 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)