From b186239f046d8ab40aff6bf5c4f2119a0458efa5 Mon Sep 17 00:00:00 2001 From: ydb5755 Date: Fri, 13 Sep 2024 12:00:06 +0300 Subject: [PATCH] donation model --- app/campaigns/models.py | 1 + app/main/models.py | 15 +++++++++++++++ app/users/models.py | 1 + python_files/db_population.py | 0 4 files changed, 17 insertions(+) create mode 100644 app/main/models.py create mode 100644 python_files/db_population.py diff --git a/app/campaigns/models.py b/app/campaigns/models.py index 228bd1f..692b2b2 100644 --- a/app/campaigns/models.py +++ b/app/campaigns/models.py @@ -11,4 +11,5 @@ class Campaign(db.Model): __tablename__ = 'campaign' id = Column('id', INTEGER(), primary_key=True) title = Column('title', TEXT(), nullable=False) + donation_id = Column(INTEGER, ForeignKey('donation.id')) #ambassadors \ No newline at end of file diff --git a/app/main/models.py b/app/main/models.py new file mode 100644 index 0000000..479cfba --- /dev/null +++ b/app/main/models.py @@ -0,0 +1,15 @@ +from app import db +from flask import current_app +from flask_login import UserMixin, current_user +from sqlalchemy import TEXT, Column, Boolean, ForeignKey, TEXT, INTEGER, VARCHAR +import jwt +from datetime import datetime, timezone, timedelta + + +class Donation(db.Model): + __tablename__ = 'donation' + id = Column('id', INTEGER(), primary_key=True, autoincrement=True) + currency_type = Column('currency_type', TEXT(), nullable=False) + amount = Column('amount', INTEGER(), nullable=False) + campaign = db.relationship('Campaign', backref='Donation', lazy='dynamic') + user = db.relationship('User', backref='Donation', lazy='dynamic') \ No newline at end of file diff --git a/app/users/models.py b/app/users/models.py index d412b08..c6cb877 100644 --- a/app/users/models.py +++ b/app/users/models.py @@ -14,6 +14,7 @@ class User(db.Model, UserMixin): email = Column('email', TEXT(), nullable=False, unique=True) password = Column('password', TEXT(), nullable=False) user_type = Column('user_type', TEXT(), nullable=False) + donation_id = Column(INTEGER, ForeignKey('donation.id')) def get_reset_token(self, expiration=600): reset_token = jwt.encode( diff --git a/python_files/db_population.py b/python_files/db_population.py new file mode 100644 index 0000000..e69de29