Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds fields to Asset model as per asset registration v2 #984

Merged
merged 1 commit into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions care/facility/migrations/0309_auto_20220820_1541.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 2.2.11 on 2022-08-20 10:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('facility', '0308_auto_20220805_2247'),
]

operations = [
migrations.AddField(
model_name='asset',
name='last_serviced_on',
field=models.DateField(blank=True, default=None, null=True),
),
migrations.AddField(
model_name='asset',
name='manufacturer',
field=models.CharField(blank=True, max_length=1024, null=True),
),
migrations.AddField(
model_name='asset',
name='notes',
field=models.TextField(blank=True, default='', null=True),
),
migrations.AddField(
model_name='asset',
name='warranty_amc_end_of_validity',
field=models.DateField(blank=True, default=None, null=True),
),
]
43 changes: 15 additions & 28 deletions care/facility/models/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ class RoomType(enum.Enum):

name = models.CharField(max_length=1024, blank=False, null=False)
description = models.TextField(default="", null=True, blank=True)
location_type = models.IntegerField(
choices=RoomTypeChoices, default=RoomType.OTHER.value
)
facility = models.ForeignKey(
Facility, on_delete=models.PROTECT, null=False, blank=False
)
location_type = models.IntegerField(choices=RoomTypeChoices, default=RoomType.OTHER.value)
facility = models.ForeignKey(Facility, on_delete=models.PROTECT, null=False, blank=False)


class Asset(BaseModel):
Expand All @@ -57,27 +53,25 @@ class Status(enum.Enum):

name = models.CharField(max_length=1024, blank=False, null=False)
description = models.TextField(default="", null=True, blank=True)
asset_type = models.IntegerField(
choices=AssetTypeChoices, default=AssetType.INTERNAL.value
)
asset_class = models.CharField(
choices=AssetClassChoices, default=None, null=True, blank=True, max_length=20
)
asset_type = models.IntegerField(choices=AssetTypeChoices, default=AssetType.INTERNAL.value)
asset_class = models.CharField(choices=AssetClassChoices, default=None, null=True, blank=True, max_length=20)
status = models.IntegerField(choices=StatusChoices, default=Status.ACTIVE.value)
current_location = models.ForeignKey(AssetLocation, on_delete=models.PROTECT, null=False, blank=False)
is_working = models.BooleanField(default=None, null=True, blank=True)
is_working = models.BooleanField(default=None, null=True, blank=True)
not_working_reason = models.CharField(max_length=1024, blank=True, null=True)
serial_number = models.CharField(max_length=1024, blank=True, null=True)
warranty_details = models.TextField(null=True, blank=True, default="")
meta = JSONField(default=dict, blank=True, validators=[JSONFieldSchemaValidator(ASSET_META)])
# Vendor Details
vendor_name = models.CharField(max_length=1024, blank=True, null=True)
support_name = models.CharField(max_length=1024, blank=True, null=True)
support_phone = models.CharField(
max_length=14, validators=[phone_number_regex], default=""
)
support_phone = models.CharField(max_length=14, validators=[phone_number_regex], default="")
support_email = models.EmailField(blank=True, null=True)
qr_code_id = models.CharField(max_length=1024, blank=True, default=None, null=True)
manufacturer = models.CharField(max_length=1024, blank=True, null=True)
warranty_amc_end_of_validity = models.DateField(default=None, null=True, blank=True)
last_serviced_on = models.DateField(default=None, null=True, blank=True)
notes = models.TextField(default="", null=True, blank=True)

class Meta:
constraints = [
Expand All @@ -91,20 +85,15 @@ class Meta:
def __str__(self):
return self.name


class UserDefaultAssetLocation(BaseModel):
user = models.ForeignKey(User, on_delete=models.PROTECT, null=False, blank=False)
location = models.ForeignKey(
AssetLocation, on_delete=models.PROTECT, null=False, blank=False
)
location = models.ForeignKey(AssetLocation, on_delete=models.PROTECT, null=False, blank=False)


class FacilityDefaultAssetLocation(BaseModel):
facility = models.ForeignKey(
Facility, on_delete=models.PROTECT, null=False, blank=False
)
location = models.ForeignKey(
AssetLocation, on_delete=models.PROTECT, null=False, blank=False
)
facility = models.ForeignKey(Facility, on_delete=models.PROTECT, null=False, blank=False)
location = models.ForeignKey(AssetLocation, on_delete=models.PROTECT, null=False, blank=False)


class AssetTransaction(BaseModel):
Expand All @@ -123,6 +112,4 @@ class AssetTransaction(BaseModel):
null=False,
blank=False,
)
performed_by = models.ForeignKey(
User, on_delete=models.PROTECT, null=False, blank=False
)
performed_by = models.ForeignKey(User, on_delete=models.PROTECT, null=False, blank=False)