-
-
Notifications
You must be signed in to change notification settings - Fork 313
(fix) docker image issue and completed enhancement in lab #4516
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
|
Caution Review failedThe pull request is closed. Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughCompute per-user completed task IDs in the lab view and pass them to the template to render a “Completed” badge for finished tasks; also change middleware concatenation in DEBUG to use a one-element tuple. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant View as lab_detail View
participant DB as UserTaskProgress
participant Tmpl as lab_detail Template
User->>View: GET /lab/<id> (authenticated)
View->>DB: Query completed tasks (user, task__in=tasks, completed=True)
DB-->>View: List of completed task IDs
View->>Tmpl: Render with context { completed_task_ids }
Tmpl-->>User: HTML showing "Completed" badges for matching tasks
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
✨ 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 (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: 0
🧹 Nitpick comments (3)
blt/settings.py (1)
131-133: Tuple append LGTM; add import guard to avoid DEBUG crashes when livereload isn’t installedKeep the tuple change. To prevent startup errors in Docker/dev environments lacking django-livereload-server, gate both app and middleware on importability.
# Replace the separate INSTALLED_APPS/MIDDLEWARE additions with this guarded block if DEBUG: try: import livereload # dev-only except ImportError: pass else: INSTALLED_APPS += ("livereload",) MIDDLEWARE += ("livereload.middleware.LiveReloadScript",)website/views/Simulation.py (1)
54-58: Computation is correct; simplify the query to avoid subquery on tasksUsing task__lab_id is a bit leaner than task__in=tasks while preserving semantics.
- completed_task_ids = set( - UserTaskProgress.objects.filter(user=request.user, task__in=tasks, completed=True).values_list( - "task_id", flat=True - ) - ) + completed_task_ids = set( + UserTaskProgress.objects.filter( + user=request.user, + task__lab_id=lab_id, + task__is_active=True, + completed=True, + ).values_list("task_id", flat=True) + )website/templates/lab_detail.html (1)
92-99: Badge works; prefer Tailwind palette, currentColor, and aria-hidden for consistency/accessibilitySwitch to framework colors and make the icon inherit text color.
- {% if completed_task_ids and task.id in completed_task_ids %} - <span class="ml-2 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-[#2ecc71] text-[#000000]"> - <svg class="w-4 h-4 mr-1" fill="none" stroke="#27ae60" viewBox="0 0 24 24"> - <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path> - </svg> - Completed - </span> - {% endif %} + {% if completed_task_ids and task.id in completed_task_ids %} + <span class="ml-2 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800"> + <svg class="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true"> + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path> + </svg> + Completed + </span> + {% endif %}
📜 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)
blt/settings.py(1 hunks)website/templates/lab_detail.html(1 hunks)website/views/Simulation.py(1 hunks)
⏰ 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). (1)
- GitHub Check: Run Tests
🔇 Additional comments (1)
website/views/Simulation.py (1)
63-64: Context wiring LGTMPassing completed_task_ids to the template is correct and matches the template usage.
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.
Pull Request Overview
This PR enhances the lab detail page by showing completed tasks with green badges and checkmarks, providing visual feedback for user progress. It also fixes a Docker image issue by converting a middleware list concatenation from list addition to tuple addition.
- Adds visual indicators for completed tasks in the lab detail view
- Fetches user task completion status and passes it to the template
- Fixes middleware configuration for proper Docker deployment
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| website/views/Simulation.py | Queries user task completion status and adds it to template context |
| website/templates/lab_detail.html | Displays green "Completed" badges with checkmarks for finished tasks |
| blt/settings.py | Fixes middleware concatenation from list to tuple for Docker compatibility |
Co-authored-by: Copilot <[email protected]>
Head branch was pushed to by a user without write access
0d3123f
fixes : #4517

Summary by CodeRabbit