Skip to content

Optimize Student API: Enhance StudentSerializer and Remove Duplicate View #2

@chung-coder

Description

@chung-coder

Description

Currently, we have duplicate functionality between ListStudentInfoView and StudentViewSet.
Plan to consolidate these by enhancing StudentSerializer and removing the duplicate view.

Current Implementation

  • ListStudentInfoView: Handles formatted student info display
  • StudentViewSet: Handles basic CRUD with raw data
  • Duplicate logic for retrieving student data
  • Two separate routes for similar functionality

Proposed Changes

  1. Enhance StudentSerializer:

    • Add formatted fields:
      • user_name
      • gender_display
      • email (from User)
      • class_name (from Class)
      • teacher_name (from Teacher)
    • Handle proper field formatting
    • Add related field validations
  2. Remove ListStudentInfoView:

    • Remove the duplicate view
    • Update URL routing
    • Ensure all current functionality is preserved in StudentViewSet

Expected Results

  • Single source of truth for student data formatting
  • Cleaner and more maintainable code
  • Same functionality through unified StudentViewSet
  • Better separation of concerns (data formatting in Serializer)

Tasks

  • Enhance StudentSerializer with formatted fields
  • Add proper field validations
  • Remove ListStudentInfoView
  • Update URL routing
  • Test all existing functionality still works
  • Update API documentation

Notes

  • Can keep current functionality while implementing changes
  • Consider handling null values in related fields
  • May need to update any frontend code using the old endpoint

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions