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

Refactor: Enhance maintainability by improving code base structure #4

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions accounts/api/routers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.urls import path

from accounts.api.views import (
UserListView,
CurrentUserView,
UserDetailView,
)


urlpatterns = [
# Users endpoints
path("users", UserListView.as_view(), name="user-list"),
path("users/current", CurrentUserView.as_view(), name="current-user"),
path("users/<int:pk>", UserDetailView.as_view(), name="user-detail"),
]
File renamed without changes.
2 changes: 1 addition & 1 deletion accounts/views.py → accounts/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)

from accounts.models import User
from accounts.serializers import UserSerializer
from accounts.api.serializers import UserSerializer


class UserViewMixin:
Expand Down
11 changes: 0 additions & 11 deletions accounts/routers.py

This file was deleted.

2 changes: 1 addition & 1 deletion accounts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rest_framework.test import APIClient

from accounts.models import User
from accounts.serializers import UserSerializer
from accounts.api.serializers import UserSerializer

from accounts.utils import create_test_user

Expand Down
15 changes: 10 additions & 5 deletions assets/routers.py → assets/api/routers.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
from django.urls import path

from assets import views
from assets.api.views import (
CurrencyListView,
CurrencyDetailView,
CurrencyPairListView,
CurrencyPairDetailView,
)


urlpatterns = [
path(
"currencies",
views.CurrencyListView.as_view(),
CurrencyListView.as_view(),
name="currency-list",
),
path(
"currencies/<int:pk>",
views.CurrencyDetailView.as_view(),
CurrencyDetailView.as_view(),
name="currency-detail",
),
path(
"assets/",
views.CurrencyPairListView.as_view(),
CurrencyPairListView.as_view(),
name="pair-list",
),
path(
"assets/<int:pk>",
views.CurrencyPairDetailView.as_view(),
CurrencyPairDetailView.as_view(),
name="pair-detail",
),
]
File renamed without changes.
2 changes: 1 addition & 1 deletion assets/views.py → assets/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)

from assets.models import Currency, CurrencyPair
from assets.serializers import (
from assets.api.serializers import (
CurrencySerializer,
CurrencyPairSerializer,
)
Expand Down
2 changes: 1 addition & 1 deletion assets/tests/test_currency_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rest_framework.test import APIClient

from assets.models import Currency
from assets.serializers import CurrencySerializer
from assets.api.serializers import CurrencySerializer

from accounts.utils import create_test_admin, create_test_user
from assets.helpers.test_utils import (
Expand Down
2 changes: 1 addition & 1 deletion assets/tests/test_currency_pair_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rest_framework.test import APIClient

from assets.models import CurrencyPair
from assets.serializers import CurrencyPairSerializer
from assets.api.serializers import CurrencyPairSerializer

from accounts.utils import create_test_admin, create_test_user
from assets.helpers.test_utils import (
Expand Down
1 change: 1 addition & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"tokens.apps.TokensConfig",
"assets.apps.AssetsConfig",
"trades.apps.TradesConfig",
"metrics.apps.MetricsConfig",
]

MIDDLEWARE = [
Expand Down
7 changes: 4 additions & 3 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

urlpatterns = [
path("admin/", admin.site.urls),
path("api/", include("accounts.routers")),
path("api/", include("tokens.routers")),
path("api/", include("assets.routers")),
path("api/", include("trades.routers")),
path("api/", include("accounts.api.routers")),
path("api/", include("assets.api.routers")),
path("api/", include("trades.api.routers")),
path("api/", include("metrics.api.routers.trades")),
]
Empty file added metrics/__init__.py
Empty file.
Empty file added metrics/api/routers/__init__.py
Empty file.
14 changes: 1 addition & 13 deletions trades/routers.py → metrics/api/routers/trades.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from django.urls import path

from trades.views import (
TradeListView,
TradeDetailView,
from metrics.api.views.trades import (
MetricsSummaryView,
ProfitAndLossView,
TotalTradesView,
Expand All @@ -12,16 +10,6 @@


urlpatterns = [
path(
"trades",
TradeListView.as_view(),
name="trade-list",
),
path(
"trades/<int:pk>",
TradeDetailView.as_view(),
name="trade-detail",
),
path(
"trades/metrics",
MetricsSummaryView.as_view(),
Expand Down
Empty file.
Loading