Created
August 11, 2018 23:27
-
-
Save EdMan1022/4ad69ff22eba6ed2bcb1ff95dbaca75d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .base_model import BaseModel | |
from ..extensions import db | |
from .classes.foreign_key_cascade import ForeignKeyCascade | |
# Association table between Payment and Subscription | |
payment_subscription = db.Table( | |
'payment_subscription', | |
db.Column('payment_id', db.Integer, db.ForeignKey('payment.id'), primary_key=True), | |
db.Column('subscription_id', db.Integer, db.ForeignKey('subscription.id'), | |
primary_key=True) | |
) | |
# Association table between Payment and OrderedProduct | |
payment_ordered_product = db.Table( | |
'payment_ordered_product', | |
db.Column('payment_id', db.Integer, db.ForeignKey('payment.id'), primary_key=True), | |
db.Column('ordered_product_id', db.Integer, db.ForeignKey('ordered_product.id'), | |
primary_key=True) | |
) | |
class Payment(BaseModel): | |
"""Ties an Order to the credit card charge that pays for the items that make it up""" | |
id = db.Column(db.Integer, primary_key=True) | |
order_id = db.Column(db.Integer, ForeignKeyCascade('order.id')) | |
subscription = db.relationship('Subscription', secondary=payment_subscription, backref=db.backref('payment')) | |
ordered_product = db.relationship('OrderedProduct', secondary=payment_ordered_product, | |
backref=db.backref('payment')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment