Skip to content

Commit

Permalink
Update cache after project is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankApiyo committed Nov 9, 2023
1 parent 89398b9 commit 9f14982
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions onadata/apps/api/tests/viewsets/test_project_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2549,6 +2549,7 @@ def test_projects_soft_delete(self):
request.user = self.user
response = view(request, pk=project_id)
self.assertEqual(response.status_code, 204)
self.assertIsNone(cache.get(f"{PROJ_OWNER_CACHE}{project_id}"))

self.project = Project.objects.get(pk=project_id)

Expand Down
1 change: 1 addition & 0 deletions onadata/apps/api/viewsets/project_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def destroy(self, request, *args, **kwargs):
"""Soft deletes a project"""
project = self.get_object()
user = request.user
cache.delete(f"{PROJ_OWNER_CACHE}{project.id}")
project.soft_delete(user)

return Response(status=status.HTTP_204_NO_CONTENT)

0 comments on commit 9f14982

Please sign in to comment.