setup update 2

This commit is contained in:
Alejandro Vazquez
2026-03-26 19:39:31 -03:00
parent fa76741d50
commit 9fb21c4a29
9 changed files with 86 additions and 54 deletions
+14 -8
View File
@@ -6,11 +6,11 @@ class Subject(db.Model):
id = db.Column(db.Integer, primary_key=True)
code = db.Column(db.String(20), unique=True, nullable=False, index=True)
name = db.Column(db.String(100), nullable=False)
name = db.Column(db.String(200), nullable=False)
description = db.Column(db.Text)
department = db.Column(db.String(100), nullable=False)
credits = db.Column(db.Integer)
duration_minutes = db.Column(db.Integer, default=90)
credits = db.Column(db.Integer, nullable=False)
duration_in_minutes = db.Column(db.Integer, nullable=False)
is_active = db.Column(db.Boolean, default=True, nullable=False)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
@@ -27,7 +27,7 @@ class Subject(db.Model):
'description': self.description,
'department': self.department,
'credits': self.credits,
'duration_minutes': self.duration_minutes,
'duration_minutes': self.duration_in_minutes,
'is_active': self.is_active,
'created_at': self.created_at.isoformat() if self.created_at else None,
'updated_at': self.updated_at.isoformat() if self.updated_at else None
@@ -42,18 +42,24 @@ class Commission(db.Model):
id = db.Column(db.Integer, primary_key=True)
subject_id = db.Column(db.Integer, db.ForeignKey('subjects.id'), nullable=False)
code = db.Column(db.String(50), nullable=False)
semester = db.Column(db.String(20), nullable=False) # Fall, Spring, Summer
semester = db.Column(db.String(20), nullable=False)
year = db.Column(db.Integer, nullable=False)
teacher_name = db.Column(db.String(100), nullable=False)
max_students = db.Column(db.Integer, default=50)
teacher_id = db.Column(db.Integer, db.ForeignKey('users.id'))
max_students = db.Column(db.Integer, nullable=False)
current_students = db.Column(db.Integer, default=0)
schedule = db.Column(db.String(255)) # e.g., "MWF 9:00-10:30 AM"
schedule = db.Column(db.String(255))
is_active = db.Column(db.Boolean, default=True, nullable=False)
created_at = db.Column(db.DateTime, default=datetime.utcnow)
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
# Relationships
reservations = db.relationship('Reservation', backref='commission', lazy=True, cascade='all, delete-orphan')
teacher = db.relationship('User', backref='teaching_commissions', foreign_keys=[teacher_id])
# Virtual field for teacher_name
@property
def teacher_name(self):
return f"{self.teacher.first_name} {self.teacher.last_name}" if self.teacher else "TBD"
# Unique constraint
__table_args__ = (db.UniqueConstraint('subject_id', 'code', 'semester', 'year'),)