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

chore: organize apps #578

Merged
merged 2 commits into from
Mar 27, 2024
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
3 changes: 2 additions & 1 deletion bd_api/apps/account/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@


class AccountConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "bd_api.apps.account"
verbose_name = "Contas"
default_auto_field = "django.db.models.BigAutoField"

def ready(self):
import bd_api.apps.account.signals # noqa
3 changes: 2 additions & 1 deletion bd_api/apps/account_auth/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@


class AuthConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "bd_api.apps.account_auth"
verbose_name = "Autenticação e Autorização Interna"
default_auto_field = "django.db.models.BigAutoField"
6 changes: 3 additions & 3 deletions bd_api/apps/account_auth/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from . import views

urlpatterns = [
path("", views.auth, name="auth"),
path("login/", views.signin, name="login"),
path("logout/", views.signout, name="logout"),
path("auth/", views.auth, name="auth"),
path("auth/login/", views.signin, name="login"),
path("auth/logout/", views.signout, name="logout"),
]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


class PaymentConfig(DjstripeAppConfig):
verbose_name = "Stripe"
verbose_name = "Pagamentos"

def ready(self):
super().ready()
import bd_api.apps.payment.signals # noqa
import bd_api.apps.payment.webhooks # noqa
import bd_api.apps.account_payment.signals # noqa
import bd_api.apps.account_payment.webhooks # noqa
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from stripe import Customer as StripeCustomer

from bd_api.apps.account.models import Account, Subscription
from bd_api.apps.payment.webhooks import add_user, remove_user
from bd_api.apps.account_payment.webhooks import add_user, remove_user
from bd_api.custom.graphql_base import CountableConnection, PlainTextNode

if settings.STRIPE_LIVE_MODE:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions bd_api/apps/account_payment/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from django.urls import include, path

urlpatterns = [path("payment/", include("djstripe.urls", namespace="payment"))]
File renamed without changes.
3 changes: 1 addition & 2 deletions bd_api/apps/api/v1/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class ApiConfig(AppConfig):
app_label = "v1"
verbose_name = " V1"
name = "bd_api.apps.api.v1"
verbose_name = " API"
default_auto_field = "django.db.models.BigAutoField"
24 changes: 14 additions & 10 deletions bd_api/apps/api/v1/urls.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
# -*- coding: utf-8 -*-
from django.http import HttpResponseRedirect
from django.urls import path
from django.urls import include, path
from django.views.decorators.csrf import csrf_exempt
from graphene_file_upload.django import FileUploadGraphQLView

from bd_api.apps.api.v1.search_views import DatasetSearchView
from bd_api.apps.api.v1.views import DatasetRedirectView


def redirect_to_v1(request):
return HttpResponseRedirect("/api/v1/")
return HttpResponseRedirect("/api/v1/graphql")


def redirect_to_v1_graphql(request):
return HttpResponseRedirect("/api/v1/graphql")
def graphql_view():
return csrf_exempt(FileUploadGraphQLView.as_view(graphiql=True))


urlpatterns = [
path("", redirect_to_v1),
path("v1/", redirect_to_v1_graphql),
path(
"v1/graphql",
csrf_exempt(FileUploadGraphQLView.as_view(graphiql=True)),
),
path("api/", redirect_to_v1),
path("api/v1/", redirect_to_v1),
path("api/v1/graphql", graphql_view()),
path("search/", DatasetSearchView.as_view()),
path("search/debug/", include("haystack.urls")),
path("dataset/", DatasetRedirectView.as_view()),
path("dataset_redirect/", DatasetRedirectView.as_view()),
]
4 changes: 0 additions & 4 deletions bd_api/apps/payment/urls.py

This file was deleted.

4 changes: 2 additions & 2 deletions bd_api/apps/schema.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
from bd_api.apps.account.graphql import AccountMutation
from bd_api.apps.api.v1.graphql import APIQuery
from bd_api.apps.payment.graphql import (
from bd_api.apps.account_payment.graphql import (
StripeCustomerMutation,
StripePriceQuery,
StripeSubscriptionCustomerMutation,
StripeSubscriptionMutation,
)
from bd_api.apps.api.v1.graphql import APIQuery
from bd_api.custom.graphql_auto import build_schema

schema = build_schema(
Expand Down
5 changes: 3 additions & 2 deletions bd_api/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
#
"health_check",
"health_check.db",
#
Expand All @@ -56,10 +57,10 @@
"huey.contrib.djhuey",
#
"bd_api.apps.account",
"bd_api.apps.api.v1",
"bd_api.apps.account_auth",
"bd_api.apps.account_payment.apps.PaymentConfig",
"bd_api.apps.api.v1",
"bd_api.apps.core",
"bd_api.apps.payment.apps.PaymentConfig",
]

MIDDLEWARE = [
Expand Down
25 changes: 4 additions & 21 deletions bd_api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,13 @@
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
from django.views.decorators.csrf import csrf_exempt
from graphene_file_upload.django import FileUploadGraphQLView

from bd_api.apps.api.v1.search_views import DatasetSearchView as DatasetSearchV2View
from bd_api.apps.api.v1.views import DatasetRedirectView
from bd_api.apps.api.v1.views import DatasetSearchView as DatasetSearchV1View


def graphql_view():
return csrf_exempt(FileUploadGraphQLView.as_view(graphiql=True))


urlpatterns = [
path("admin/", admin.site.urls),
path("", include("bd_api.apps.core.urls")),
path("api/", include("bd_api.apps.api.v1.urls")),
path("api/graphql/", graphql_view()),
path("account/", include("bd_api.apps.account.urls")),
path("auth/", include("bd_api.apps.account_auth.urls")),
path("search/", DatasetSearchV1View.as_view()),
path("search/v2/", DatasetSearchV2View.as_view()),
path("search/debug/", include("haystack.urls")),
path("dataset/", DatasetRedirectView.as_view()),
path("dataset_redirect/", DatasetRedirectView.as_view()),
path("payment/", include("bd_api.apps.payment.urls")),
path("", include("bd_api.apps.api.v1.urls")),
path("", include("bd_api.apps.account.urls")),
path("", include("bd_api.apps.account_auth.urls")),
path("", include("bd_api.apps.account_payment.urls")),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Loading