diff --git a/config/api/v1/urls.py b/config/api/v1/urls.py index 95007fc..2588df2 100644 --- a/config/api/v1/urls.py +++ b/config/api/v1/urls.py @@ -1,5 +1,5 @@ -from django.urls import path, include -from drf_spectacular.views import SpectacularSwaggerView, SpectacularRedocView +from django.urls import include, path +from drf_spectacular.views import SpectacularRedocView, SpectacularSwaggerView from config.api.v1.views import APISchema diff --git a/config/celery.py b/config/celery.py index 55b7fa5..08783a9 100644 --- a/config/celery.py +++ b/config/celery.py @@ -1,4 +1,5 @@ import os + from celery import Celery # set the default Django settings module for the 'celery' program. diff --git a/config/settings/base.py b/config/settings/base.py index 1802d1b..ea595fc 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -1,4 +1,5 @@ import datetime + from config.settings.environ import * # noqa APP_NAME = "Shop" diff --git a/config/settings/environ.py b/config/settings/environ.py index 5bd5554..106b14c 100644 --- a/config/settings/environ.py +++ b/config/settings/environ.py @@ -1,7 +1,7 @@ import os -import environ from pathlib import Path +import environ BASE_DIR = Path(".") diff --git a/config/tests/mixins.py b/config/tests/mixins.py index f25a6d3..924175b 100644 --- a/config/tests/mixins.py +++ b/config/tests/mixins.py @@ -1,6 +1,7 @@ -import string import random -from django.contrib.auth.models import User, Permission +import string + +from django.contrib.auth.models import Permission, User class TestUserAuthenticationMixin: diff --git a/config/urls.py b/config/urls.py index 149f6b7..b3e6e57 100644 --- a/config/urls.py +++ b/config/urls.py @@ -2,8 +2,7 @@ import debug_toolbar from django.conf import settings from django.conf.urls.static import static from django.contrib import admin -from django.urls import path, include - +from django.urls import include, path urlpatterns = [ path("", include("shop.urls")), diff --git a/files/api/v1/urls.py b/files/api/v1/urls.py index 849a82e..88cbbd5 100644 --- a/files/api/v1/urls.py +++ b/files/api/v1/urls.py @@ -2,7 +2,6 @@ from rest_framework.routers import DefaultRouter from files.api.v1.views import FileUploadViewSet - app_name = "files" diff --git a/files/api/v1/views.py b/files/api/v1/views.py index 9816ba3..56ee215 100644 --- a/files/api/v1/views.py +++ b/files/api/v1/views.py @@ -1,4 +1,5 @@ from rest_framework.viewsets import ModelViewSet + from files.api.v1.serializers import FileUploadSerializer from files.models import FileUpload diff --git a/shop/admin.py b/shop/admin.py index c7c60aa..1205f13 100644 --- a/shop/admin.py +++ b/shop/admin.py @@ -1,18 +1,9 @@ from django.contrib import admin -from shop.models import ( - Product, - ProductPrice, - OrderLine, - Order, - Tax, - Customer, - Provider, - Tag, - ProductBatch, - Brand, -) from unfold.admin import ModelAdmin +from shop.models import (Brand, Customer, Order, OrderLine, Product, + ProductBatch, ProductPrice, Provider, Tag, Tax) + # Register your models here. @admin.register(Product) diff --git a/shop/api/v1/permissions.py b/shop/api/v1/permissions.py index 91a7a03..ab9e0fc 100644 --- a/shop/api/v1/permissions.py +++ b/shop/api/v1/permissions.py @@ -1,4 +1,5 @@ from rest_framework.permissions import BasePermission + from config.api.v1.mixins import CRUDPermissionsMixin diff --git a/shop/api/v1/routers.py b/shop/api/v1/routers.py index 76ea448..5aea780 100644 --- a/shop/api/v1/routers.py +++ b/shop/api/v1/routers.py @@ -1,17 +1,10 @@ from rest_framework.routers import DefaultRouter -from shop.api.v1.viewsets import ( - TaxViewSet, - CustomerViewSet, - ProductViewSet, - ProductPriceViewSet, - OrderViewSet, - OrderLineViewSet, - ProviderViewSet, - ProductBatchViewSet, - TagViewSet, - BrandViewSet, -) +from shop.api.v1.viewsets import (BrandViewSet, CustomerViewSet, + OrderLineViewSet, OrderViewSet, + ProductBatchViewSet, ProductPriceViewSet, + ProductViewSet, ProviderViewSet, TagViewSet, + TaxViewSet) app_name = "shop" diff --git a/shop/api/v1/serializers.py b/shop/api/v1/serializers.py index 8b7a185..6f1ab54 100644 --- a/shop/api/v1/serializers.py +++ b/shop/api/v1/serializers.py @@ -1,19 +1,10 @@ from django.utils import timezone from rest_framework import serializers -from files.api.v1.serializers import FileUploadSerializer, NoIDFileUploadSerializer -from shop.models import ( - Product, - ProductPrice, - Customer, - Tax, - OrderLine, - Order, - ProductBatch, - Provider, - Tag, - Brand, -) +from files.api.v1.serializers import (FileUploadSerializer, + NoIDFileUploadSerializer) +from shop.models import (Brand, Customer, Order, OrderLine, Product, + ProductBatch, ProductPrice, Provider, Tag, Tax) class TaxSerializer(serializers.ModelSerializer): diff --git a/shop/api/v1/viewsets.py b/shop/api/v1/viewsets.py index dca6f28..b1d9a80 100644 --- a/shop/api/v1/viewsets.py +++ b/shop/api/v1/viewsets.py @@ -1,45 +1,26 @@ from decimal import Decimal -from django.db.models.deletion import ProtectedError -from django.utils.text import gettext_lazy as _ -from django.shortcuts import get_object_or_404 from django.db import transaction - -from rest_framework.viewsets import ModelViewSet +from django.db.models.deletion import ProtectedError +from django.shortcuts import get_object_or_404 +from django.utils.text import gettext_lazy as _ from rest_framework.exceptions import ValidationError from rest_framework.permissions import IsAdminUser - -from shop.filters import ProductFilter -from shop.api.v1.serializers import ( - ProductSerializer, - ProductPriceSerializer, - CustomerSerializer, - TaxSerializer, - OrderSerializer, - OrderLineSerializer, - ProviderSerializer, - ProductBatchSerializer, - CreateProductSerializer, - CreateProductPriceSerializer, - TagSerializer, - ListProductSerializer, - UpdateProductSerializer, - BrandSerializer, -) -from shop.models import ( - Product, - ProductPrice, - Customer, - Tax, - Order, - OrderLine, - Provider, - ProductBatch, - Tag, - Brand, -) +from rest_framework.viewsets import ModelViewSet from shop.api.v1.permissions import ProductPermissions, ProductPricePermissions +from shop.api.v1.serializers import (BrandSerializer, + CreateProductPriceSerializer, + CreateProductSerializer, + CustomerSerializer, ListProductSerializer, + OrderLineSerializer, OrderSerializer, + ProductBatchSerializer, + ProductPriceSerializer, ProductSerializer, + ProviderSerializer, TagSerializer, + TaxSerializer, UpdateProductSerializer) +from shop.filters import ProductFilter +from shop.models import (Brand, Customer, Order, OrderLine, Product, + ProductBatch, ProductPrice, Provider, Tag, Tax) from shop.utils import delete_product_batch diff --git a/shop/filters.py b/shop/filters.py index f2b3ae6..0ac0faa 100644 --- a/shop/filters.py +++ b/shop/filters.py @@ -1,5 +1,5 @@ -from django.utils.text import gettext_lazy as _ import django_filters +from django.utils.text import gettext_lazy as _ from shop.models import Product diff --git a/shop/migrations/0001_initial.py b/shop/migrations/0001_initial.py index 4a7ebf2..5258f49 100644 --- a/shop/migrations/0001_initial.py +++ b/shop/migrations/0001_initial.py @@ -1,9 +1,10 @@ # Generated by Django 5.0.6 on 2024-05-21 17:19 +import uuid +from decimal import Decimal + import django.db.models.deletion import django.utils.timezone -import uuid -from decimal import Decimal from django.db import migrations, models diff --git a/shop/migrations/0003_alter_brand_creation_date_and_more.py b/shop/migrations/0003_alter_brand_creation_date_and_more.py index e069fd8..12a52de 100644 --- a/shop/migrations/0003_alter_brand_creation_date_and_more.py +++ b/shop/migrations/0003_alter_brand_creation_date_and_more.py @@ -1,8 +1,9 @@ # Generated by Django 5.0.6 on 2024-06-02 19:47 +from decimal import Decimal + import django.db.models.deletion import django.utils.timezone -from decimal import Decimal from django.db import migrations, models diff --git a/shop/tests/test_api_orders.py b/shop/tests/test_api_orders.py index b3b7f1c..08f562a 100644 --- a/shop/tests/test_api_orders.py +++ b/shop/tests/test_api_orders.py @@ -4,7 +4,7 @@ from rest_framework import status from rest_framework.test import APITestCase from config.tests.mixins import TestUserAuthenticationMixin -from shop.models import Product, ProductPrice, Tax, Customer +from shop.models import Customer, Product, ProductPrice, Tax class TestOrdersAPI(APITestCase, TestUserAuthenticationMixin): diff --git a/shop/tests/test_api_products.py b/shop/tests/test_api_products.py index a142d63..fef0fb3 100644 --- a/shop/tests/test_api_products.py +++ b/shop/tests/test_api_products.py @@ -2,12 +2,12 @@ import random import string from decimal import Decimal +from django.utils import timezone from rest_framework import status from rest_framework.test import APITestCase -from django.utils import timezone from config.tests.mixins import TestUserAuthenticationMixin -from shop.models import Product, ProductPrice, Tax, ProductBatch, Tag +from shop.models import Product, ProductBatch, ProductPrice, Tag, Tax class TestProductsAPI(APITestCase, TestUserAuthenticationMixin): diff --git a/shop/tests/test_shop_models.py b/shop/tests/test_shop_models.py index dbfd884..7f91ddd 100644 --- a/shop/tests/test_shop_models.py +++ b/shop/tests/test_shop_models.py @@ -1,7 +1,9 @@ from decimal import Decimal + from rest_framework.test import APITestCase as TestCase -from shop.models import Product, ProductPrice, Tax, Customer -from shop.utils import create_order_line_for_product, create_order + +from shop.models import Customer, Product, ProductPrice, Tax +from shop.utils import create_order, create_order_line_for_product class ShopModelsTest(TestCase): diff --git a/shop/urls.py b/shop/urls.py index f971ec0..0bee606 100644 --- a/shop/urls.py +++ b/shop/urls.py @@ -1,4 +1,5 @@ from django.urls import path + from shop.views import index, list_products, product_detail app_name = "shop" diff --git a/shop/utils.py b/shop/utils.py index e2c0216..edbb38b 100644 --- a/shop/utils.py +++ b/shop/utils.py @@ -1,6 +1,6 @@ from decimal import Decimal -from shop.models import OrderLine, Product, Order, Customer, ProductBatch +from shop.models import Customer, Order, OrderLine, Product, ProductBatch def create_order_line_for_product(product: Product, quantity: Decimal, order: Order): diff --git a/shop/views.py b/shop/views.py index da0bae6..cb46b0e 100644 --- a/shop/views.py +++ b/shop/views.py @@ -1,11 +1,9 @@ -from django.views.generic import TemplateView from django.shortcuts import get_object_or_404 -from django.core.paginator import Paginator +from django.views.generic import TemplateView from shop.filters import ProductFilter -from shop.models import Product - from shop.mixins import FilteredQuerysetMixin, PaginatedQuerysetMixin +from shop.models import Product class IndexView(TemplateView): diff --git a/theme/templates/theme/base.html b/theme/templates/theme/base.html index 26831d2..4e3614f 100644 --- a/theme/templates/theme/base.html +++ b/theme/templates/theme/base.html @@ -3,7 +3,7 @@ - + {{ title }} @@ -14,9 +14,9 @@
-{% block main %} + {% block main %} -{% endblock %} + {% endblock %}
diff --git a/tpv/admin.py b/tpv/admin.py index 7846fe6..a531a98 100644 --- a/tpv/admin.py +++ b/tpv/admin.py @@ -1,7 +1,8 @@ from django.contrib import admin -from tpv.models import PaymentTransaction from unfold.admin import ModelAdmin +from tpv.models import PaymentTransaction + # Register your models here. @admin.register(PaymentTransaction) diff --git a/tpv/migrations/0001_initial.py b/tpv/migrations/0001_initial.py index f56db61..f8ebca3 100644 --- a/tpv/migrations/0001_initial.py +++ b/tpv/migrations/0001_initial.py @@ -1,10 +1,12 @@ # Generated by Django 5.0.6 on 2024-05-21 17:19 -import tpv.models import uuid from decimal import Decimal + from django.db import migrations, models +import tpv.models + class Migration(migrations.Migration): diff --git a/tpv/models.py b/tpv/models.py index 2b13417..4edb3a7 100644 --- a/tpv/models.py +++ b/tpv/models.py @@ -1,5 +1,6 @@ from decimal import Decimal from uuid import uuid4 + from django.db import models from django.utils.text import gettext_lazy as _ diff --git a/tpv/redsys.py b/tpv/redsys.py index 556e70d..0db1a4b 100644 --- a/tpv/redsys.py +++ b/tpv/redsys.py @@ -1,15 +1,14 @@ import base64 import json -import requests +import requests from django.conf import settings from django.urls import reverse -from tpv.models import PaymentTransaction -from tpv.utils import compute_signature, decode_b64_dict -from tpv.settings import TransactionTypes - from tpv.exceptions import RedsysPaymentException +from tpv.models import PaymentTransaction +from tpv.settings import TransactionTypes +from tpv.utils import compute_signature, decode_b64_dict class RedsysClient: diff --git a/tpv/signals.py b/tpv/signals.py index b968008..4e952a7 100644 --- a/tpv/signals.py +++ b/tpv/signals.py @@ -1,5 +1,4 @@ from django.dispatch import Signal - redsys_payment_accepted = Signal() redsys_payment_rejected = Signal() diff --git a/tpv/tests/test_redsys.py b/tpv/tests/test_redsys.py index ade09ca..516bd1c 100644 --- a/tpv/tests/test_redsys.py +++ b/tpv/tests/test_redsys.py @@ -1,16 +1,16 @@ import base64 import json from decimal import Decimal + +from django.conf import settings from django.urls import reverse +from django.utils import timezone from rest_framework import status from rest_framework.test import APITestCase -from django.conf import settings -from django.utils import timezone from tpv.models import PaymentTransaction from tpv.redsys import RedsysClient from tpv.settings import ERROR_CODES - from tpv.utils import validate_expiry_date diff --git a/tpv/urls.py b/tpv/urls.py index dfe14a8..74e36ff 100644 --- a/tpv/urls.py +++ b/tpv/urls.py @@ -1,11 +1,7 @@ from django.urls import path -from tpv.views import ( - transaction_created, - webhook, - payment_accepted, - payment_rejected, - payment_form, -) + +from tpv.views import (payment_accepted, payment_form, payment_rejected, + transaction_created, webhook) app_name = "tpv" diff --git a/tpv/utils.py b/tpv/utils.py index 042cd02..4030f82 100644 --- a/tpv/utils.py +++ b/tpv/utils.py @@ -2,15 +2,14 @@ import base64 import hashlib import hmac import json +import re +from decimal import Decimal import pyDes -import re - -from decimal import Decimal -from django.utils.text import gettext_lazy as _ from django.utils import timezone +from django.utils.text import gettext_lazy as _ -from tpv.exceptions import RedsysValidationException, RedsysPaymentException +from tpv.exceptions import RedsysPaymentException, RedsysValidationException from tpv.models import PaymentTransaction from tpv.settings import ERROR_CODES from tpv.signals import redsys_payment_accepted diff --git a/tpv/views.py b/tpv/views.py index 7db907e..c422769 100644 --- a/tpv/views.py +++ b/tpv/views.py @@ -1,14 +1,14 @@ +from django.http.response import HttpResponse +from django.shortcuts import get_object_or_404, redirect, render from django.urls import reverse from django.views.decorators.csrf import csrf_exempt -from django.shortcuts import render, get_object_or_404, redirect -from django.http.response import HttpResponse from django.views.generic import TemplateView from tpv.forms import UpdateEmailForm from tpv.models import PaymentTransaction from tpv.redsys import RedsysClient -from tpv.utils import pay_transaction, validate_payment_for_transaction from tpv.signals import redsys_payment_accepted, redsys_payment_rejected +from tpv.utils import pay_transaction, validate_payment_for_transaction def payment_accepted(request, transaction): diff --git a/users/api/v1/serializers.py b/users/api/v1/serializers.py index 811c1a3..6d895fd 100644 --- a/users/api/v1/serializers.py +++ b/users/api/v1/serializers.py @@ -2,10 +2,8 @@ from typing import List from django.conf import settings from django.contrib.auth import get_user_model -from django.contrib.auth.password_validation import ( - get_password_validators, - validate_password, -) +from django.contrib.auth.password_validation import (get_password_validators, + validate_password) from rest_framework import serializers from rest_framework.exceptions import ValidationError from rest_framework_simplejwt.serializers import TokenObtainPairSerializer diff --git a/users/api/v1/urls.py b/users/api/v1/urls.py index 9272041..a6b9fbd 100644 --- a/users/api/v1/urls.py +++ b/users/api/v1/urls.py @@ -1,12 +1,8 @@ from django.urls import path -from users.api.v1.views import retrieve_update_me, change_password - -from rest_framework_simplejwt.views import ( - token_refresh, - token_obtain_pair, - token_verify, -) +from rest_framework_simplejwt.views import (token_obtain_pair, token_refresh, + token_verify) +from users.api.v1.views import change_password, retrieve_update_me app_name = "auth" diff --git a/users/api/v1/views.py b/users/api/v1/views.py index b3d867d..f3687f8 100644 --- a/users/api/v1/views.py +++ b/users/api/v1/views.py @@ -2,7 +2,7 @@ from django.contrib.auth.models import User from rest_framework.generics import RetrieveUpdateAPIView, UpdateAPIView from rest_framework.permissions import IsAuthenticated -from users.api.v1.serializers import UserSerializer, UpdatePasswordSerializer +from users.api.v1.serializers import UpdatePasswordSerializer, UserSerializer class RetrieveUpdateMe(RetrieveUpdateAPIView): diff --git a/users/forms/login.py b/users/forms/login.py index 06d8c2b..62bf724 100644 --- a/users/forms/login.py +++ b/users/forms/login.py @@ -1,6 +1,6 @@ -from django.utils.text import gettext_lazy as _ from django import forms from django.contrib.auth.forms import AuthenticationForm, UsernameField +from django.utils.text import gettext_lazy as _ class LoginForm(AuthenticationForm): diff --git a/users/tests/test_api_change_password.py b/users/tests/test_api_change_password.py index 710e10a..b3eee7e 100644 --- a/users/tests/test_api_change_password.py +++ b/users/tests/test_api_change_password.py @@ -1,7 +1,7 @@ -from rest_framework import status -from rest_framework.test import APITestCase from django.contrib.auth import get_user_model from django.shortcuts import reverse +from rest_framework import status +from rest_framework.test import APITestCase User = get_user_model() diff --git a/users/tests/test_api_login.py b/users/tests/test_api_login.py index ab9f39e..093f305 100644 --- a/users/tests/test_api_login.py +++ b/users/tests/test_api_login.py @@ -1,7 +1,7 @@ -from rest_framework import status -from rest_framework.test import APITestCase from django.contrib.auth import get_user_model from django.shortcuts import reverse +from rest_framework import status +from rest_framework.test import APITestCase User = get_user_model() diff --git a/users/tests/test_login.py b/users/tests/test_login.py index f035348..0257754 100644 --- a/users/tests/test_login.py +++ b/users/tests/test_login.py @@ -1,7 +1,7 @@ -from rest_framework import status -from rest_framework.test import APITestCase from django.contrib.auth import get_user_model from django.shortcuts import reverse +from rest_framework import status +from rest_framework.test import APITestCase User = get_user_model() diff --git a/users/tests/test_users_model.py b/users/tests/test_users_model.py index 3de1334..efe1f0e 100644 --- a/users/tests/test_users_model.py +++ b/users/tests/test_users_model.py @@ -1,10 +1,8 @@ import pytest - from django.contrib.auth import get_user_model from django.contrib.auth.models import Group from django.test import TestCase - User = get_user_model() diff --git a/users/urls.py b/users/urls.py index f740d6e..0d2dc8f 100644 --- a/users/urls.py +++ b/users/urls.py @@ -1,4 +1,5 @@ from django.urls import path + from users.views import login, logout, register, reset_password app_name = "users" diff --git a/users/views.py b/users/views.py index 251d498..9317ab5 100644 --- a/users/views.py +++ b/users/views.py @@ -1,7 +1,9 @@ +from django.contrib.auth import login as login_user +from django.contrib.auth import logout as logout_user +from django.shortcuts import redirect, render, reverse from django.views.generic import TemplateView, View -from django.shortcuts import render, reverse, redirect + from users.forms import LoginForm -from django.contrib.auth import login as login_user, logout as logout_user class RedirectionMixin: