Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 4414: Implement file format validation #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

amanmogal
Copy link
Owner

This pull request addresses issue Cloud-CV#4414 by implementing file format validation for submissions to ensure that only accepted file formats are allowed. The changes include both client-side and server-side validations.

Changes Made:

  1. Client-Side Validation:

    • Implemented file format validation in JavaScript to ensure that only accepted file formats (e.g., CSV) are allowed for submission.
    • Added an event listener to the file input element to validate the file format before submission.
  2. Server-Side Validation:

    • Added file format validation in Django to ensure that the validation is not bypassed.
    • Implemented a validate_file_format function to check the file content type and raise a ValidationError if the format is not accepted.
  3. Error Messaging:

    • Displayed an error message to the user if the file format is not accepted, indicating the accepted file formats for the challenge.

Files Modified:

  • Client-Side:

    • frontend/src/js/controllers/SubmissionFilesCtrl.js
    • frontend/src/views/web/challenge/submission.html
  • Server-Side:

    • apps/challenges/views.py

How to Test:

  1. Client-Side:

    • Navigate to the submission page.
    • Try uploading a file with an invalid format (e.g., .txt).
    • Verify that an error message is displayed and the file is not submitted.
  2. Server-Side:

    • Submit a file with an invalid format via the API.
    • Verify that the server responds with an appropriate error message.

Issue Reference:

Fixes Cloud-CV#4414

Add server-side file format validation for challenge submissions

 "Update submission form to restrict file uploads to CSV format"
Add server-side file format validation for challenge submissions

 "Update submission form to restrict file uploads to CSV format"
Add server-side file format validation for challenge submissions

 "Update submission form to restrict file uploads to CSV format"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: Accepting files of incorrect formats instead of rejecting them
1 participant