This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.py
executable file
·42 lines (37 loc) · 2.28 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(400), unique=True, nullable=False)
fullname = db.Column(db.Text, unique=False, nullable=True)
email = db.Column(db.String(400), unique=True, nullable=True)
password = db.Column(db.String(1000), unique=False, nullable=True)
passwordToken = db.Column(db.Text, unique=False, nullable=True)
passwordResetTimer = db.Column(db.Integer, unique=False, nullable=True, default=-1)
highPermissionLevel = db.Column(db.Boolean, unique=False, nullable=False, default=False)
def __repr__(self):
return '<User %r>' % self.username
class Ticket(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(512), unique=False, nullable=True)
is_open = db.Column(db.Boolean, unique=False, nullable = False, default= True)
text = db.Column(db.Text, unique=False, nullable=False)
media = db.Column(db.Text, unique=False, nullable=True) #This contains base64'ed binary images and videos in a python list.
time = db.Column(db.Integer, unique = False) # The time the ticket was created in epoch seconds
created_by_id = db.Column(db.Integer, db.ForeignKey('user.id'))
hidden = db.Column(db.Boolean, unique=False, default= False)
created_by = db.relationship('User', backref='tickets_created_by', foreign_keys=[created_by_id])
def __repr__(self):
return '<Ticket %r>' % self.title
class TicketReply(db.Model):
id = db.Column(db.Integer, primary_key = True)
text = db.Column(db.Text, unique=False, nullable=False)
media = db.Column(db.Text, unique=False, nullable=True)
isNote = db.Column(db.Boolean, unique=False, nullable = True)
time = db.Column(db.Integer, unique = False) # The time the ticket reply was created in epoch seconds
created_by_id = db.Column(db.Integer, db.ForeignKey('user.id'))
main_ticket_id = db.Column(db.Integer, db.ForeignKey('ticket.id'))
created_by = db.relationship('User', backref='ticket_reply_by', foreign_keys=[created_by_id])
main_ticket = db.relationship('Ticket', backref = 'ticket_reply_main_ticket', foreign_keys=[main_ticket_id])
def __repr__(self):
return '<TicketReply to %r>' % self.main_ticket