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)