🚚 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 main.models import *
from bbs.models import *
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 strawberry import ID
from main import models
from main.api.errors import Error, FieldError, FormErrors
from main.api.types.inventory import Transaction
from main.api.types.shop import Order
from bbs import models
from bbs.api.errors import Error, FieldError, FormErrors
from bbs.api.types.inventory import Transaction
from bbs.api.types.shop import Order
UserModel = get_user_model()
@@ -4,8 +4,8 @@ from django.contrib.auth import get_user_model
from django.db import transaction
from strawberry_django import auto
from main import models
from main.api.types.users import User
from bbs import models
from bbs.api.types.users import User
DjangoUser = get_user_model()
File renamed without changes.
@@ -1,7 +1,7 @@
import strawberry
import strawberry_django
from main.api.types.inventory import Transaction, TransactionOrdering
from bbs.api.types.inventory import Transaction, TransactionOrdering
@strawberry.type
@@ -1,8 +1,8 @@
import strawberry
import strawberry_django
from main import models
from main.api.types.shop import Order, OrderOrdering, OrderStats, OrderStatsByTime, Point, Product, ProductOrderStat
from bbs import models
from bbs.api.types.shop import Order, OrderOrdering, OrderStats, OrderStatsByTime, Point, Product, ProductOrderStat
@strawberry.type
@@ -3,7 +3,7 @@ import strawberry_django
from django.contrib.auth.models import User as DjangoUser
from strawberry import ID
from main.api.types.users import User
from bbs.api.types.users import User
@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
from strawberry_django import auto
from main import models
from main.api.types.users import User
from bbs import models
from bbs.api.types.users import User
@strawberry_django.ordering.order(models.Transaction)
@@ -2,8 +2,8 @@ import strawberry
import strawberry_django
from strawberry_django import auto
from main import models
from main.api.types.utils import JSONScalar
from bbs import models
from bbs.api.types.utils import JSONScalar
@strawberry_django.filters.filter(models.Product)
@@ -31,7 +31,7 @@ class OrderOrdering:
@strawberry_django.type(models.Order)
class Order:
id: auto
customer: strawberry.LazyType["User", "main.api.types.users"]
customer: strawberry.LazyType["User", "bbs.api.types.users"]
order_sum: auto
created: auto
orderlines: list["OrderLine"]
@@ -5,8 +5,8 @@ import strawberry_django
from django.contrib.auth import get_user_model
from strawberry_django import auto
from main import models
from main.api.types.shop import Point, ProductOrderStat
from bbs import models
from bbs.api.types.shop import Point, ProductOrderStat
UserModel = get_user_model()
File renamed without changes.
+1 -1
View File
@@ -2,7 +2,7 @@ from django.apps import AppConfig
class BBSAppConfig(AppConfig):
name = "main"
name = "bbs"
verbose_name = "Biceps Bar System"
def ready(self):
+1 -1
View File
@@ -1,6 +1,6 @@
from django import forms
from main.models import InventoryTransaction, Product
from bbs.models import InventoryTransaction, Product
class InventoryTransactionForm(forms.ModelForm):
File renamed without changes.
File renamed without changes.
@@ -1,10 +1,10 @@
from pathlib import Path
from django.conf import settings
from django.core.management import BaseCommand, CommandParser
from strawberry.printer import print_schema
from bbssite.settings import BASE_DIR
from main.api.schema import schema as schema_symbol
from bbs.api.schema import schema as schema_symbol
class Command(BaseCommand):
@@ -16,7 +16,7 @@ class Command(BaseCommand):
def handle(self, *args, filename=None, **options):
schema_output = print_schema(schema_symbol)
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)
self.stdout.write(self.style.SUCCESS("OK"))
else:
@@ -1,6 +1,6 @@
from django.core.management.base import BaseCommand, CommandParser
from main.models import UserProfile
from bbs.models import UserProfile
class Command(BaseCommand):
@@ -72,7 +72,7 @@ class Migration(migrations.Migration):
models.ForeignKey(
on_delete=models.CASCADE,
related_name="orderlines",
to="main.Order",
to="bbs.Order",
),
),
],
@@ -157,7 +157,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name="orderline",
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(
model_name="inventorytransaction",
@@ -166,7 +166,7 @@ class Migration(migrations.Migration):
on_delete=models.CASCADE,
related_name="transactions",
verbose_name="Produkt",
to="main.Product",
to="bbs.Product",
),
),
migrations.AddField(
File renamed without changes.
+3 -3
View File
@@ -146,8 +146,8 @@ class OrderLineManager(models.QuerySet):
class OrderLine(models.Model):
order = models.ForeignKey("main.Order", on_delete=models.CASCADE, related_name="orderlines")
product = models.ForeignKey("main.Product", on_delete=models.CASCADE, related_name="orderlines")
order = models.ForeignKey("bbs.Order", on_delete=models.CASCADE, related_name="orderlines")
product = models.ForeignKey("bbs.Product", on_delete=models.CASCADE, related_name="orderlines")
amount = models.IntegerField()
unit_price = models.FloatField(verbose_name="Enhetspris")
@@ -184,7 +184,7 @@ class InventoryTransaction(models.Model):
related_name="inventory_transactions",
)
product = models.ForeignKey(
"main.Product",
"bbs.Product",
on_delete=models.CASCADE,
related_name="transactions",
verbose_name="Produkt",
+3 -2
View File
@@ -72,7 +72,7 @@ MIDDLEWARE = [
"django.contrib.messages.middleware.MessageMiddleware",
]
ROOT_URLCONF = "bbssite.urls"
ROOT_URLCONF = "bbs.urls"
INSTALLED_APPS = [
"django.contrib.auth",
@@ -85,9 +85,10 @@ INSTALLED_APPS = [
"django_extensions",
"easy_thumbnails",
"corsheaders",
"django_rename_app",
]
LOCAL_APPS = [
"main",
"bbs",
]
INSTALLED_APPS += LOCAL_APPS
@@ -2,7 +2,7 @@ import pytest
from django.test import Client
from strawberry.django.test import GraphQLTestClient
from main.models import Order, Product
from bbs.models import Order, Product
@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.contrib import admin
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 main import urls as main_urls
from main.api.schema import schema
from bbs.api.schema import schema
from bbs.views.reports import inventory, inventory_add, report
admin.autodiscover()
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/logout/", LogoutView.as_view(), name="django.contrib.auth.views.logout"),
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.shortcuts import redirect, render
from main.forms import DateRangeForm, InventoryTransactionForm
from main.models import InventoryTransaction, Order, Product, Transaction, UserProfile
from bbs.forms import DateRangeForm, InventoryTransactionForm
from bbs.models import InventoryTransaction, Order, Product, Transaction, UserProfile
def report(request):
+1 -1
View File
@@ -2,6 +2,6 @@ import os
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()
-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
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
Generated
+16 -1
View File
@@ -143,6 +143,17 @@ python-versions = ">=3.6"
[package.dependencies]
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]]
name = "easy-thumbnails"
version = "2.7.2"
@@ -570,7 +581,7 @@ testing = ["coverage (>=4)", "coverage-enable-subprocess (>=1)", "flaky (>=3)",
[metadata]
lock-version = "1.1"
python-versions = "^3.9"
content-hash = "3fa14cb7bc28f810082b1aa4604a74060ec4ea32e63864f91a005aa37ea73c8c"
content-hash = "c4579c258a444e0d3ab942c66b7374f6b868580adfeadc2fca39cd448a27be09"
[metadata.files]
asgiref = [
@@ -646,6 +657,10 @@ django-extensions = [
{file = "django-extensions-3.1.5.tar.gz", hash = "sha256:28e1e1bf49f0e00307ba574d645b0af3564c981a6dfc87209d48cb98f77d0b1a"},
{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 = [
{file = "easy-thumbnails-2.7.2.tar.gz", hash = "sha256:a7dd9cf97efaf70ba5d76484a962f08ba65b31f1681bc417257743650e9e8a8a"},
{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-django = "^0.2.5"
django-cors-headers = "^3.10.0"
django-rename-app = "^0.1.3"
[tool.poetry.dev-dependencies]
pytest = "*"