Skip to content

Commit

Permalink
Update views.py
Browse files Browse the repository at this point in the history
  • Loading branch information
idabblewith committed Feb 15, 2025
1 parent 6bb4199 commit c822a45
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions agencies/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@

# region Affiliation Views ====================================================================================================


class Affiliations(APIView):
permission_classes = [IsAuthenticated]

Expand Down Expand Up @@ -234,13 +235,12 @@ def post(self, req):
)




# endregion =================================================================================================


# region Agency Views ====================================================================================================


class Agencies(APIView):
permission_classes = [IsAuthenticated]

Expand Down Expand Up @@ -273,6 +273,7 @@ def post(self, req):
status=HTTP_400_BAD_REQUEST,
)


class AgencyDetail(APIView):
permission_classes = [IsAuthenticated]

Expand Down Expand Up @@ -320,6 +321,7 @@ def put(self, req, pk):
status=HTTP_400_BAD_REQUEST,
)


# endregion =================================================================================================


Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}

Expand Down Expand Up @@ -904,6 +912,7 @@ def post(self, req, pk):

# region Division Views ====================================================================================================


class Divisions(APIView):
def get(self, req):
all = Division.objects.all()
Expand Down

0 comments on commit c822a45

Please sign in to comment.