Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rinkitadhana
Copy link
Contributor

@rinkitadhana rinkitadhana commented Oct 15, 2025

fixes #4631

before:

image

after:

image

Summary by CodeRabbit

  • New Features

    • Interactive Team Overview: tabbed filters (user/date/goal/task), debounced task search, expandable report rows, loading and friendly empty states.
  • UI

    • Redesigned header with Team Overview title and Add Member action; modernized Members and Daily Status Reports tables with avatars, status chips, and action links.
  • Improvements

    • More reliable data loading, clearer error handling, consistent report ordering, and accurate member listings.
  • Refactor

    • Backend view and request handling streamlined for improved robustness.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Walkthrough

Adds a new external client-side script and template markup for the Team Overview page, and refactors the server-side team overview view to gather members from organization admins/managers, streamline report querying and AJAX filtering, and add HTTP/login decorators on several endpoints.

Changes

Cohort / File(s) Summary of Changes
Client script
website/static/js/organization_team_overview.js
New JS: tab switching, filter panels, debounced task search, AJAX fetch with X-Requested-With and request-id handling, loading/error/empty states, HTML-escaped table rendering, expandable long-text cells, global toggleRow(row).
Template changes
website/templates/organization/dashboard/organization_team_overview.html
Replaced prior inline layout with a new Team Overview template: header and actions, Organization Members table (avatars, status chips, actions), Daily Status Reports section with tabbed filters (user/date/goal/task), empty-state UI, and external JS inclusion. Removed inline scripts and legacy table markup.
View refactor and HTTP semantics
website/views/company.py
Refactored OrganizationDashboardTeamOverviewView.get() to build team members from organization admins/managers (de-duplicated, ordered), simplified report queries (ordered by date), moved AJAX filtering handling into view context with improved logging/error handling, and added/moved HTTP method and login decorators to multiple endpoints.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant B as Browser UI
  participant JS as organization_team_overview.js
  participant S as Django View (Team Overview)
  participant DB as Database

  U->>B: Open Team Overview page
  B->>JS: DOMContentLoaded -> init (tabs, filters)
  JS->>S: GET /team-overview?tab=user (X-Requested-With, request-id)
  S->>DB: Query reports (filters, ordered by date)
  DB-->>S: Reports JSON
  S-->>JS: JSON response
  JS->>B: updateTable() -> render rows or empty state

  U->>B: Switch tab / change filter
  B->>JS: filter event (debounced for task)
  JS->>S: GET /team-overview?... (AJAX with params, request-id)
  S->>DB: Filtered query
  DB-->>S: Results / error
  S-->>JS: JSON / error
  JS->>B: Update table or show error state
Loading
sequenceDiagram
  autonumber
  participant JS as organization_team_overview.js
  participant DOM as Table/UI
  Note over JS,DOM: Expandable long-text cells (previous/next/blockers)
  JS->>DOM: Render truncated content with "Show more"
  DOM-->>JS: click toggleRow(row)
  JS->>DOM: Toggle visibility of short/full content
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The pull request introduces unrelated modifications in website/views/company.py, such as adding decorators and renaming or moving functions for bughunt and prize operations, which do not pertain to fixing or redesigning the team overview page. Please isolate or remove the unrelated decorator additions and method refactors into a separate pull request so that this change set remains focused on the team overview redesign and fixes.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
βœ… Passed checks (3 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check βœ… Passed The title succinctly states that this pull request delivers a redesign and fixes for the team overview page, directly reflecting the primary changes in templates, client-side scripts, and view logic without extraneous detail.
Linked Issues Check βœ… Passed The pull request fully implements the linked issue #4631 by refactoring the organization dashboard view to correctly gather team members, updating the HTML and client-side JavaScript for the redesigned Team Overview layout, and enabling the intended filtering and display fixes.
✨ Finishing touches
  • πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

πŸ“œ Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 42a3dc6 and 8432ff7.

πŸ“’ Files selected for processing (1)
  • website/static/js/organization_team_overview.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • website/static/js/organization_team_overview.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run Tests
  • GitHub Check: docker-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
website/views/company.py (2)

563-590: Avoid blanket exception handling when building team_members

Catching every exception here hides real bugs and tripped Ruff BLE001. We only need to cope with missing user profiles, so rely on getattr instead of swallowing everything.

-        team_members = []
-        for user in team_member_users:
-            try:
-                profile = user.userprofile
-                # Create a wrapper object with expected attributes
-                member_data = type(
-                    "obj",
-                    (object,),
-                    {
-                        "user": user,
-                        "user_avatar": profile.user_avatar if hasattr(profile, "user_avatar") else None,
-                        "role": "Admin" if user == organization_obj.admin else "Manager",
-                    },
-                )()
-                team_members.append(member_data)
-            except Exception:
-                # If userprofile doesn't exist, create basic member data
-                member_data = type(
-                    "obj",
-                    (object,),
-                    {
-                        "user": user,
-                        "user_avatar": None,
-                        "role": "Admin" if user == organization_obj.admin else "Manager",
-                    },
-                )()
-                team_members.append(member_data)
+        team_members = []
+        for user in team_member_users:
+            profile = getattr(user, "userprofile", None)
+            avatar = getattr(profile, "user_avatar", None) if profile else None
+            member_data = type(
+                "obj",
+                (object,),
+                {
+                    "user": user,
+                    "user_avatar": avatar,
+                    "role": "Admin" if user == organization_obj.admin else "Manager",
+                },
+            )()
+            team_members.append(member_data)

Based on static analysis hints


618-637: Tighten avatar lookup in the AJAX payload

The second blanket except Exception for avatar resolution raises the same Ruff BLE001 warning. Switching to safe getattr calls keeps the code resilient to missing profiles without erasing unexpected errors (and keeps the log noise down).

-                try:
-                    avatar_url = (
-                        report.user.userprofile.user_avatar.url if report.user.userprofile.user_avatar else None
-                    )
-                except Exception as e:
-                    logger.warning(f"Error getting avatar for user {report.user.username}: {e}")
-                    avatar_url = None
+                user_profile = getattr(report.user, "userprofile", None)
+                avatar_field = getattr(user_profile, "user_avatar", None) if user_profile else None
+                avatar_url = avatar_field.url if avatar_field else None

Based on static analysis hints

πŸ“œ Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 82ad67c and 42a3dc6.

πŸ“’ Files selected for processing (3)
  • website/static/js/organization_team_overview.js (1 hunks)
  • website/templates/organization/dashboard/organization_team_overview.html (1 hunks)
  • website/views/company.py (1 hunks)
🧰 Additional context used
πŸͺ› Ruff (0.14.0)
website/views/company.py

578-578: Do not catch blind exception: Exception

(BLE001)


622-622: Do not catch blind exception: Exception

(BLE001)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Run Tests
  • GitHub Check: docker-test

@DonnieBLT DonnieBLT merged commit 1ddd95a into OWASP-BLT:main Oct 15, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix team overview page on organization dashboard

2 participants