Skip to content

Add hindi_name and image fields to StudentBatchUpload models - #1949

Merged
vikrantwiz02 merged 6 commits into
FusionIIIT:prod/acad-reactfrom
vikrantwiz02:prod/acad-react
Aug 12, 2026
Merged

Add hindi_name and image fields to StudentBatchUpload models#1949
vikrantwiz02 merged 6 commits into
FusionIIIT:prod/acad-reactfrom
vikrantwiz02:prod/acad-react

Conversation

@vikrantwiz02

Copy link
Copy Markdown
Member

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 StudentBatchUpload and PhdStudentBatchUpload models, implements secure base64 image upload/validation, and provides comprehensive regression tests for these features.

Model and Database Changes:

  • Added hindi_name, photo, and signature fields to both StudentBatchUpload and PhdStudentBatchUpload models to support Hindi names and image uploads for students. [1] [2] [3] [4]
  • Added a migration to create these fields in the database schema.

API and Backend Logic:

  • Updated the student creation and update endpoints to handle the new fields, including parsing and saving base64-encoded images for photo and signature, and supporting Hindi names and Aadhaar numbers. [1] [2] [3]
  • Implemented the _decode_base64_image helper for safe decoding, validation, and file creation from base64 image data, including size/type checks and handling unchanged images.
  • Extended batch student retrieval to return the new fields in both camelCase and snake_case for frontend compatibility.

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
@vikrantwiz02
vikrantwiz02 merged commit 24cadba into FusionIIIT:prod/acad-react Aug 12, 2026
1 check passed
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.

1 participant