Skip to main content

User

The User model represents student and admin accounts in the system. Table name: users

Fields

id
Integer
required
Primary key, auto-incrementing
full_name
String(100)
required
User’s full name (indexed)
email
String(120)
required
Unique email address (indexed)
year
Integer
Academic year level
maths_class
String(100)
Math class identifier
password_hash
String(128)
Hashed password using Werkzeug security
is_admin
Boolean
default:"false"
required
Administrative privileges flag
key_stage
String(3)
required
Educational key stage (indexed)
school_id
Integer
Foreign key to school.id (indexed, nullable)
is_competition_participant
Boolean
default:"false"
required
Competition participation flag

Relationships

Methods

set_password
method
def set_password(self, password)
Hash and set user password using generate_password_hashParameters:
  • password (str): Plain text password to hash
check_password
method
def check_password(self, password) -> bool
Verify password against stored hash using check_password_hashParameters:
  • password (str): Plain text password to verify
Returns:
  • bool: True if password matches, False otherwise

Mixins

Inherits from UserMixin (Flask-Login) and db.Model

School

The School model represents educational institutions. Table name: school

Fields

id
Integer
required
Primary key, auto-incrementing
name
String(100)
required
School name (unique, indexed)
email_domain
String(100)
Email domain for school addresses
address
String(200)
Physical address
date_joined
DateTime
default:"datetime.datetime.now"
required
Timestamp when school joined the platform

Relationships

Build docs developers (and LLMs) love