From 9588116ba708bd1bf105ca483cc8a907f5100605 Mon Sep 17 00:00:00 2001 From: Midgard Date: Sun, 26 Jan 2020 03:04:17 +0100 Subject: [PATCH] Fix data model before generating migration --- app/database/muhscheme.txt | 3 +-- app/models/orderitemchoice.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 app/models/orderitemchoice.py diff --git a/app/database/muhscheme.txt b/app/database/muhscheme.txt index 6245514..711c142 100644 --- a/app/database/muhscheme.txt +++ b/app/database/muhscheme.txt @@ -30,9 +30,8 @@ order_item order_item_choice id + order_item_id choice_id HLDS identifier kind single_choice/multi_choice - order_item name - description value just a textual description of the chosen values diff --git a/app/models/orderitemchoice.py b/app/models/orderitemchoice.py new file mode 100644 index 0000000..95af04d --- /dev/null +++ b/app/models/orderitemchoice.py @@ -0,0 +1,20 @@ +from datetime import datetime + +from .database import db +from .orderitem import OrderItem + + +class OrderItemChoice(db.Model): + id = db.Column(db.Integer, primary_key=True) + choice_id = db.Column(db.String(64), nullable=True) + order_item_id = db.Column(db.Integer, db.ForeignKey("orderitem.id"), nullable=False) + kind = db.Column(db.String(1), nullable=False) + name = db.Column(db.String(120), nullable=True) + value = db.Column(db.String(120), nullable=True) + + # pylint: disable=attribute-defined-outside-init + def configure(self, order: OrderItem) -> None: + self.order = order + + def __repr__(self) -> str: + return "{}: {}".format(self.name, self.value)