Skip to content

Commit

Permalink
fix(asset_location): switched to BaseModel
Browse files Browse the repository at this point in the history
  • Loading branch information
aeswibon committed Nov 17, 2023
1 parent 41b553e commit 7bddcd3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(
Expand All @@ -48,6 +62,9 @@ class Migration(migrations.Migration):
),
),
],
options={
"abstract": False,
},
),
migrations.AddField(
model_name="assetlocation",
Expand Down
14 changes: 9 additions & 5 deletions care/facility/models/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand Down

0 comments on commit 7bddcd3

Please sign in to comment.