~homeworkprod/byceps

b004c6967b0208ddb7e6525db1ece1205720698b — Jochen Kupperschmidt 3 years ago 3a6720f
Move `PaymentMethod` and `PaymentState` enums to order transfer package
M app.py => app.py +2 -2
@@ 17,9 17,9 @@ from byceps.services.party.models.party import Party
from byceps.services.shop.article.models.article import Article
from byceps.services.shop.order.models.order import Order
from byceps.services.shop.order.models.order_item import OrderItem
from byceps.services.shop.order.models.payment import \
    PaymentState as OrderPaymentState
from byceps.services.shop.order.service import find_order_by_order_number
from byceps.services.shop.order.transfer.models import \
    PaymentState as OrderPaymentState
from byceps.services.ticketing.ticket_service import find_ticket_by_code
from byceps.services.user.models.detail import UserDetail
from byceps.services.user.models.user import User

M byceps/blueprints/shop_article_admin/views.py => byceps/blueprints/shop_article_admin/views.py +1 -1
@@ 13,9 13,9 @@ from flask import abort, request

from ...services.party import service as party_service
from ...services.shop.article import service as article_service
from ...services.shop.order.models.payment import PaymentState
from ...services.shop.order import ordered_articles_service, \
    service as order_service
from ...services.shop.order.transfer.models import PaymentState
from ...services.shop.sequence import service as sequence_service
from ...services.user import service as user_service
from ...util.framework.blueprint import create_blueprint

M byceps/blueprints/shop_order/views.py => byceps/blueprints/shop_order/views.py +1 -1
@@ 11,8 11,8 @@ from flask import abort, g, request
from ...services.country import service as country_service
from ...services.shop.article import service as article_service
from ...services.shop.cart.models import Cart
from ...services.shop.order.models.payment import PaymentMethod
from ...services.shop.order import service as order_service
from ...services.shop.order.transfer.models import PaymentMethod
from ...util.framework.blueprint import create_blueprint
from ...util.framework.flash import flash_error, flash_success
from ...util.framework.templating import templated

M byceps/blueprints/shop_order_admin/forms.py => byceps/blueprints/shop_order_admin/forms.py +1 -1
@@ 9,7 9,7 @@ byceps.blueprints.shop_order_admin.forms
from wtforms import RadioField, TextAreaField
from wtforms.validators import InputRequired, Length

from ...services.shop.order.models.payment import PaymentMethod
from ...services.shop.order.transfer.models import PaymentMethod
from ...util.l10n import LocalizedForm



M byceps/blueprints/shop_order_admin/models.py => byceps/blueprints/shop_order_admin/models.py +1 -2
@@ 8,10 8,9 @@ byceps.blueprints.shop_order_admin.models

from enum import Enum

from ...services.shop.order.transfer.models import PaymentState
from ...util import iterables

from ...services.shop.order.models.payment import PaymentState


IGNORED = None
NOT_YET_SHIPPED = False

M byceps/blueprints/shop_order_admin/views.py => byceps/blueprints/shop_order_admin/views.py +1 -1
@@ 9,9 9,9 @@ byceps.blueprints.shop_order_admin.views
from flask import abort, g, request, Response

from ...services.party import service as party_service
from ...services.shop.order.models.payment import PaymentMethod, PaymentState
from ...services.shop.order import service as order_service
from ...services.shop.order.export import service as order_export_service
from ...services.shop.order.transfer.models import PaymentMethod, PaymentState
from ...services.shop.sequence import service as sequence_service
from ...services.ticketing import ticket_service
from ...services.user import service as user_service

M byceps/services/shop/order/action_registry_service.py => byceps/services/shop/order/action_registry_service.py +1 -1
@@ 12,7 12,7 @@ from ...user_badge.transfer.models import BadgeID
from ..article.transfer.models import ArticleNumber

from .models.order_action import Parameters
from .models.payment import PaymentState
from .transfer.models import PaymentState

from . import action_service


M byceps/services/shop/order/action_service.py => byceps/services/shop/order/action_service.py +1 -1
@@ 18,7 18,7 @@ from .actions.create_tickets import create_tickets
from .actions.revoke_tickets import revoke_tickets
from .models.order import OrderTuple
from .models.order_action import OrderAction, Parameters
from .models.payment import PaymentState
from .transfer.models import PaymentState


OrderActionType = Callable[[OrderTuple, ArticleNumber, int, Parameters], None]

M byceps/services/shop/order/models/order.py => byceps/services/shop/order/models/order.py +1 -3
@@ 21,9 21,7 @@ from ....user.models.user import User

from ...article.models.article import Article

from ..transfer.models import OrderNumber

from .payment import PaymentMethod, PaymentState
from ..transfer.models import OrderNumber, PaymentMethod, PaymentState


OrderTuple = namedtuple('OrderTuple', [

M byceps/services/shop/order/models/order_action.py => byceps/services/shop/order/models/order_action.py +1 -1
@@ 15,7 15,7 @@ from .....database import db, generate_uuid
from ...article.models.article import Article
from ...article.transfer.models import ArticleNumber

from .payment import PaymentState
from ..transfer.models import PaymentState


Parameters = Dict[str, Any]

D byceps/services/shop/order/models/payment.py => byceps/services/shop/order/models/payment.py +0 -20
@@ 1,20 0,0 @@
"""
byceps.services.shop.order.models.order.payment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2018 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from enum import Enum


PaymentMethod = Enum('PaymentMethod', ['bank_transfer', 'cash', 'direct_debit'])


PaymentState = Enum('PaymentState', [
    'open',
    'canceled_before_paid',
    'paid',
    'canceled_after_paid',
])

M byceps/services/shop/order/ordered_articles_service.py => byceps/services/shop/order/ordered_articles_service.py +1 -2
@@ 14,8 14,7 @@ from ....database import db
from ..article.transfer.models import ArticleNumber

from .models.order_item import OrderItem as DbOrderItem
from .models.payment import PaymentState
from .transfer.models import OrderItem
from .transfer.models import OrderItem, PaymentState


def count_ordered_articles(article_number: ArticleNumber

M byceps/services/shop/order/service.py => byceps/services/shop/order/service.py +1 -2
@@ 27,9 27,8 @@ from .models.order import Order, OrderTuple
from .models.order_event import OrderEvent
from .models.order_item import OrderItem
from .models.orderer import Orderer
from .models.payment import PaymentMethod, PaymentState
from . import action_service
from .transfer.models import OrderID, OrderNumber
from .transfer.models import OrderID, OrderNumber, PaymentMethod, PaymentState


class OrderFailed(Exception):

M byceps/services/shop/order/transfer/models.py => byceps/services/shop/order/transfer/models.py +16 -0
@@ 7,6 7,7 @@ byceps.services.shop.order.transfer.models
"""

from decimal import Decimal
from enum import Enum
from typing import NewType
from uuid import UUID



@@ 21,6 22,21 @@ OrderID = NewType('OrderID', UUID)
OrderNumber = NewType('OrderNumber', str)


PaymentMethod = Enum('PaymentMethod', [
    'bank_transfer',
    'cash',
    'direct_debit',
])


PaymentState = Enum('PaymentState', [
    'open',
    'canceled_before_paid',
    'paid',
    'canceled_after_paid',
])


@attrs(frozen=True, slots=True)
class OrderItem:
    order_number = attrib(type=OrderNumber)

M testfixtures/shop_order.py => testfixtures/shop_order.py +1 -1
@@ 9,7 9,7 @@ testfixtures.shop_order
from byceps.services.shop.order.models.order import Order
from byceps.services.shop.order.models.order_item import OrderItem
from byceps.services.shop.order.models.orderer import Orderer
from byceps.services.shop.order.models.payment import PaymentMethod
from byceps.services.shop.order.transfer.models import PaymentMethod


ANY_ORDER_NUMBER = 'AEC-03-B00074'

M tests/blueprints/shop_order_admin/test_views.py => tests/blueprints/shop_order_admin/test_views.py +1 -1
@@ 5,7 5,7 @@

from byceps.services.shop.article.models.article import Article
from byceps.services.shop.order.models.order import Order
from byceps.services.shop.order.models.payment import PaymentMethod, \
from byceps.services.shop.order.transfer.models import PaymentMethod, \
    PaymentState

from testfixtures.shop_article import create_article

M tests/services/shop/order/actions/base.py => tests/services/shop/order/actions/base.py +1 -1
@@ 4,7 4,7 @@
"""

from byceps.services.shop.cart.models import Cart
from byceps.services.shop.order.models.payment import PaymentMethod
from byceps.services.shop.order.transfer.models import PaymentMethod
from byceps.services.shop.order import service as order_service
from byceps.services.shop.sequence.models import Purpose
from byceps.services.shop.sequence import service as shop_sequence_service

M tests/services/shop/order/models/test_order_payment_state.py => tests/services/shop/order/models/test_order_payment_state.py +1 -1
@@ 3,7 3,7 @@
:License: Modified BSD, see LICENSE for details.
"""

from byceps.services.shop.order.models.payment import PaymentState
from byceps.services.shop.order.transfer.models import PaymentState

from testfixtures.shop_order import create_order
from testfixtures.user import create_user

M tests/services/shop/order/test_ordered_articles_service.py => tests/services/shop/order/test_ordered_articles_service.py +1 -1
@@ 6,7 6,7 @@
from itertools import count

from byceps.services.shop.order import ordered_articles_service
from byceps.services.shop.order.models.payment import PaymentState
from byceps.services.shop.order.transfer.models import PaymentState

from testfixtures.shop_article import create_article
from testfixtures.shop_order import create_order, create_order_item