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

Skip to content

Conversation

@igennova
Copy link
Contributor

@igennova igennova commented Aug 28, 2025

fixes : #4517
image

Summary by CodeRabbit

  • New Features
    • Lab detail page now highlights your completed tasks with a green “Completed” badge and checkmark, making progress easier to track at a glance.
    • Completion status is personalized per user and shown directly within each task row; unfinished tasks remain unchanged for clear differentiation.
  • Chores
    • No other user-facing changes in this release.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 28, 2025

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit 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.

Walkthrough

Compute 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

Cohort / File(s) Summary
Settings tuple normalization
blt/settings.py
In DEBUG, change middleware append from a list literal to a one-element tuple: MIDDLEWARE += ("livereload.middleware.LiveReloadScript",)
Lab detail template badges
website/templates/lab_detail.html
Add conditional rendering of a green “Completed” badge (with checkmark SVG) next to each task’s type badge when task.id is present in completed_task_ids
View: compute completion set
website/views/Simulation.py
In lab_detail, query UserTaskProgress for user=request.user, task__in=tasks, completed=True; extract task_ids into a set and provide completed_task_ids in the template context

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to the DB query correctness and potential N+1 concerns in website/views/Simulation.py.
  • Verify template conditional uses the same ID types (int/str) as returned by the query to avoid mismatches.
✨ 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 ffe9ea4 and 6be73dd.

📒 Files selected for processing (2)
  • blt/settings.py (1 hunks)
  • website/templates/lab_detail.html (1 hunks)

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.

@DonnieBLT DonnieBLT enabled auto-merge August 28, 2025 16:20
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: 0

🧹 Nitpick comments (3)
blt/settings.py (1)

131-133: Tuple append LGTM; add import guard to avoid DEBUG crashes when livereload isn’t installed

Keep 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 tasks

Using 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/accessibility

Switch 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

📥 Commits

Reviewing files that changed from the base of the PR and between 91d857d and ffe9ea4.

📒 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 LGTM

Passing completed_task_ids to the template is correct and matches the template usage.

coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 28, 2025
@DonnieBLT DonnieBLT added this pull request to the merge queue Aug 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 28, 2025
@igennova igennova requested a review from DonnieBLT August 28, 2025 16:32
@DonnieBLT DonnieBLT requested a review from Copilot September 19, 2025 04:06
Copy link
Contributor

Copilot AI left a 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

DonnieBLT
DonnieBLT previously approved these changes Sep 19, 2025
@DonnieBLT DonnieBLT enabled auto-merge September 19, 2025 04:06
auto-merge was automatically disabled September 19, 2025 05:28

Head branch was pushed to by a user without write access

@DonnieBLT DonnieBLT merged commit 4b44873 into OWASP-BLT:main Nov 15, 2025
1 check passed
@DonnieBLT DonnieBLT added the LGTM label Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Completed Badge on Task

2 participants