🚨 Add pre-commit
Format code Add bin/run
This commit is contained in:
1 parent
9d3afadbff
commit
dcd8edaaa6
28 files changed
+264
-51
No files matched your search
@@ -1,4 +1,5 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from main.models import *
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -18,5 +18,5 @@ class FieldError(Error):
|
||||
@strawberry.type
|
||||
class FormErrors:
|
||||
fields: list[FieldError]
|
||||
message: str = ''
|
||||
message: str = ""
|
||||
error: bool = True
|
||||
@@ -6,7 +6,7 @@ from django.shortcuts import get_object_or_404
|
||||
from strawberry import ID
|
||||
|
||||
from main import models
|
||||
from main.api.errors import Error, FormErrors, FieldError
|
||||
from main.api.errors import Error, FieldError, FormErrors
|
||||
from main.api.types import Order, Transaction, UserProfile
|
||||
|
||||
UserModel = get_user_model()
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import strawberry
|
||||
import strawberry_django
|
||||
|
||||
from main.api import mutations
|
||||
from main.api.types import Product, User, Order
|
||||
from main.api.types import Order, Product, User
|
||||
|
||||
|
||||
@strawberry.type
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from django.db.models import Sum, Count
|
||||
from django.db.models import Count, Sum
|
||||
from rest_framework import serializers
|
||||
from rest_framework.serializers import ModelSerializer
|
||||
|
||||
from main.models import Product, OrderLine, Order
|
||||
from main.models import Order, OrderLine, Product
|
||||
|
||||
|
||||
class ProductSerializer(ModelSerializer):
|
||||
|
||||
+1
-1
@@ -1,10 +1,10 @@
|
||||
from rest_framework import mixins
|
||||
from rest_framework.decorators import action
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.viewsets import GenericViewSet
|
||||
|
||||
from main.api.serializers import ProductSerializer, ProductStatSerializer
|
||||
from main.models import Product
|
||||
from rest_framework.viewsets import GenericViewSet
|
||||
|
||||
|
||||
class ProductViewSet(mixins.ListModelMixin, mixins.RetrieveModelMixin, GenericViewSet):
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ from django import forms
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from main.models import Order, Transaction, InventoryTransaction, Product, UserProfile
|
||||
from main.models import InventoryTransaction, Order, Product, Transaction, UserProfile
|
||||
from main.utils import format_username
|
||||
|
||||
|
||||
|
||||
@@ -11,13 +11,13 @@ class Command(BaseCommand):
|
||||
help = " Write graphql schema to file or stdout"
|
||||
|
||||
def add_arguments(self, parser: CommandParser):
|
||||
parser.add_argument("--filename", default='schema.graphql', help='`-` prints to stdout')
|
||||
parser.add_argument("--filename", default="schema.graphql", help="`-` prints to stdout")
|
||||
|
||||
def handle(self, *args, filename=None, **options):
|
||||
schema_output = print_schema(schema_symbol)
|
||||
if filename != '-':
|
||||
if filename != "-":
|
||||
with Path(BASE_DIR, filename).open("w+") as fp:
|
||||
fp.write(schema_output)
|
||||
self.stdout.write(self.style.SUCCESS('OK'))
|
||||
self.stdout.write(self.style.SUCCESS("OK"))
|
||||
else:
|
||||
print(schema_output)
|
||||
@@ -1,8 +1,8 @@
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
import difflib
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
import facebook
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
from main.models import UserProfile
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
+4
-5
@@ -1,15 +1,14 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Iterable, Type
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from graphql.pyutils import snake_to_camel
|
||||
import strawberry
|
||||
from django.contrib.auth.models import User
|
||||
from django.test.client import RequestFactory
|
||||
from graphql.pyutils import snake_to_camel
|
||||
from strawberry.arguments import is_unset
|
||||
from strawberry.types import ExecutionResult
|
||||
|
||||
from main.api.schema import schema
|
||||
from typing import Any, Iterable, Type
|
||||
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
|
||||
def lowercase_first_letter(text: str):
|
||||
|
||||
@@ -3,7 +3,7 @@ from django.test import Client
|
||||
from strawberry.django.test import GraphQLTestClient
|
||||
|
||||
from main.api.mutations import create_order
|
||||
from main.models import Product, Order
|
||||
from main.models import Order, Product
|
||||
from main.testing import MutationTest
|
||||
|
||||
|
||||
@@ -12,12 +12,12 @@ def gql_client_fixture(client: Client):
|
||||
yield GraphQLTestClient(client)
|
||||
|
||||
|
||||
@pytest.fixture(name='product')
|
||||
@pytest.fixture(name="product")
|
||||
def product_fix(db):
|
||||
return Product.objects.create(name='borg', sale_price_ext=35, sale_price_int=30)
|
||||
return Product.objects.create(name="borg", sale_price_ext=35, sale_price_int=30)
|
||||
|
||||
|
||||
@pytest.fixture(name='create_order_mutation')
|
||||
@pytest.fixture(name="create_order_mutation")
|
||||
def create_order_mutation_fixture(product):
|
||||
fields = """
|
||||
... on CreateOrderSuccess {
|
||||
@@ -38,13 +38,15 @@ def create_order_mutation_fixture(product):
|
||||
|
||||
def test_create_order(product, create_order_mutation):
|
||||
assert Order.objects.count() == 0
|
||||
res = create_order_mutation.mutate(customerId="external", isExternal=True, orderLines=[{"productId": product.id, "amount": 1}])
|
||||
res = create_order_mutation.mutate(
|
||||
customerId="external", isExternal=True, orderLines=[{"productId": product.id, "amount": 1}]
|
||||
)
|
||||
assert res
|
||||
assert not res.errors
|
||||
assert res.data
|
||||
order_lines = res.data.get('createOrder', {}).get('order', {}).get('orderlines', [])
|
||||
order_lines = res.data.get("createOrder", {}).get("order", {}).get("orderlines", [])
|
||||
assert order_lines
|
||||
assert order_lines[0]['product']['id'] == str(product.id)
|
||||
assert order_lines[0]["product"]["id"] == str(product.id)
|
||||
assert Order.objects.count() == 1
|
||||
o = Order.objects.first()
|
||||
assert o.orderlines.first().product.id == product.id
|
||||
+7
-7
@@ -1,21 +1,21 @@
|
||||
from django.conf.urls import url
|
||||
from django.contrib.staticfiles.views import serve
|
||||
from django.urls import path
|
||||
from rest_framework.routers import DefaultRouter
|
||||
|
||||
from main.api.views import ProductViewSet
|
||||
from main.views.general import deposit, log, register
|
||||
from main.views.reports import inventory, inventory_add, report
|
||||
from main.views.stats import (
|
||||
stats_list,
|
||||
stats_products_realtime,
|
||||
stats_products_per_user,
|
||||
OrdersHourlyView,
|
||||
OrdersDailyView,
|
||||
OrdersHourlyView,
|
||||
OrdersMonthlyView,
|
||||
OrdersYearlyView,
|
||||
stats_list,
|
||||
stats_products_per_user,
|
||||
stats_products_realtime,
|
||||
)
|
||||
from main.views.general import register, deposit, log
|
||||
from main.views.reports import inventory, inventory_add, report
|
||||
from main.views.users import create_user, profile
|
||||
from rest_framework.routers import DefaultRouter
|
||||
|
||||
urlpatterns = [
|
||||
url(r"^$", register, name="home"),
|
||||
|
||||
@@ -6,11 +6,11 @@ from django.contrib.auth.models import User
|
||||
from django.db.models import Min
|
||||
from django.forms import formset_factory
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import render, redirect
|
||||
from django.shortcuts import redirect, render
|
||||
from django.urls import reverse
|
||||
|
||||
from main.forms import OrderLineForm, OrderForm, DepositForm
|
||||
from main.models import Product, OrderLine, Order, Transaction
|
||||
from main.forms import DepositForm, OrderForm, OrderLineForm
|
||||
from main.models import Order, OrderLine, Product, Transaction
|
||||
from main.utils import users_format_js, users_with_perm
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@ from datetime import datetime, timedelta
|
||||
from itertools import groupby
|
||||
|
||||
from django.contrib import messages
|
||||
from django.shortcuts import render, redirect
|
||||
from django.shortcuts import redirect, render
|
||||
|
||||
from main.forms import DateRangeForm, InventoryTransactionForm
|
||||
from main.models import Product, InventoryTransaction, UserProfile, Transaction, Order
|
||||
from main.models import InventoryTransaction, Order, Product, Transaction, UserProfile
|
||||
|
||||
|
||||
def report(request):
|
||||
|
||||
+4
-3
@@ -1,12 +1,13 @@
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
from itertools import groupby
|
||||
|
||||
from django.http import JsonResponse
|
||||
from django.shortcuts import render
|
||||
from django.utils import timezone
|
||||
from itertools import groupby
|
||||
|
||||
from django.views.generic import View
|
||||
from main.models import Product, OrderLine, Order
|
||||
|
||||
from main.models import Order, OrderLine, Product
|
||||
|
||||
|
||||
def stats_list(request):
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.db import connection
|
||||
from django.db.models import Sum, Count
|
||||
from django.shortcuts import render, redirect
|
||||
from django.db.models import Count, Sum
|
||||
from django.shortcuts import redirect, render
|
||||
|
||||
from main.forms import SimpleCreateUserForm
|
||||
from main.models import Order
|
||||
from main.models import Transaction
|
||||
from main.models import Order, Transaction
|
||||
|
||||
|
||||
def create_user(request):
|
||||
|
||||
Reference in new issue
Block a user