From 816c1d697e4937a0abdc1d11e445ed9f42c8c44b Mon Sep 17 00:00:00 2001 From: ydb5755 Date: Fri, 20 Sep 2024 12:02:01 +0300 Subject: [PATCH] add anonymous option to donation --- app/main/models.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/main/models.py b/app/main/models.py index 45021a0..4829f2b 100644 --- a/app/main/models.py +++ b/app/main/models.py @@ -13,11 +13,11 @@ class Donation(db.Model): amount = Column('amount', INTEGER(), nullable=False) user_id = Column('user_id', INTEGER(), nullable=False) campaign_id = Column('campaign_id', INTEGER(), nullable=False) + anonymous = Column('anonymous', Boolean(), default=False) - # user_id = Column(INTEGER, ForeignKey('user.id')) - # campaign_id = Column(INTEGER, ForeignKey('campaign.id')) - + def get_user(self): + from app.users.models import User + return User.query.filter_by(id=self.user_id).first() + def __repr__(self) -> str: - return f"{self.id} - {self.currency_type} - {self.amount}" - # campaign = db.relationship('Campaign', backref='donation', lazy='dynamic') - # user = db.relationship('User', backref='donation', lazy='dynamic') \ No newline at end of file + return f"{self.id} - {self.currency_type} - {self.amount}" \ No newline at end of file