Skip to content

Commit

Permalink
Fixed Issue of Facility Update in facility_models.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ertush committed Jul 12, 2024
1 parent 61f8e48 commit a4c99fd
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions facilities/models/facility_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,20 +306,22 @@ def push_facility_updates_to_dhis2(self, org_unit_id, facility_updates_payload):


if r.json()["status"] != "OK":
r = requests.post(
settings.DHIS_ENDPOINT + "api/organisationUnits/",
auth=(settings.DHIS_USERNAME, settings.DHIS_PASSWORD),
headers={
"Accept": "application/json"
},
json=facility_updates_payload
)
# r = requests.post(
# settings.DHIS_ENDPOINT + "api/organisationUnits/",
# auth=(settings.DHIS_USERNAME, settings.DHIS_PASSWORD),
# headers={
# "Accept": "application/json"
# },
# json=facility_updates_payload
# )

# raise ValidationError(
# {
# "Error!": ["Unable to push facility updates to DHIS2"]
# }
# )
raise ValidationError(
{
"Error!": ["Unable to push facility updates to KHIS. Created a new facility {}".format(r.text())]
}
)
else:
return r.json()


def format_coordinates(self, str_coordinates):
Expand Down Expand Up @@ -2291,6 +2293,7 @@ def push_facility_updates(self):

LOGGER.error('[>>>>>Info] coordinates: {}, FacilityCoordinatesObj: {}'.format(coordinates, FacilityCoordinates.objects.values('coordinates')
.get(facility_id=self.facility.id)['coordinates']))

new_facility_updates_payload = {
"code": str(self.facility.code),
"name": str(self.facility.name),
Expand Down

0 comments on commit a4c99fd

Please sign in to comment.