Skip to content

Commit

Permalink
Merge pull request #333 from napse-invest/dev
Browse files Browse the repository at this point in the history
fix(api): exchange account creation
  • Loading branch information
tomjeannesson authored Mar 12, 2024
2 parents 78fa87c + 50d120e commit 373e287
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions django_napse/api/exchanges/views/exchange_account_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django_napse.api.exchanges.serializers.exchange_account_detail_serializer import ExchangeAccountDetailSerializer
from django_napse.api.exchanges.serializers.exchange_account_serializer import ExchangeAccountSerializer
from django_napse.core.models import Exchange, ExchangeAccount
from django_napse.core.models.accounts.exchange import EXCHANGE_ACCOUNT_DICT
from django_napse.utils.constants import EXCHANGES

if TYPE_CHECKING:
Expand Down Expand Up @@ -61,14 +62,13 @@ def create(self, request: Request) -> None:
return Response({"error": "Missing exchange"}, status=status.HTTP_400_BAD_REQUEST)
if "testing" not in request.data:
return Response({"error": "Missing testing"}, status=status.HTTP_400_BAD_REQUEST)

print(request.data)
# TODO (Xénépix) : Rework the following part to use a serializer. # noqa
exchange = Exchange.objects.get(name=request.data["exchange"])
exchange_account = ExchangeAccount.objects.create(
data = request.data.copy()
exchange = Exchange.objects.get(name=data.pop("exchange"))
exchange_account = EXCHANGE_ACCOUNT_DICT[request.data["exchange"]].objects.create(
exchange=exchange,
name=request.data["name"],
testing=request.data["testing"],
description=request.data.get("description", ""),
**data,
)
serializer = self.get_serializer(exchange_account)
return Response(serializer.data, status=status.HTTP_201_CREATED)
Expand Down
2 changes: 1 addition & 1 deletion requirements/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ celery==5.3.6
redis==5.0.3

python-binance==1.0.19 # https://github.com/sammchardy/python-binance
pydantic==2.6.3 # https://github.com/pydantic/pydantic
pydantic==2.6.4 # https://github.com/pydantic/pydantic

0 comments on commit 373e287

Please sign in to comment.