Skip to content

Commit

Permalink
fix(asset): fixed linting
Browse files Browse the repository at this point in the history
  • Loading branch information
aeswibon committed Oct 23, 2023
1 parent 67c76af commit 55fe1e8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
15 changes: 12 additions & 3 deletions care/facility/api/serializers/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@
StatusChoices,
UserDefaultAssetLocation,
)
from care.utils.assetintegration.hl7monitor import HL7MonitorAsset
from care.utils.assetintegration.onvif import OnvifAsset
from care.utils.assetintegration.ventilator import VentilatorAsset
from care.users.api.serializers.user import (
UserAssignedSerializer,
UserBaseMinimumSerializer,
)
from care.utils.assetintegration.hl7monitor import HL7MonitorAsset
from care.utils.assetintegration.onvif import OnvifAsset
from care.utils.assetintegration.ventilator import VentilatorAsset
from care.utils.queryset.facility import get_facility_queryset
from config.serializers import ChoiceField
from config.validators import MiddlewareDomainAddressValidator


class AssetLocationSerializer(ModelSerializer):
facility = FacilityBareMinimumSerializer(read_only=True)
id = UUIDField(source="external_id", read_only=True)
Expand Down Expand Up @@ -73,6 +74,14 @@ def validate(self, data):
}
)

if "duty_staff" in data:
duty_staffs_objects = len(data["duty_staff"])
print("duty: ", duty_staffs_objects)
if duty_staffs_objects > 3:
raise ValidationError(
{"duty_staff": "Only 3 duty staffs can be assigned"}
)

return data

class Meta:
Expand Down
4 changes: 2 additions & 2 deletions care/facility/api/viewsets/facility_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ def get_queryset(self):
queryset=UserSkill.objects.filter(skill__deleted=False),
),
)
except Exception as e:
raise ValidationError({"Facility": "Facility not found"}) from e
except Facility.DoesNotExist:
raise ValidationError({"Facility": "Facility not found"})
12 changes: 12 additions & 0 deletions care/facility/migrations/0393_merge_20231020_1752.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Generated by Django 4.2.5 on 2023-10-20 12:22

from django.db import migrations


class Migration(migrations.Migration):
dependencies = [
("facility", "0389_add_duty_staff"),
("facility", "0392_alter_dailyround_consciousness_level"),
]

operations = []

0 comments on commit 55fe1e8

Please sign in to comment.