-
-
Notifications
You must be signed in to change notification settings - Fork 313
feature: Redesign and fix team overview page #4632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds 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
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
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
Estimated code review effortπ― 4 (Complex) | β±οΈ ~60 minutes Pre-merge checks and finishing touchesβ Failed checks (2 warnings)
β Passed checks (3 passed)
β¨ Finishing touches
π§ͺ Generate unit tests (beta)
π Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Knowledge base: Disabled due to π Files selected for processing (1)
π§ Files skipped from review as they are similar to previous changes (1)
β° 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)
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. Comment |
There was a problem hiding this 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 buildingteam_membersCatching every exception here hides real bugs and tripped Ruff BLE001. We only need to cope with missing user profiles, so rely on
getattrinstead 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 payloadThe second blanket
except Exceptionfor avatar resolution raises the same Ruff BLE001 warning. Switching to safegetattrcalls 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 NoneBased 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
π 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
fixes #4631
before:
after:
Summary by CodeRabbit
New Features
UI
Improvements
Refactor