Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 상징 삭제 시 db에서 weight row 따라서 삭제해주도록 수정 #122

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions backend/weight_table/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ def post(self, request):
serializer.is_valid(raise_exception=True)
serializer.save()

# Delete weight rows if user deleted corresponding symbols
weight_symbols = WeightTable.objects.filter(user=user).values('symbol_id')
weight_to_delete = [item['symbol_id'] for item in weight_symbols]

try:
for item in serializer.validated_data:
weight_to_delete.remove(item.get('symbol_id'))
except ValueError:
pass

for id in weight_to_delete:
WeightTable.objects.get(symbol_id=id, user=user).delete()

return Response(status=status.HTTP_200_OK)

def get(self, request):
Expand Down