Skip to content

feat(placement-cell): Rebuild Placement Cell backend with clean REST API#1889

Open
vikrantwiz02 wants to merge 2 commits intoFusionIIIT:prod/acad-reactfrom
vikrantwiz02:feat(placement)/placement-branch-vikrant
Open

feat(placement-cell): Rebuild Placement Cell backend with clean REST API#1889
vikrantwiz02 wants to merge 2 commits intoFusionIIIT:prod/acad-reactfrom
vikrantwiz02:feat(placement)/placement-branch-vikrant

Conversation

@vikrantwiz02
Copy link
Copy Markdown
Member

@vikrantwiz02 vikrantwiz02 commented May 1, 2026

Summary

  • Complete rewrite of the placement_cell Django app — replaces the legacy 5810-line monolithic views.py + 25-model schema with a clean service/selector/API architecture
  • Deletes all old forms, template views, and URLs; adds a DRF token-authenticated REST API
  • CPI is never stored — always fetched live from examination.api.views.calculate_cpi_for_student() against published ResultAnnouncement records

Architecture

placement_cell/
├── models.py — Company, JobPost, PlacementSchedule, PlacementApplication,
│ PlacementResult, StudentPlacementProfile, PlacementAnnouncement,
│ PlacementStatistics, OffCampusPlacement
├── services.py — write operations only (create/update/delete, apply, withdraw,
│ bulk status, upsert profile, off-campus CRUD)
├── selectors.py — read queries only (student CPI, eligible jobs, applicant lists,
│ live batch statistics)
├── api/views.py — thin views: authenticate → role check → service/selector → serialize
├── api/serializers.py
├── api/urls.py
├── tests/test_module.py — 9 service + API tests
└── migrations/ — 0001_initial, 0002 (OffCampusPlacement + PPO type), 0003 (apply_link)

Key design decisions

  • Live CPI: selectors.get_student_published_cpi() calls calculate_cpi_for_student() — no stored CPI field on profile
  • Opted-out is one-way: services.upsert_student_profile() ignores opted_out=False if already True
  • Off-campus = placed: services.add_offcampus_placement() sets StudentPlacementProfile.is_placed = True
  • Live statistics: _compute_batch_live_stats() queries live from Student/Application/OffCampus/Result tables — no stale snapshot dependency
  • apply_link tracking: student clicking an external apply link still hits POST /stu/jobs/<id>/apply/ to record the application in DB before opening the external URL

API surface

Prefix Roles Endpoints
/placement-cell/api/stu/ student dashboard, jobs, apply, withdraw, applications, profile
/placement-cell/api/officer/ placement officer companies, jobs, toggle, applicants, status, bulk-status, students, update, offcampus, announcements, statistics, export
/placement-cell/api/chairman/ placement chairman statistics, students, export
/placement-cell/api/dean/ dean + faculty statistics, announcements, batches

Test plan

  • python manage.py check → 0 errors
  • python manage.py migrate → clean
  • GET /placement-cell/api/stu/dashboard/ with student token → 200
  • POST /placement-cell/api/stu/jobs/<id>/apply/ with CPI below min_cpi → 400 with message
  • GET /placement-cell/api/officer/jobs/ with student token → 403
  • GET /placement-cell/api/officer/export/ → valid XLSX download
  • python manage.py test placement_cell → all 9 tests pass
  • Verify globals, otheracademic, academic_procedures still import cleanly

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