-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
29 lines (22 loc) · 1010 Bytes
/
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
import datetime
from typing import List
from flask import url_for
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import Table, ForeignKey, Column, text, select, func
from sqlalchemy import Integer, String, Text, Boolean, Float, DateTime
from sqlalchemy.orm import relationship
from sqlalchemy.orm import Mapped
from sqlalchemy.orm import mapped_column
from flask_login import UserMixin
db = SQLAlchemy()
class User(UserMixin, db.Model):
__tablename__ = 'users'
id: Mapped[int] = mapped_column(primary_key=True)
usos_id: Mapped[int] = mapped_column(Integer, unique=True, nullable=True, default=None)
first_name: Mapped[str] = mapped_column(String(64), nullable=False)
last_name: Mapped[str] = mapped_column(String(64), nullable=False)
email: Mapped[str] = mapped_column(String(64), nullable=False)
student_number: Mapped[str] = mapped_column(String(10), nullable=True)
@property
def display_name(self):
return f"{self.first_name} {self.last_name}"