-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
28 lines (23 loc) · 1.21 KB
/
models.py
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
from datetime import datetime
from database import db
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(120), unique=True, nullable=False)
username = db.Column(db.String(80), nullable=False)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
class Document(db.Model):
id = db.Column(db.Integer, primary_key=True)
filename = db.Column(db.String(120), nullable=False)
text = db.Column(db.Text, nullable=False)
upload_time = db.Column(db.DateTime, default=datetime.utcnow)
class TranscriptionSession(db.Model):
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
start_time = db.Column(db.DateTime, default=datetime.utcnow)
end_time = db.Column(db.DateTime)
status = db.Column(db.String(50), default='active')
user = db.relationship('User', back_populates='transcription_sessions')
User.transcription_sessions = db.relationship('TranscriptionSession',
order_by=TranscriptionSession.id,
back_populates='user'
)