mirror of
https://github.com/simple-login/app.git
synced 2025-02-23 23:34:05 +08:00
Add Notification model
This commit is contained in:
parent
dfb427e6da
commit
a2e7de0bab
2 changed files with 13 additions and 0 deletions
|
@ -1417,3 +1417,11 @@ class RecoveryCode(db.Model, ModelMixin):
|
||||||
"""Delete all recovery codes for user"""
|
"""Delete all recovery codes for user"""
|
||||||
cls.query.filter_by(user_id=user.id).delete()
|
cls.query.filter_by(user_id=user.id).delete()
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
|
class Notification(db.Model, ModelMixin):
|
||||||
|
user_id = db.Column(db.ForeignKey(User.id, ondelete="cascade"), nullable=False)
|
||||||
|
message = db.Column(db.Text, nullable=False)
|
||||||
|
|
||||||
|
# whether user has marked the notification as read
|
||||||
|
read = db.Column(db.Boolean, nullable=False, default=False)
|
||||||
|
|
|
@ -53,6 +53,7 @@ from app.models import (
|
||||||
EmailLog,
|
EmailLog,
|
||||||
Referral,
|
Referral,
|
||||||
AliasMailbox,
|
AliasMailbox,
|
||||||
|
Notification,
|
||||||
)
|
)
|
||||||
from app.monitor.base import monitor_bp
|
from app.monitor.base import monitor_bp
|
||||||
from app.oauth.base import oauth_bp
|
from app.oauth.base import oauth_bp
|
||||||
|
@ -247,6 +248,10 @@ def fake_data():
|
||||||
referral = Referral.create(user_id=user.id, code="REFCODE", name="First referral")
|
referral = Referral.create(user_id=user.id, code="REFCODE", name="First referral")
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
for i in range(6):
|
||||||
|
Notification.create(user_id=user.id, message=f"""Hey hey <b>{i}</b> """ * 10)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
User.create(
|
User.create(
|
||||||
email="winston@continental.com",
|
email="winston@continental.com",
|
||||||
name="Winston",
|
name="Winston",
|
||||||
|
|
Loading…
Reference in a new issue