-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
30 lines (23 loc) · 1.06 KB
/
models.py
File metadata and controls
30 lines (23 loc) · 1.06 KB
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
from flask_login import UserMixin
from extensions import db
class User(UserMixin, db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(20), unique=True)
image_path = db.Column(db.String(60))
notifications = db.relationship('Notification', backref='user')
contacts = db.relationship('Contact', backref='user')
class Contact(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(60), unique=True)
image_path = db.Column(db.String(60))
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
notifications = db.relationship('Notification', backref='contact')
class Notification(db.Model):
id = db.Column(db.Integer, primary_key=True)
from_user = db.Column(db.Integer)
timestamp = db.Column(db.String(14))
confirmed = db.Column(db.Integer)
time_created = db.Column(db.String(10))
date_created = db.Column(db.String(10))
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
contact_id = db.Column(db.Integer, db.ForeignKey('contact.id'))