ref: legacy
src/types/configuration.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
from . import db from datetime import datetime as dt from datetime import timedelta class Configuration(db.Model): __tablename__ = "configurations" id = db.Column(db.Integer, primary_key = True) purchase_duration = db.Column(db.Float, nullable = False) purchase_duration_type = db.Column(db.String(256), server_default = 'days') delivery_duration = db.Column(db.Float, nullable = False) delivery_duration_type = db.Column(db.String(256), server_default = 'days') created_at = db.Column(db.DateTime, default = dt.now) updated_at = db.Column(db.DateTime, default = dt.now) def __init__(self, purchase_duration, purchase_duration_type, delivery_duration, delivery_duration_type): self.purchase_duration = purchase_duration self.purchase_duration_type = purchase_duration_type self.delivery_duration = delivery_duration self.delivery_duration_type = delivery_duration_type def purchase_time_delta(self): d = dict() d[self.purchase_duration_type] = self.purchase_duration return timedelta(**d) def delivery_time_delta(self): d = dict() d[self.delivery_duration_type] = self.delivery_duration return timedelta(**d) |