-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.py
More file actions
20 lines (16 loc) · 768 Bytes
/
Copy pathuser.py
File metadata and controls
20 lines (16 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from tortoise import fields,models
from models.project import Project
from models.task import Task
class User(models.Model):
id = fields.IntField(pk=True)
username = fields.CharField(max_length=50,unique=True)
email = fields.CharField(max_length=255,unique=True)
password = fields.CharField(max_length=255)
role = fields.CharField(max_length=20,default="user")
task_owner = fields.ReverseRelation["Task"] # tasks owned by this user
projects = fields.ReverseRelation["Project"] #projects of this user
tasks_assigned = fields.ManyToManyRelation["Task"] # task assigned to this user
created_at = fields.DatetimeField(auto_now_add=True)
updated_at = fields.DatetimeField(auto_now=True)
class Meta:
table = "users"