fix: resolver tipos estaticos en modelos, importador y academic router (v3.8.4)
This commit is contained in:
@@ -16,18 +16,19 @@ class Career(db.Model):
|
||||
created_at = db.Column(db.DateTime, default=lambda: datetime.now(timezone.utc).replace(tzinfo=None))
|
||||
|
||||
# Relationships
|
||||
subjects: List['Subject'] = db.relationship('Subject', backref='career_obj', lazy=True)
|
||||
subjects = db.relationship('Subject', backref='career_obj', lazy=True)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def to_dict(self):
|
||||
subs = getattr(self, 'subjects', None)
|
||||
return {
|
||||
'id': self.id,
|
||||
'name': self.name,
|
||||
'code': self.code,
|
||||
'description': self.description,
|
||||
'subjects_count': len(self.subjects) if self.subjects else 0,
|
||||
'subjects_count': len(subs) if isinstance(subs, (list, set, tuple)) else 0,
|
||||
'created_at': self.created_at.isoformat() if self.created_at else None
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ class Subject(db.Model):
|
||||
updated_at = db.Column(db.DateTime, default=lambda: datetime.now(timezone.utc).replace(tzinfo=None), onupdate=lambda: datetime.now(timezone.utc).replace(tzinfo=None))
|
||||
|
||||
# Relationships
|
||||
commissions: List['Commission'] = db.relationship('Commission', backref='subject', lazy=True, cascade='all, delete-orphan')
|
||||
careers: List['Career'] = db.relationship('Career', secondary=subject_careers, lazy='subquery', backref=db.backref('shared_subjects', lazy=True))
|
||||
commissions = db.relationship('Commission', backref='subject', lazy=True, cascade='all, delete-orphan')
|
||||
careers = db.relationship('Career', secondary=subject_careers, lazy='subquery', backref=db.backref('shared_subjects', lazy=True))
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user