🚚 Rename app main to bbs

🚚 Move settings into main
➕ Add django-rename-app
This commit is contained in:
nikolark committed 2022-02-20 00:39:16 +01:00
1 parent e1eaf3df98
commit 9b903f42d6
39 files changed
+82 -73

No files matched your search

View File
File renamed without changes.
+1 -1
View File
@@ -1,6 +1,6 @@
from django.contrib import admin from django.contrib import admin
from main.models import * from bbs.models import *
class ProductAdmin(admin.ModelAdmin): class ProductAdmin(admin.ModelAdmin):
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -5,10 +5,10 @@ from django.db import transaction
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from strawberry import ID from strawberry import ID
from main import models from bbs import models
from main.api.errors import Error, FieldError, FormErrors from bbs.api.errors import Error, FieldError, FormErrors
from main.api.types.inventory import Transaction from bbs.api.types.inventory import Transaction
from main.api.types.shop import Order from bbs.api.types.shop import Order
UserModel = get_user_model() UserModel = get_user_model()
@@ -4,8 +4,8 @@ from django.contrib.auth import get_user_model
from django.db import transaction from django.db import transaction
from strawberry_django import auto from strawberry_django import auto
from main import models from bbs import models
from main.api.types.users import User from bbs.api.types.users import User
DjangoUser = get_user_model() DjangoUser = get_user_model()
File renamed without changes.
@@ -1,7 +1,7 @@
import strawberry import strawberry
import strawberry_django import strawberry_django
from main.api.types.inventory import Transaction, TransactionOrdering from bbs.api.types.inventory import Transaction, TransactionOrdering
@strawberry.type @strawberry.type
@@ -1,8 +1,8 @@
import strawberry import strawberry
import strawberry_django import strawberry_django
from main import models from bbs import models
from main.api.types.shop import Order, OrderOrdering, OrderStats, OrderStatsByTime, Point, Product, ProductOrderStat from bbs.api.types.shop import Order, OrderOrdering, OrderStats, OrderStatsByTime, Point, Product, ProductOrderStat
@strawberry.type @strawberry.type
@@ -3,7 +3,7 @@ import strawberry_django
from django.contrib.auth.models import User as DjangoUser from django.contrib.auth.models import User as DjangoUser
from strawberry import ID from strawberry import ID
from main.api.types.users import User from bbs.api.types.users import User
@strawberry.type @strawberry.type
+20
View File
@@ -0,0 +1,20 @@
import strawberry
from bbs.api.mutations.shop import ShopMutations
from bbs.api.mutations.users import UsersMutations
from bbs.api.queries.inventory import InventoryQueries
from bbs.api.queries.shop import ShopQueries
from bbs.api.queries.users import UsersQueries
@strawberry.type
class Query(InventoryQueries, ShopQueries, UsersQueries):
pass
@strawberry.type
class Mutation(ShopMutations, UsersMutations):
pass
schema = strawberry.Schema(query=Query, mutation=Mutation)
File renamed without changes.
@@ -1,8 +1,8 @@
import strawberry_django import strawberry_django
from strawberry_django import auto from strawberry_django import auto
from main import models from bbs import models
from main.api.types.users import User from bbs.api.types.users import User
@strawberry_django.ordering.order(models.Transaction) @strawberry_django.ordering.order(models.Transaction)
@@ -2,8 +2,8 @@ import strawberry
import strawberry_django import strawberry_django
from strawberry_django import auto from strawberry_django import auto
from main import models from bbs import models
from main.api.types.utils import JSONScalar from bbs.api.types.utils import JSONScalar
@strawberry_django.filters.filter(models.Product) @strawberry_django.filters.filter(models.Product)
@@ -31,7 +31,7 @@ class OrderOrdering:
@strawberry_django.type(models.Order) @strawberry_django.type(models.Order)
class Order: class Order:
id: auto id: auto
customer: strawberry.LazyType["User", "main.api.types.users"] customer: strawberry.LazyType["User", "bbs.api.types.users"]
order_sum: auto order_sum: auto
created: auto created: auto
orderlines: list["OrderLine"] orderlines: list["OrderLine"]
@@ -5,8 +5,8 @@ import strawberry_django
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from strawberry_django import auto from strawberry_django import auto
from main import models from bbs import models
from main.api.types.shop import Point, ProductOrderStat from bbs.api.types.shop import Point, ProductOrderStat
UserModel = get_user_model() UserModel = get_user_model()
File renamed without changes.
+1 -1
View File
@@ -2,7 +2,7 @@ from django.apps import AppConfig
class BBSAppConfig(AppConfig): class BBSAppConfig(AppConfig):
name = "main" name = "bbs"
verbose_name = "Biceps Bar System" verbose_name = "Biceps Bar System"
def ready(self): def ready(self):
+1 -1
View File
@@ -1,6 +1,6 @@
from django import forms from django import forms
from main.models import InventoryTransaction, Product from bbs.models import InventoryTransaction, Product
class InventoryTransactionForm(forms.ModelForm): class InventoryTransactionForm(forms.ModelForm):
File renamed without changes.
File renamed without changes.
@@ -1,10 +1,10 @@
from pathlib import Path from pathlib import Path
from django.conf import settings
from django.core.management import BaseCommand, CommandParser from django.core.management import BaseCommand, CommandParser
from strawberry.printer import print_schema from strawberry.printer import print_schema
from bbssite.settings import BASE_DIR from bbs.api.schema import schema as schema_symbol
from main.api.schema import schema as schema_symbol
class Command(BaseCommand): class Command(BaseCommand):
@@ -16,7 +16,7 @@ class Command(BaseCommand):
def handle(self, *args, filename=None, **options): def handle(self, *args, filename=None, **options):
schema_output = print_schema(schema_symbol) schema_output = print_schema(schema_symbol)
if filename != "-": if filename != "-":
with Path(BASE_DIR, filename).open("w+") as fp: with Path(settings.BASE_DIR, filename).open("w+") as fp:
fp.write(schema_output) fp.write(schema_output)
self.stdout.write(self.style.SUCCESS("OK")) self.stdout.write(self.style.SUCCESS("OK"))
else: else:
@@ -1,6 +1,6 @@
from django.core.management.base import BaseCommand, CommandParser from django.core.management.base import BaseCommand, CommandParser
from main.models import UserProfile from bbs.models import UserProfile
class Command(BaseCommand): class Command(BaseCommand):
@@ -72,7 +72,7 @@ class Migration(migrations.Migration):
models.ForeignKey( models.ForeignKey(
on_delete=models.CASCADE, on_delete=models.CASCADE,
related_name="orderlines", related_name="orderlines",
to="main.Order", to="bbs.Order",
), ),
), ),
], ],
@@ -157,7 +157,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name="orderline", model_name="orderline",
name="product", name="product",
field=models.ForeignKey(on_delete=models.CASCADE, related_name="orderlines", to="main.Product"), field=models.ForeignKey(on_delete=models.CASCADE, related_name="orderlines", to="bbs.Product"),
), ),
migrations.AddField( migrations.AddField(
model_name="inventorytransaction", model_name="inventorytransaction",
@@ -166,7 +166,7 @@ class Migration(migrations.Migration):
on_delete=models.CASCADE, on_delete=models.CASCADE,
related_name="transactions", related_name="transactions",
verbose_name="Produkt", verbose_name="Produkt",
to="main.Product", to="bbs.Product",
), ),
), ),
migrations.AddField( migrations.AddField(
File renamed without changes.
+3 -3
View File
@@ -146,8 +146,8 @@ class OrderLineManager(models.QuerySet):
class OrderLine(models.Model): class OrderLine(models.Model):
order = models.ForeignKey("main.Order", on_delete=models.CASCADE, related_name="orderlines") order = models.ForeignKey("bbs.Order", on_delete=models.CASCADE, related_name="orderlines")
product = models.ForeignKey("main.Product", on_delete=models.CASCADE, related_name="orderlines") product = models.ForeignKey("bbs.Product", on_delete=models.CASCADE, related_name="orderlines")
amount = models.IntegerField() amount = models.IntegerField()
unit_price = models.FloatField(verbose_name="Enhetspris") unit_price = models.FloatField(verbose_name="Enhetspris")
@@ -184,7 +184,7 @@ class InventoryTransaction(models.Model):
related_name="inventory_transactions", related_name="inventory_transactions",
) )
product = models.ForeignKey( product = models.ForeignKey(
"main.Product", "bbs.Product",
on_delete=models.CASCADE, on_delete=models.CASCADE,
related_name="transactions", related_name="transactions",
verbose_name="Produkt", verbose_name="Produkt",
+3 -2
View File
@@ -72,7 +72,7 @@ MIDDLEWARE = [
"django.contrib.messages.middleware.MessageMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
] ]
ROOT_URLCONF = "bbssite.urls" ROOT_URLCONF = "bbs.urls"
INSTALLED_APPS = [ INSTALLED_APPS = [
"django.contrib.auth", "django.contrib.auth",
@@ -85,9 +85,10 @@ INSTALLED_APPS = [
"django_extensions", "django_extensions",
"easy_thumbnails", "easy_thumbnails",
"corsheaders", "corsheaders",
"django_rename_app",
] ]
LOCAL_APPS = [ LOCAL_APPS = [
"main", "bbs",
] ]
INSTALLED_APPS += LOCAL_APPS INSTALLED_APPS += LOCAL_APPS
@@ -2,7 +2,7 @@ import pytest
from django.test import Client from django.test import Client
from strawberry.django.test import GraphQLTestClient from strawberry.django.test import GraphQLTestClient
from main.models import Order, Product from bbs.models import Order, Product
@pytest.fixture(name="gql_client") @pytest.fixture(name="gql_client")
Executable → Regular
+7 -4
View File
@@ -2,16 +2,19 @@ from django.conf import settings
from django.conf.urls.static import static from django.conf.urls.static import static
from django.contrib import admin from django.contrib import admin
from django.contrib.auth.views import LoginView, LogoutView from django.contrib.auth.views import LoginView, LogoutView
from django.urls import include, path, re_path from django.urls import path, re_path
from strawberry.django.views import GraphQLView from strawberry.django.views import GraphQLView
from main import urls as main_urls from bbs.api.schema import schema
from main.api.schema import schema from bbs.views.reports import inventory, inventory_add, report
admin.autodiscover() admin.autodiscover()
urlpatterns = [ urlpatterns = [
re_path(r"", include(main_urls)), # TODO: migrate reports to SPA
re_path(r"^inventory/$", inventory, name="inventory"),
re_path(r"^inventory/add/$", inventory_add, name="inventory-add"),
re_path(r"^report$", report, name="report"),
path("accounts/login/", LoginView.as_view(), name="django.contrib.auth.views.login"), path("accounts/login/", LoginView.as_view(), name="django.contrib.auth.views.login"),
path("accounts/logout/", LogoutView.as_view(), name="django.contrib.auth.views.logout"), path("accounts/logout/", LogoutView.as_view(), name="django.contrib.auth.views.logout"),
path("admin/", admin.site.urls), path("admin/", admin.site.urls),
View File
File renamed without changes.
File renamed without changes.
@@ -4,8 +4,8 @@ from itertools import groupby
from django.contrib import messages from django.contrib import messages
from django.shortcuts import redirect, render from django.shortcuts import redirect, render
from main.forms import DateRangeForm, InventoryTransactionForm from bbs.forms import DateRangeForm, InventoryTransactionForm
from main.models import InventoryTransaction, Order, Product, Transaction, UserProfile from bbs.models import InventoryTransaction, Order, Product, Transaction, UserProfile
def report(request): def report(request):
+1 -1
View File
@@ -2,6 +2,6 @@ import os
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bbssite.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bbs.settings")
application = get_wsgi_application() application = get_wsgi_application()
-20
View File
@@ -1,20 +0,0 @@
import strawberry
from main.api.mutations.shop import ShopMutations
from main.api.mutations.users import UsersMutations
from main.api.queries.inventory import InventoryQueries
from main.api.queries.shop import ShopQueries
from main.api.queries.users import UsersQueries
@strawberry.type
class Query(InventoryQueries, ShopQueries, UsersQueries):
pass
@strawberry.type
class Mutation(ShopMutations, UsersMutations):
pass
schema = strawberry.Schema(query=Query, mutation=Mutation)
-11
View File
@@ -1,11 +0,0 @@
from django.urls import re_path
from main.views.reports import inventory, inventory_add, report
urlpatterns = [
# TODO: migrate to SPA
# Reports
re_path(r"^inventory/$", inventory, name="inventory"),
re_path(r"^inventory/add/$", inventory_add, name="inventory-add"),
re_path(r"^report$", report, name="report"),
]
View File
Whitespace-only changes.
+1 -1
View File
@@ -3,7 +3,7 @@ import os
import sys import sys
if __name__ == "__main__": if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bbssite.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bbs.settings")
from django.core.management import execute_from_command_line from django.core.management import execute_from_command_line
Generated
+16 -1
View File
@@ -143,6 +143,17 @@ python-versions = ">=3.6"
[package.dependencies] [package.dependencies]
Django = ">=2.2" Django = ">=2.2"
[[package]]
name = "django-rename-app"
version = "0.1.3"
description = "A Django Management Command to rename existing Django Applications."
category = "main"
optional = false
python-versions = "*"
[package.dependencies]
django = "*"
[[package]] [[package]]
name = "easy-thumbnails" name = "easy-thumbnails"
version = "2.7.2" version = "2.7.2"
@@ -570,7 +581,7 @@ testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)",
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.9" python-versions = "^3.9"
content-hash = "3fa14cb7bc28f810082b1aa4604a74060ec4ea32e63864f91a005aa37ea73c8c" content-hash = "c4579c258a444e0d3ab942c66b7374f6b868580adfeadc2fca39cd448a27be09"
[metadata.files] [metadata.files]
asgiref = [ asgiref = [
@@ -646,6 +657,10 @@ django-extensions = [
{file = "django-extensions-3.1.5.tar.gz", hash = "sha256:28e1e1bf49f0e00307ba574d645b0af3564c981a6dfc87209d48cb98f77d0b1a"}, {file = "django-extensions-3.1.5.tar.gz", hash = "sha256:28e1e1bf49f0e00307ba574d645b0af3564c981a6dfc87209d48cb98f77d0b1a"},
{file = "django_extensions-3.1.5-py3-none-any.whl", hash = "sha256:9238b9e016bb0009d621e05cf56ea8ce5cce9b32e91ad2026996a7377ca28069"}, {file = "django_extensions-3.1.5-py3-none-any.whl", hash = "sha256:9238b9e016bb0009d621e05cf56ea8ce5cce9b32e91ad2026996a7377ca28069"},
] ]
django-rename-app = [
{file = "django_rename_app-0.1.3-py2.py3-none-any.whl", hash = "sha256:bba31d33de4614124e2cd2f22fcea07b2affbbb2cf877a26893e0c15465fbfab"},
{file = "django_rename_app-0.1.3.tar.gz", hash = "sha256:195d2fa09eec8ed57577f7bf57a3c6944bdb6447fe47c07be0e575fb2e325742"},
]
easy-thumbnails = [ easy-thumbnails = [
{file = "easy-thumbnails-2.7.2.tar.gz", hash = "sha256:a7dd9cf97efaf70ba5d76484a962f08ba65b31f1681bc417257743650e9e8a8a"}, {file = "easy-thumbnails-2.7.2.tar.gz", hash = "sha256:a7dd9cf97efaf70ba5d76484a962f08ba65b31f1681bc417257743650e9e8a8a"},
{file = "easy_thumbnails-2.7.2-py3-none-any.whl", hash = "sha256:9d7ed56a9b57aba7a8d0e03dc3b8507ca51aab5e0ed0bc705c3261ff1f659192"}, {file = "easy_thumbnails-2.7.2-py3-none-any.whl", hash = "sha256:9d7ed56a9b57aba7a8d0e03dc3b8507ca51aab5e0ed0bc705c3261ff1f659192"},
+1
View File
@@ -28,6 +28,7 @@ sentry-sdk = "1.4.3"
strawberry-graphql = "^0.93.1" strawberry-graphql = "^0.93.1"
strawberry-graphql-django = "^0.2.5" strawberry-graphql-django = "^0.2.5"
django-cors-headers = "^3.10.0" django-cors-headers = "^3.10.0"
django-rename-app = "^0.1.3"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
pytest = "*" pytest = "*"