Skip to content

Refactor code for improved readability and#227

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

Refactor code for improved readability and#227
Joshkovu merged 1 commit into
mainfrom
chore/clean-internshipAdmin

Conversation

@Joshkovu
Copy link
Copy Markdown
Owner

@Joshkovu Joshkovu commented May 1, 2026

maintainability across multiple files

maintainability across multiple files
Copilot AI review requested due to automatic review settings May 1, 2026 08:15
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 2fa1c588-8556-45ba-a5ba-9a7039a1cbff

📥 Commits

Reviewing files that changed from the base of the PR and between 307c6d1 and a2c150d.

📒 Files selected for processing (7)
  • logify-backend/apps/accounts/test_user_detail.py
  • logify-backend/apps/evaluations/migrations/0004_auto_20260429_2011.py
  • logify-backend/apps/evaluations/test_evaluation.py
  • logify-backend/apps/evaluations/views.py
  • logify-frontend/src/pages/dashboards/InternshipAdmin/pages/Dashboard.jsx
  • logify-frontend/src/pages/dashboards/InternshipAdmin/pages/Students.jsx
  • logify-frontend/src/tests/setupTests.js

Summary by CodeRabbit

  • New Features

    • Implemented college-scoped access control for internship administrators—users now see only evaluation records, scores, and results from their assigned college.
  • Tests

    • Added comprehensive test suite validating college-scoped data visibility for internship admins across list endpoints and cross-college record retrieval scenarios.

Walkthrough

The pull request implements college-scoped data visibility for internship admin users by restricting evaluations, evaluation scores, and final results queries based on the admin's institution and associated programme. A new access control helper function is introduced, comprehensive test coverage validates the scoping behavior across multiple colleges, and formatting adjustments standardize code style throughout the codebase.

Changes

Cohort / File(s) Summary
College-Scoped Access Control
logify-backend/apps/evaluations/views.py
Introduces get_admin_college_placement_filter() helper to restrict evaluation-related queries to records matching the admin's college and programme scope; replaces unconditional "all" results for internship admins with placement-based filtering; adds superuser override for full access.
Access Control Test Suite
logify-backend/apps/evaluations/test_evaluation.py
Adds comprehensive test suite validating college-scoped visibility for internship admin users; verifies list endpoints return college-filtered results, cross-college record retrieval returns 404, and score filtering respects evaluation ownership boundaries.
Backend Migrations & Formatting
logify-backend/apps/evaluations/migrations/0004_auto_20260429_2011.py, logify-backend/apps/accounts/test_user_detail.py
Requotes Django model lookups to double-quoted strings and reformats migration function calls; adds trailing comma to function argument for style consistency.
Frontend UI Formatting
logify-frontend/src/pages/dashboards/InternshipAdmin/pages/Dashboard.jsx, logify-frontend/src/pages/dashboards/InternshipAdmin/pages/Students.jsx
Reformats filter predicates and destructuring patterns into single-line arrow functions and consistent spacing; no functional logic changes.
Test Infrastructure
logify-frontend/src/tests/setupTests.js
Adds Jest module mock for react-toastify to suppress toast UI rendering in tests and capture toast method calls for test validation.

Sequence Diagram

sequenceDiagram
    participant User
    participant Views as Views Layer
    participant Filter as Access Control
    participant DB as Database
    
    User->>Views: Request evaluation list (as internship_admin)
    Views->>Filter: get_admin_college_placement_filter(user)
    
    alt User is Superuser
        Filter-->>Views: Return all() queryset
    else Internship Admin with College
        Filter->>Filter: Extract institution, admin_college, programme_ids
        Filter-->>Views: Return placement filter dict
    else No Valid Scope
        Filter-->>Views: Return None
    end
    
    alt Filter result is None
        Views->>DB: Return none() queryset
        DB-->>Views: Empty result
    else Filter result exists
        Views->>DB: Apply college/programme constraints
        DB-->>Views: Filtered evaluations
    end
    
    Views-->>User: Scoped evaluation data
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hoppy hops through college gates with glee,
Each admin sees just what they ought to see!
With filters fresh and tests so bright,
Access control is done just right!


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: a2c150d
Status: ✅  Deploy successful!
Preview URL: https://a442cce5.logify-frontend.pages.dev
Branch Preview URL: https://chore-clean-internshipadmin.logify-frontend.pages.dev

View logs

@Joshkovu Joshkovu merged commit ed97f97 into main May 1, 2026
8 of 9 checks passed
@Joshkovu Joshkovu review requested due to automatic review settings May 1, 2026 08:37
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