diff --git a/agencies/views.py b/agencies/views.py index 7af1740..bfa04df 100644 --- a/agencies/views.py +++ b/agencies/views.py @@ -63,6 +63,7 @@ # region Affiliation Views ==================================================================================================== + class Affiliations(APIView): permission_classes = [IsAuthenticated] @@ -234,13 +235,12 @@ def post(self, req): ) - - # endregion ================================================================================================= # region Agency Views ==================================================================================================== + class Agencies(APIView): permission_classes = [IsAuthenticated] @@ -273,6 +273,7 @@ def post(self, req): status=HTTP_400_BAD_REQUEST, ) + class AgencyDetail(APIView): permission_classes = [IsAuthenticated] @@ -320,6 +321,7 @@ def put(self, req, pk): status=HTTP_400_BAD_REQUEST, ) + # endregion ================================================================================================= @@ -662,6 +664,12 @@ def put(self, req, pk): division_id = req.data.get("division") print("DIV ID: ", division_id) + + # Pre-process the leader field to set to none if 0 received + leader = req.data.get("leader") + if leader == "0" or leader == 0: + leader = None + ba_data = { key: value for key, value in { @@ -673,9 +681,9 @@ def put(self, req, pk): "introduction": req.data.get("introduction"), "data_custodian": req.data.get("data_custodian"), "finance_admin": req.data.get("finance_admin"), - "leader": req.data.get("leader"), + "leader": leader, }.items() - if value is not None + if value is not None or key == "leader" # and (not isinstance(value, list) or value) } @@ -904,6 +912,7 @@ def post(self, req, pk): # region Division Views ==================================================================================================== + class Divisions(APIView): def get(self, req): all = Division.objects.all()