diff --git a/care/facility/migrations/0395_assetlocationdutystaff_assetlocation_users.py b/care/facility/migrations/0395_assetlocationdutystaff_assetlocation_users.py index 5ee979ca3c..f0e6510152 100644 --- a/care/facility/migrations/0395_assetlocationdutystaff_assetlocation_users.py +++ b/care/facility/migrations/0395_assetlocationdutystaff_assetlocation_users.py @@ -1,4 +1,6 @@ -# Generated by Django 4.2.5 on 2023-11-17 06:36 +# Generated by Django 4.2.5 on 2023-11-17 13:25 + +import uuid import django.db.models.deletion from django.conf import settings @@ -24,7 +26,19 @@ class Migration(migrations.Migration): verbose_name="ID", ), ), - ("deleted", models.BooleanField(default=False)), + ( + "external_id", + models.UUIDField(db_index=True, default=uuid.uuid4, unique=True), + ), + ( + "created_date", + models.DateTimeField(auto_now_add=True, db_index=True, null=True), + ), + ( + "modified_date", + models.DateTimeField(auto_now=True, db_index=True, null=True), + ), + ("deleted", models.BooleanField(db_index=True, default=False)), ( "asset_location", models.ForeignKey( @@ -48,6 +62,9 @@ class Migration(migrations.Migration): ), ), ], + options={ + "abstract": False, + }, ), migrations.AddField( model_name="assetlocation", diff --git a/care/facility/models/asset.py b/care/facility/models/asset.py index b7c193aefa..a785bd6259 100644 --- a/care/facility/models/asset.py +++ b/care/facility/models/asset.py @@ -59,14 +59,12 @@ class RoomType(enum.Enum): ) -class AssetLocationDutyStaff(models.Model): +class AssetLocationDutyStaff(BaseModel): asset_location = models.ForeignKey( AssetLocation, on_delete=models.CASCADE, null=False, blank=False ) user = models.ForeignKey(User, on_delete=models.CASCADE, null=False, blank=False) - deleted = models.BooleanField(default=False) - created_by = models.ForeignKey( User, on_delete=models.PROTECT, @@ -113,7 +111,11 @@ class Asset(BaseModel): choices=AssetTypeChoices, default=AssetType.INTERNAL.value ) asset_class = models.CharField( - choices=AssetClassChoices, default=None, null=True, blank=True, max_length=20 + choices=AssetClassChoices, + default=None, + null=True, + blank=True, + max_length=20, ) status = models.IntegerField(choices=StatusChoices, default=Status.ACTIVE.value) current_location = models.ForeignKey( @@ -124,7 +126,9 @@ class Asset(BaseModel): serial_number = models.CharField(max_length=1024, blank=True, null=True) warranty_details = models.TextField(null=True, blank=True, default="") # Deprecated meta = JSONField( - default=dict, blank=True, validators=[JSONFieldSchemaValidator(ASSET_META)] + default=dict, + blank=True, + validators=[JSONFieldSchemaValidator(ASSET_META)], ) # Vendor Details vendor_name = models.CharField(max_length=1024, blank=True, null=True) diff --git a/care/facility/tests/test_asset_location_api.py b/care/facility/tests/test_asset_location_api.py index 56ea5729f6..500f0f7405 100644 --- a/care/facility/tests/test_asset_location_api.py +++ b/care/facility/tests/test_asset_location_api.py @@ -29,7 +29,8 @@ def test_retrieve_asset_location(self): self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data["id"], str(self.asset_location.external_id)) self.assertEqual( - response.data["middleware_address"], self.asset_location.middleware_address + response.data["middleware_address"], + self.asset_location.middleware_address, ) def test_create_asset_location(self): @@ -44,7 +45,8 @@ def test_create_asset_location(self): self.assertEqual(response.status_code, status.HTTP_201_CREATED) self.assertEqual(response.data["name"], sample_data["name"]) self.assertEqual( - response.data["middleware_address"], sample_data["middleware_address"] + response.data["middleware_address"], + sample_data["middleware_address"], ) def test_update_asset_location(self): @@ -59,7 +61,8 @@ def test_update_asset_location(self): self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(response.data["name"], sample_data["name"]) self.assertEqual( - response.data["middleware_address"], sample_data["middleware_address"] + response.data["middleware_address"], + sample_data["middleware_address"], ) def test_create_asset_location_invalid_middleware(self): @@ -101,5 +104,4 @@ def test_assign_duty_staff(self): data, ) - self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(len(response.json()["duty_staff_objects"]), 2) + self.assertEqual(response.status_code, status.HTTP_201_CREATED)