Skip to content

Commit 87a0db5

Browse files
shreeyash07sudip-khanal
authored andcommitted
fix(local-units): remove other profiles field from and add mixin
1 parent fbbb460 commit 87a0db5

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

local_units/serializers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ class Meta:
107107
fields = "__all__"
108108

109109

110-
class OtherProfileSerializer(serializers.ModelSerializer):
110+
class OtherProfileSerializer(NestedCreateMixin, NestedUpdateMixin, serializers.ModelSerializer):
111+
id = serializers.IntegerField(required=False)
112+
111113
class Meta:
112114
model = OtherProfile
113115
fields = "__all__"
@@ -154,10 +156,9 @@ class HealthDataSerializer(
154156
professional_training_facilities_details = ProfessionalTrainingFacilitySerializer(
155157
source="professional_training_facilities", many=True, read_only=True
156158
)
157-
other_profiles_details = OtherProfileSerializer(
158-
source="other_profiles",
159+
other_profiles = OtherProfileSerializer(
159160
many=True,
160-
read_only=True,
161+
required=False,
161162
)
162163
modified_by_details = LocalUnitMiniUserSerializer(source="modified_by", read_only=True)
163164
created_by_details = LocalUnitMiniUserSerializer(source="created_by", read_only=True)
@@ -553,7 +554,6 @@ class LocalUnitOptionsSerializer(serializers.Serializer):
553554
professional_training_facilities = ProfessionalTrainingFacilitySerializer(many=True)
554555
general_medical_services = GeneralMedicalServiceSerializer(many=True)
555556
specialized_medical_beyond_primary_level = SpecializedMedicalServiceSerializer(many=True)
556-
other_profiles = OtherProfileSerializer(many=True)
557557

558558

559559
class MiniDelegationOfficeSerializer(serializers.ModelSerializer):

local_units/test_views.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
LocalUnitChangeRequest,
3535
LocalUnitLevel,
3636
LocalUnitType,
37-
OtherProfile,
3837
PrimaryHCC,
3938
ProfessionalTrainingFacility,
4039
SpecializedMedicalService,
@@ -525,7 +524,6 @@ def test_create_update_local_unit_health(self):
525524
functionality = Functionality.objects.create(code=1, name="Code 1")
526525
health_facility_type = FacilityType.objects.create(code=1, name="Code 1")
527526
primary_health_care_center = PrimaryHCC.objects.create(code=1, name="Code 1")
528-
other_profiles = OtherProfile.objects.create(number=1, position="test")
529527
data = {
530528
"local_branch_name": "Silele Red Cross Clinic, Sigombeni Red Cross Clinic & Mahwalala Red Cross Clinic",
531529
"english_branch_name": None,
@@ -578,7 +576,10 @@ def test_create_update_local_unit_health(self):
578576
"nursing_aid": 0,
579577
"midwife": 9,
580578
"other_medical_heal": True,
581-
"other_profiles": [other_profiles.id],
579+
"other_profiles": [
580+
{"number": 2, "position": "Nurse"},
581+
{"number": 3, "position": "Doctor"},
582+
],
582583
"feedback": "first question of initial question did not provide for the option to write the name of the NS. It is written LRC yet it should allow Baphalali Eswatini Red Cross Society (BERCS) to be inscribed in the box.", # noqa: E501
583584
"affiliation": affiliation.id,
584585
"functionality": functionality.id,

0 commit comments

Comments
 (0)