[Bug] Files chosen in pop-up (modal) forms are silently discarded

Open Beginner friendly
#95 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
django, javascript
Domain
backend

Research direction

Start in templates/js/core.js at saveForm and check the modal form submission path for FormData; then inspect the add_own_qualification and update_own_qualification views to see whether they bind request.FILES. Verify that submitting a certificate file stores it and that the response still reports success.

Written by the indexing model from the issue text.

Description

Summary

templates/js/core.js saveForm submits every .js-submit-modal-form with data: form.serialize(). jQuery's serialize() never includes <input type="file">, so any file chosen in a modal form is dropped. The view saves the record and returns form_is_valid: true, so the user sees success but no file is stored.

We hit this with qualification certificates: add_own_qualification and update_own_qualification, field certificate_file.

Steps to reproduce

  1. Go to My Qualifications and add or edit a qualification.
  2. Choose a certificate file and save.
  3. The record saves, but it has no certificate, and no upload request carries the file.

Suggested fix

$.ajax({
  url: form.attr("action"),
  data: new FormData(form[0]),
  processData: false,
  contentType: false,
  type: form.attr("method"),
  dataType: "json",
  // ...
});

The views must also bind request.FILES to the form (Form(request.POST, request.FILES, ...)), if they don't already.

Dominant language
HTML
Stars
6
Forks
4
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from brainthee/CHAOTICA

All issues in brainthee/CHAOTICA

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.