Files
team-tryouts/app/models/objective.py
T
cedrick2711 f468217745
CI - Security, Lint & Tests / validate (push) Failing after 1m13s
progression 50% pour evolution des joueurs
2026-09-05 11:30:13 -04:00

85 lines
2.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Player evolution objective — individual or team KPI-based goal."""
from app.extensions import db
from app.time_utils import utc_now_naive
class Objective(db.Model):
"""Player evolution objective — a KPI-driven plan for individual players
or teams, created and tracked by coaching staff.
Covers the full lifecycle: draft (pending), active, completed, overdue.
Supports arbitrary KPI metrics, optional tags, and verifiable progress.
"""
__tablename__ = 'objectives'
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(200), nullable=False)
description = db.Column(db.Text, nullable=True)
# Category
type = db.Column(
db.String(20),
nullable=False,
default='individual',
)
status = db.Column(
db.String(20),
nullable=False,
default='active',
)
priority = db.Column(
db.String(20),
nullable=False,
default='medium',
)
category = db.Column(db.String(50), nullable=True)
is_template = db.Column(db.Boolean, default=False, nullable=False)
# Assignment (individual player / org team)
player_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=True)
team_id = db.Column(db.Integer, db.ForeignKey('org_teams.id'), nullable=True)
# KPI fields
kpi_metric = db.Column(db.String(120), nullable=True)
kpi_target = db.Column(db.Numeric(10, 2), nullable=True)
kpi_unit = db.Column(db.String(20), nullable=True)
kpi_precision = db.Column(db.Integer, nullable=True)
# Timeline
start_date = db.Column(db.Date, nullable=True)
due_date = db.Column(db.Date, nullable=False)
check_frequency = db.Column(db.String(30), nullable=True)
# Progress tracking (0–100)
progress = db.Column(db.Integer, default=0, nullable=False)
# Misc
tags = db.Column(db.String(255), nullable=True)
# Who created it
created_by = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
# Timestamps
created_at = db.Column(db.DateTime, default=utc_now_naive)
updated_at = db.Column(db.DateTime, default=utc_now_naive, onupdate=utc_now_naive)
# -----------------------------------------------------------------------
# Relationships
# -----------------------------------------------------------------------
player = db.relationship(
'User',
foreign_keys=[player_id],
backref=db.backref('objectives', lazy='dynamic'),
)
team = db.relationship(
'OrgTeam',
foreign_keys=[team_id],
backref=db.backref('objectives', lazy='dynamic'),
)
creator = db.relationship(
'User',
foreign_keys=[created_by],
)