Add hindi_name and image fields to StudentBatchUpload models - #1949
Merged
vikrantwiz02 merged 6 commits intoAug 12, 2026
Conversation
Add hindi_name (CharField) and photo/signature (ImageField, upload_to media) to StudentBatchUpload and PhdStudentBatchUpload, plus migration 0049. - add_single_student: persist hindi_name + aadhar_number (was dropped) and decode base64 photo/signature into ImageFields via a shared helper. - update_student: hindi_name/aadhar_number via direct_fields; photo/signature replaced only when a new base64 image is sent (unchanged edits keep the file). - get_batch_students: return hindi_name, aadhaar, and photo/signature URLs so UG/PG/PhD lists show them. Images arrive as base64 in the existing JSON payload; stored as real files.
Defense-in-depth: _decode_base64_image now returns None for any type other than png/jpg/jpeg, matching the frontend restriction.
Save photo/signature as <roll_number>_photo.<ext> and <roll_number>_sign.<ext> on both manual add and update.
_decode_base64_image now rejects payloads over max_kb (photo 200KB, signature 30KB) so the frontend caps can't be bypassed via a direct API call.
Prevents orphaned image files accumulating in media/ on re-upload.
13 tests covering: - _decode_base64_image branches (valid png/jpeg naming, oversize/type/empty rejects) - model persistence of hindi_name/aadhar/photo/signature on both upload models - update_student endpoint: auth required, image+text round-trip, oversize rejected, replacement deletes old file, unchanged path preserved Add Fusion.settings.test_settings (disables historical migrations) so the suite builds a schema from current models; several legacy RunSQL migrations can't run against an empty DB. Run: manage.py test applications.programme_curriculum.test_upcoming_batches \ --settings=Fusion.settings.test_settings --noinput
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds support for storing student passport photos, signatures, Hindi names, and Aadhaar numbers in the student management system, including both the core models and API endpoints. It introduces new fields to the
StudentBatchUploadandPhdStudentBatchUploadmodels, implements secure base64 image upload/validation, and provides comprehensive regression tests for these features.Model and Database Changes:
hindi_name,photo, andsignaturefields to bothStudentBatchUploadandPhdStudentBatchUploadmodels to support Hindi names and image uploads for students. [1] [2] [3] [4]API and Backend Logic:
photoandsignature, and supporting Hindi names and Aadhaar numbers. [1] [2] [3]_decode_base64_imagehelper for safe decoding, validation, and file creation from base64 image data, including size/type checks and handling unchanged images.