Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions api/routes/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@

@router.post("/fill", response_model=FormFillResponse)
def fill_form(form: FormFill, db: Session = Depends(get_db)):
if not get_template(db, form.template_id):
raise AppError("Template not found", status_code=404)

fetched_template = get_template(db, form.template_id)

if not fetched_template:
raise AppError("Template not found", status_code=404)

controller = Controller()
path = controller.fill_form(user_input=form.input_text, fields=fetched_template.fields, pdf_form_path=fetched_template.pdf_path)
path = controller.fill_form(
user_input=form.input_text,
fields=fetched_template.fields,
pdf_form_path=fetched_template.pdf_path
)

submission = FormSubmission(**form.model_dump(), output_pdf_path=path)
return create_form(db, submission)
Expand Down