feat(academic): allow subjects to be associated with multiple careers (v3.8.21)
This commit is contained in:
+12
-10
@@ -311,10 +311,6 @@ async def update_subject(
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
|
||||
if 'career_id' in data:
|
||||
c_id = data['career_id']
|
||||
subject.career_id = int(c_id) if c_id else None
|
||||
|
||||
if 'career_ids' in data:
|
||||
career_ids = data.get('career_ids')
|
||||
if isinstance(career_ids, str):
|
||||
@@ -326,14 +322,20 @@ async def update_subject(
|
||||
if c_id_list:
|
||||
c_objs = Career.query.filter(Career.id.in_(c_id_list)).all()
|
||||
subject.careers = c_objs
|
||||
if c_objs and not subject.career_id:
|
||||
subject.career_id = c_objs[0].id
|
||||
if not subject.career_id or subject.career_id not in c_id_list:
|
||||
subject.career_id = c_objs[0].id if c_objs else None
|
||||
else:
|
||||
subject.careers = []
|
||||
subject.career_id = None
|
||||
elif 'career_id' in data:
|
||||
c_id = data['career_id']
|
||||
subject.career_id = int(c_id) if c_id else None
|
||||
if subject.career_id:
|
||||
c_obj = Career.query.get(subject.career_id)
|
||||
if c_obj:
|
||||
subject.careers = [c_obj]
|
||||
else:
|
||||
subject.careers = []
|
||||
elif 'career_id' in data and subject.career_id:
|
||||
c_obj = Career.query.get(subject.career_id)
|
||||
if c_obj and c_obj not in subject.careers:
|
||||
subject.careers = [c_obj]
|
||||
|
||||
if 'description' in data:
|
||||
subject.description = (data['description'] or '').strip()
|
||||
|
||||
Reference in New Issue
Block a user