Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
@@ -242,6 +242,8 @@ def update_idea_in_database(idea_id: int, form: IdeaForm, db: Session) -> bool:
|
|
242 |
db_idea = db.query(InnovativeIdea).filter(InnovativeIdea.id == idea_id).first()
|
243 |
if db_idea:
|
244 |
for field, value in form.dict(exclude_unset=True).items():
|
|
|
|
|
245 |
setattr(db_idea, field, value)
|
246 |
db.commit()
|
247 |
return True
|
@@ -263,7 +265,7 @@ def save_idea_to_database(form: IdeaForm, db: Session) -> Optional[int]:
|
|
263 |
technical_challenges=form.technical_challenges,
|
264 |
legal_barriers=form.legal_barriers,
|
265 |
data_dependencies=form.data_dependencies,
|
266 |
-
team_roles=','.join(
|
267 |
timeline=form.timeline,
|
268 |
additional_info=form.additional_info
|
269 |
)
|
@@ -290,7 +292,7 @@ def load_idea_from_database(idea_id: int, db: Session) -> Optional[IdeaForm]:
|
|
290 |
technical_challenges=db_idea.technical_challenges,
|
291 |
legal_barriers=db_idea.legal_barriers,
|
292 |
data_dependencies=db_idea.data_dependencies,
|
293 |
-
team_roles=
|
294 |
timeline=db_idea.timeline,
|
295 |
additional_info=db_idea.additional_info
|
296 |
)
|
|
|
242 |
db_idea = db.query(InnovativeIdea).filter(InnovativeIdea.id == idea_id).first()
|
243 |
if db_idea:
|
244 |
for field, value in form.dict(exclude_unset=True).items():
|
245 |
+
if field == 'team_roles' and isinstance(value, list):
|
246 |
+
value = ','.join(value) # Convert list to comma-separated string
|
247 |
setattr(db_idea, field, value)
|
248 |
db.commit()
|
249 |
return True
|
|
|
265 |
technical_challenges=form.technical_challenges,
|
266 |
legal_barriers=form.legal_barriers,
|
267 |
data_dependencies=form.data_dependencies,
|
268 |
+
team_roles=','.join(form.team_roles) if form.team_roles else '', # Convert list to string
|
269 |
timeline=form.timeline,
|
270 |
additional_info=form.additional_info
|
271 |
)
|
|
|
292 |
technical_challenges=db_idea.technical_challenges,
|
293 |
legal_barriers=db_idea.legal_barriers,
|
294 |
data_dependencies=db_idea.data_dependencies,
|
295 |
+
team_roles=db_idea.team_roles.split(',') if db_idea.team_roles else [], # Convert string back to list
|
296 |
timeline=db_idea.timeline,
|
297 |
additional_info=db_idea.additional_info
|
298 |
)
|