Skip to content

feat: implement user authentication models, serializers, and registra…#231

Merged
Joshkovu merged 1 commit into
mainfrom
chore/clean-internshipAdmin
May 2, 2026
Merged

feat: implement user authentication models, serializers, and registra…#231
Joshkovu merged 1 commit into
mainfrom
chore/clean-internshipAdmin

Conversation

@Joshkovu
Copy link
Copy Markdown
Owner

@Joshkovu Joshkovu commented May 2, 2026

…tion logic for students, supervisors, and admins

…tion logic for students, supervisors, and admins
Copilot AI review requested due to automatic review settings May 2, 2026 09:49
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 62355239-d5b8-4e6a-93fe-08ffd6cdd684

📥 Commits

Reviewing files that changed from the base of the PR and between 0613e04 and 6e69972.

📒 Files selected for processing (7)
  • logify-backend/apps/academics/migrations/0004_alter_colleges_id_alter_departments_id_and_more.py
  • logify-backend/apps/academics/test_academics.py
  • logify-backend/apps/accounts/migrations/0007_supervisorapplication_college_alter_staffprofiles_id_and_more.py
  • logify-backend/apps/accounts/models.py
  • logify-backend/apps/accounts/serializers.py
  • logify-backend/apps/accounts/test_auth.py
  • logify-backend/apps/accounts/views.py
💤 Files with no reviewable changes (1)
  • logify-backend/apps/academics/test_academics.py

Summary by CodeRabbit

Release Notes

  • New Features

    • Supervisor applications now support college association and management within institutional hierarchies.
  • Bug Fixes

    • Enhanced permission enforcement for supervisor approval with college-level scope validation.
  • Tests

    • Updated test coverage for supervisor workflows with improved college context handling.
  • Chores

    • Updated database schema with standardized ID field definitions across core models.

Walkthrough

This pull request adds college-based access control to supervisor application workflows. It updates model ID fields to use Django's AutoField, adds a college relationship to SupervisorApplication, and implements college-scoped filtering in approval and listing endpoints alongside existing institution-level controls.

Changes

College-Scoped Supervisor Applications

Layer / File(s) Summary
Schema Foundation
logify-backend/apps/academics/migrations/0004_alter_colleges_id_alter_departments_id_and_more.py
Academics models (Colleges, Departments, Institutions, Programmes) have their id fields altered to explicit AutoField primary keys.
Data Model
logify-backend/apps/accounts/models.py
SupervisorApplication gains a nullable ForeignKey to academics.Colleges with SET_NULL on delete.
Migration & Schema
logify-backend/apps/accounts/migrations/0007_supervisorapplication_college_alter_staffprofiles_id_and_more.py
Accounts migration adds the college field to SupervisorApplication and updates id fields for StaffProfiles, SupervisorApplication, and User to AutoField.
Serialization
logify-backend/apps/accounts/serializers.py
SupervisorApplicationSerializer includes "college" in serialized fields; signup creation now passes college when creating SupervisorApplication records.
Access Control & Scoping
logify-backend/apps/accounts/views.py
SupervisorApprovalView.post enforces college-scope validation in addition to institution scope; SupervisorApplicationListView.get_queryset filters by both institution and college for non-superusers.
Tests & Fixtures
logify-backend/apps/accounts/test_auth.py, logify-backend/apps/academics/test_academics.py
Supervisor test fixtures updated to include college and StaffProfiles associations; removed a now-redundant admin institution access test from academics tests.

Sequence Diagram

sequenceDiagram
    actor Admin as Admin User
    participant View as SupervisorApprovalView
    participant DB as Database
    
    Admin->>View: POST approve supervisor application
    activate View
    
    Note over View: Retrieve admin's StaffProfile
    View->>DB: Query StaffProfiles for admin
    DB-->>View: StaffProfile with department & college
    
    Note over View: Check institution scope
    View->>DB: Verify application institution match
    DB-->>View: Institution OK
    
    Note over View: Check college scope (new)
    View->>DB: Extract admin_college_id from StaffProfile
    alt College present on application
        View->>DB: Verify application.college_id == admin_college_id
        DB-->>View: College match verified
    else College not required
        View->>View: Proceed without college check
    end
    
    alt Permission granted
        View->>DB: Update application.status = "approved"
        DB-->>View: Success
        View-->>Admin: 200 OK
    else Permission denied
        View-->>Admin: 403 Forbidden
    end
    deactivate View
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

A supervisor's college is claimed at last,
With scopes and approvals holding fast,
No more wild roaming across the land—
Each admin approves only what they've planned! 🐰✨


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Review rate limit: 2/3 reviews remaining, refill in 20 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying logify-frontend with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6e69972
Status: ✅  Deploy successful!
Preview URL: https://b4f60834.logify-frontend.pages.dev
Branch Preview URL: https://chore-clean-internshipadmin.logify-frontend.pages.dev

View logs

@Joshkovu Joshkovu merged commit 06e7a9d into main May 2, 2026
11 checks passed
@Joshkovu Joshkovu review requested due to automatic review settings May 2, 2026 10:11
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