Skip to content

fix: volunteer signup

Vandana reddy Balannagari requested to merge fix/signup-vol into develop

Merge Request

Overview

This MR introduces a fully role-based medical camp signup and attendance system. It resolves issues where users were restricted to a single role per camp and enables independent registration and tracking for multiple roles such as coordinator, volunteer, and doctor. It also integrates QR-based attendance per role.

What does this MR do and why?

Previously, the system blocked users from signing up for multiple roles using the same identity. This caused incorrect behavior such as volunteer signup being blocked if the user was already a coordinator, incorrect signup-status responses, and missing QR codes.

This MR refactors the signup logic to be role-based. Each user can now register independently for different roles within the same camp. QR codes are generated per registration and used for accurate attendance tracking.

Changes Made

  • Refactored signup logic to support role-based registration
  • Allowed multiple roles per user per camp
  • Updated database queries to check (user_id, camp_id, camp_role)
  • Integrated QR code generation (base64 PNG)
  • Updated signup and signup-status APIs to return QR code
  • Enhanced attendance API to use QR code for precise identification
  • Updated Pydantic schemas to include qr_code field

Technical Details

Root Cause:

  • Signup logic checked only user_id, blocking all roles
  • No separation between roles in registration
  • QR code not linked to specific registration

Fix:

  • Signup now validates based on (user_id, camp_id, role)
  • Each role gets a unique camp_visit_id
  • QR code encodes camp_visit_id for accurate attendance tracking

Architecture:

  • Role-based registration model
  • QR-based attendance using camp_visit_id
  • Independent records per role

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📝 Documentation update
  • ️ Refactor (no functional changes)
  • Performance improvement
  • 🧪 Test update
  • 🔧 Configuration change
  • 🚨 Security fix
  • 🗑️ Deprecation (removing deprecated code)

Related Issues / References

  • Fixes issue where volunteer signup was blocked by coordinator role
  • Fixes incorrect signup-status response
  • Adds support for multi-role users in camps

Screenshots or Screen Recordings

API /signup-status response example:

{ "signup": true, "attendance": false, "qr_code": "<base64_string>" }

How to Validate Locally

  1. Start backend: uvicorn app.main:app --reload

  2. Login as a user

  3. Signup as coordinator

  4. Switch to volunteer role

  5. Click "Signup for Medical Camp"

  6. Verify:

    • signup API returns 200
    • signup-status returns signup: true
  7. Confirm:

    • Redirect to QR page
    • QR code is displayed
  8. Scan QR:

    • Attendance is marked correctly

Testing Done

  • Unit tests added/updated
  • API endpoint tests passing

Test Cases Covered:

Scenario Expected Result Status
Coordinator signup Success
Volunteer signup after coordinator Success
Duplicate same-role signup Blocked
Signup-status accuracy Correct data
QR generation Returned
Attendance via QR Correct record updated

Test Commands Run:

pytest

Code Quality Checklist

Code Standards

  • Code follows project conventions (naming, structure, formatting)
  • No debug statements or commented-out code left
  • No unused imports, variables, or functions
  • No duplicate code (DRY principle followed)
  • Type hints are properly defined

Python & FastAPI Best Practices

  • Functions follow single-responsibility principle
  • Dependency injection used appropriately
  • Pydantic models used for validation
  • SQLAlchemy queries optimized
  • Proper error handling implemented

API Design

  • RESTful conventions followed
  • Proper HTTP status codes returned
  • Input validation implemented
  • Role-based access control handled

Database & Migrations

  • No raw SQL queries used
  • ORM used for queries
  • Data integrity maintained

Security

  • No sensitive data logged
  • SQL injection prevention verified
  • Input validation implemented

Error Handling

  • Errors handled gracefully
  • User-friendly messages returned
  • Logging implemented

Documentation

  • README.md updated
  • API documentation updated via schemas
  • CHANGELOG.md will be updated

Known Limitations / Technical Debt

  • Auto-role selection may assign unintended role if not explicitly provided
  • Frontend must ensure correct role is passed during signup

Additional Notes

  • QR-based attendance ensures accurate role-specific tracking
  • Supports multi-role workflows for the same user

MR Acceptance Checklist

Quality & Correctness

  • Code works as intended and solves the stated problem
  • No bugs introduced
  • Edge cases handled appropriately

Maintainability

  • Code is readable and well-organized
  • Code is testable and well-structured

Acceptance Review

  • Reviewed by at least 1 teammate
  • Reviewed by product owner

Merge request reports

Loading