Skip to content

Commit

Permalink
fix: list forms api
Browse files Browse the repository at this point in the history
  • Loading branch information
nrjadkry committed Sep 5, 2023
1 parent ef0f63d commit 6deb2eb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/backend/app/central/central_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,23 @@ def list_submissions(project_id: int, odk_central: project_schemas.ODKCentral =
def get_form_list(db: Session, skip: int, limit: int):
"""Returns the list of id and title of xforms from the database."""
try:
return (
forms = (
db.query(db_models.DbXForm.id, db_models.DbXForm.title)
.offset(skip)
.limit(limit)
.all()
)

result_dict = []
for form in forms:
form_dict = {
'id': form[0], # Assuming the first element is the ID
'title': form[1] # Assuming the second element is the title
}
result_dict.append(form_dict)

return result_dict

except Exception as e:
log.error(e)
raise HTTPException(e) from e
Expand Down

0 comments on commit 6deb2eb

Please sign in to comment.