Skip to content

Python Editor#649

Merged
A1L13N merged 3 commits intoalphaonelabs:mainfrom
10done:codeeditor
Jul 9, 2025
Merged

Python Editor#649
A1L13N merged 3 commits intoalphaonelabs:mainfrom
10done:codeeditor

Conversation

@10done
Copy link
Contributor

@10done 10done commented Jul 7, 2025

Related issues

Fixes #648
https://www.loom.com/share/73fffbc346304a5490a9f8df587934ef?sid=81a56261-f994-4783-8174-c4626c325694

Checklist

  • Did you run the pre-commit? (If not, your PR will most likely not pass — please ensure it passes pre-commit)
  • Did you test the change? (Ensure you didn’t just prompt the AI and blindly commit — test the code and confirm it works)
  • Added screenshots to the PR description (if applicable)

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Added an interactive multi-language code editor with syntax highlighting and standard input support.
    • Enabled real-time code execution with output and error display.
    • Introduced a new server endpoint to safely evaluate submitted code.
    • Activated the "Code Editor" navigation link for easy access from the main menu.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 7, 2025

"""

Walkthrough

A code editor feature is introduced, including a Django view and template for the editor interface, JavaScript for client-side code submission using Ace editor, and backend logic to execute submitted code securely with optional input. Navigation is updated to enable access to the editor, and new URL patterns are registered for the editor page and code evaluation endpoint.

Changes

File(s) Change Summary
web/virtual_lab/static/virtual_lab/js/code_editor.js New JS module for Ace-based code editor, code submission, CSRF handling, and response display.
web/virtual_lab/templates/virtual_lab/code_editor/code_editor.html New Django template for interactive code editor page using Ace editor and output display.
web/virtual_lab/templates/virtual_lab/layout.html Updated navigation: "Code Editor" now links to the editor page instead of being a disabled span.
web/virtual_lab/urls.py Added URL patterns for code editor page and code evaluation endpoint; imported corresponding views.
web/virtual_lab/views.py Added code_editor_view for rendering editor page and evaluate_code POST endpoint for running submitted code.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser (JS)
    participant Django Server
    participant Python Executor

    User->>Browser (JS): Enter code, click "Run Code"
    Browser (JS)->>Django Server: POST /evaluate-code/ (code, stdin, CSRF)
    Django Server->>Python Executor: Send code and input to Piston API
    Python Executor-->>Django Server: Return stdout/stderr or error
    Django Server-->>Browser (JS): JSON response (stdout, stderr)
    Browser (JS)-->>User: Display output/errors in UI
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement a code editor UI for Python code (#648)
Allow user to submit code and optional input (#648)
Execute code securely on the backend (#648)
Display output and errors in the frontend (#648)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found.
"""

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @10done, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request delivers a significant new feature: an interactive Python code editor. It provides a complete solution from the user interface, where code can be written and custom input provided, to the backend, which safely executes the code and returns the results. This enhances the application's capabilities by offering a dynamic environment for Python code experimentation.

Highlights

  • New Feature: Interactive Python Editor: This pull request introduces a fully functional interactive Python code editor, allowing users to write, run, and see the output of Python code directly within the web application. This addresses issue #648.
  • Frontend Implementation: The frontend integrates the Ace Editor for a rich code editing experience with Python syntax highlighting. It includes UI elements for code input, custom standard input (stdin), a 'Run Code' button, and a dedicated area to display the execution output (stdout and stderr).
  • Backend Code Execution: A new backend endpoint (/evaluate-code/) has been added to securely execute user-provided Python code. The code is written to a temporary file, executed using subprocess.run with a 5-second timeout, and its stdout/stderr are captured and returned as JSON. The temporary file is always cleaned up after execution.
  • Navigation Integration: The main site navigation (layout.html) has been updated to include an active link to the new 'Code Editor' page, making it easily accessible to users.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new interactive Python code editor, which is a great feature. The implementation covers the frontend UI, JavaScript logic for code submission, and a Django backend for code evaluation.

My review focuses on several key areas: a critical security vulnerability, code correctness, and several opportunities to improve maintainability and security best practices. The most urgent issue is the remote code execution (RCE) vulnerability in the evaluate_code view, which must be addressed before this can be considered for production.

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: 11

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6703d4c and b9e1107.

📒 Files selected for processing (5)
  • web/virtual_lab/static/virtual_lab/js/code_editor.js (1 hunks)
  • web/virtual_lab/templates/virtual_lab/code_editor/code_editor.html (1 hunks)
  • web/virtual_lab/templates/virtual_lab/layout.html (1 hunks)
  • web/virtual_lab/urls.py (2 hunks)
  • web/virtual_lab/views.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{html,jsx,tsx,vue}`: Always use Tailwind CSS classes for styling HTML elem...

**/*.{html,jsx,tsx,vue}: Always use Tailwind CSS classes for styling HTML elements
Never use custom CSS classes
Never use inline styles
Follow the project's color scheme using Tailwind's color classes: Primary: teal-300, Secondary: gray-600, Success: green-600, Warning: yellow-600, Danger: red-600, and use dark mode variants with the dark: prefix
Use 'container mx-auto px-4' for containers
Use 'bg-white dark:bg-gray-800 rounded-lg shadow-lg' for cards
For form inputs, use 'w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500'
For form labels, use 'block text-sm font-medium text-gray-700 dark:text-gray-300'
For primary buttons, use 'bg-teal-300 hover:bg-teal-400 text-white px-6 py-2 rounded-lg transition duration-200'
For secondary buttons, use 'bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300'
For headings, use 'text-2xl font-bold' (adjust size as needed)
For body text, use 'text-gray-600 dark:text-gray-300'
For links, use 'text-blue-600 hover:text-blue-800 dark:text-blue-400'
Use flex and grid for layouts
Use consistent spacing with gap-{size} and space-{y|x}-{size}
Use responsive design with sm:, md:, lg:, xl: prefixes
Always include dark mode alternatives using the dark: prefix
Use dark:bg-gray-800 for card backgrounds
Use dark:text-gray-300 for text
Use proper heading hierarchy
Include proper ARIA labels where needed
Ensure sufficient color contrast
Add hover/focus states for interactive elements

📄 Source: CodeRabbit Inference Engine (.cursorrules)

List of files the instruction was applied to:

  • web/virtual_lab/templates/virtual_lab/code_editor/code_editor.html
  • web/virtual_lab/templates/virtual_lab/layout.html
🧠 Learnings (3)
📓 Common learnings
Learnt from: Abhishek-Punhani
PR: alphaonelabs/alphaonelabs-education-website#337
File: web/templates/courses/detail.html:1506-1560
Timestamp: 2025-04-07T11:33:41.277Z
Learning: For the alphaonelabs-education-website project, the team prefers to keep PRs focused and manageable in size. Additional enhancements like accessibility improvements should be addressed in separate follow-up issues rather than expanding the scope of an existing PR.
web/virtual_lab/urls.py (2)
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: The urls.py file is in the web folder
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: The views.py file is in the web folder
web/virtual_lab/views.py (1)
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: The views.py file is in the web folder
🧬 Code Graph Analysis (2)
web/virtual_lab/urls.py (1)
web/virtual_lab/views.py (2)
  • code_editor_view (80-82)
  • evaluate_code (86-105)
web/virtual_lab/views.py (2)
web/virtual_lab/static/virtual_lab/js/code_editor.js (2)
  • code (26-26)
  • stdin (27-27)
web/virtual_lab/static/virtual_lab/js/common.js (1)
  • name (3-3)
🪛 Ruff (0.11.9)
web/virtual_lab/views.py

80-80: Missing return type annotation for public function code_editor_view

(ANN201)


80-80: Missing type annotation for function argument request

(ANN001)


86-86: Missing return type annotation for public function evaluate_code

(ANN201)


86-86: Missing type annotation for function argument request

(ANN001)


100-100: subprocess call: check for execution of untrusted input

(S603)

🪛 Biome (1.9.4)
web/virtual_lab/static/virtual_lab/js/code_editor.js

[error] 6-6: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)


[error] 54-56: Template literals are preferred over string concatenation.

Unsafe fix: Use a template literal.

(lint/style/useTemplate)

⏰ 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). (6)
  • GitHub Check: build-and-test
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Run Tests
  • GitHub Check: Linting
🔇 Additional comments (2)
web/virtual_lab/templates/virtual_lab/layout.html (1)

32-33: Navigation link activation looks good!

The Code Editor link is properly activated with appropriate hover styling matching the other navigation items.

web/virtual_lab/urls.py (1)

5-6: URL configuration is properly structured.

The new URL patterns follow Django conventions with appropriate naming.

Also applies to: 35-36

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: 4

♻️ Duplicate comments (7)
web/virtual_lab/templates/virtual_lab/code_editor/code_editor.html (4)

26-34: Form elements missing required Tailwind classes

label, select, and textarea should adopt the standard classes (block text-sm font-medium …, w-full px-4 py-2 border …). Update to comply for consistent theming & a11y.

Also applies to: 36-41


45-45: Run button should use primary-button class

Switch to bg-teal-300 hover:bg-teal-400 … per guidelines for visual consistency.


55-58: Avoid leaking globals

Expose the evaluate URL via data-evaluate-url on the button instead of window.* to keep global scope clean.


12-18: Inline styles must be replaced with Tailwind utilities

Inline <style> violates the project guidelines. Apply height/width/border via Tailwind, e.g.

-    <div id="editor">…</div>
+    <div id="editor"
+         class="h-[400px] w-full border border-gray-300 dark:border-gray-600 rounded-lg">…</div>

Remove the whole <style> block.

web/virtual_lab/views.py (2)

97-101: Handle malformed JSON to avoid 500s

json.loads(request.body) will raise JSONDecodeError on bad input. Wrap in try/except and return 400.


88-90: Add type hints for public views

Annotate parameters/returns (HttpRequest, HttpResponse) for maintainability and linting compliance.

Also applies to: 93-93

web/virtual_lab/static/virtual_lab/js/code_editor.js (1)

3-7: Duplicate CSRF helper

getCookie duplicates existing getCSRFToken in common.js; reuse the shared util to avoid drift.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b9e1107 and 0742abb.

📒 Files selected for processing (3)
  • web/virtual_lab/static/virtual_lab/js/code_editor.js (1 hunks)
  • web/virtual_lab/templates/virtual_lab/code_editor/code_editor.html (1 hunks)
  • web/virtual_lab/views.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{html,jsx,tsx,vue}`: Always use Tailwind CSS classes for styling HTML elem...

**/*.{html,jsx,tsx,vue}: Always use Tailwind CSS classes for styling HTML elements
Never use custom CSS classes
Never use inline styles
Follow the project's color scheme using Tailwind's color classes: Primary: teal-300, Secondary: gray-600, Success: green-600, Warning: yellow-600, Danger: red-600, and use dark mode variants with the dark: prefix
Use 'container mx-auto px-4' for containers
Use 'bg-white dark:bg-gray-800 rounded-lg shadow-lg' for cards
For form inputs, use 'w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500'
For form labels, use 'block text-sm font-medium text-gray-700 dark:text-gray-300'
For primary buttons, use 'bg-teal-300 hover:bg-teal-400 text-white px-6 py-2 rounded-lg transition duration-200'
For secondary buttons, use 'bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300'
For headings, use 'text-2xl font-bold' (adjust size as needed)
For body text, use 'text-gray-600 dark:text-gray-300'
For links, use 'text-blue-600 hover:text-blue-800 dark:text-blue-400'
Use flex and grid for layouts
Use consistent spacing with gap-{size} and space-{y|x}-{size}
Use responsive design with sm:, md:, lg:, xl: prefixes
Always include dark mode alternatives using the dark: prefix
Use dark:bg-gray-800 for card backgrounds
Use dark:text-gray-300 for text
Use proper heading hierarchy
Include proper ARIA labels where needed
Ensure sufficient color contrast
Add hover/focus states for interactive elements

📄 Source: CodeRabbit Inference Engine (.cursorrules)

List of files the instruction was applied to:

  • web/virtual_lab/templates/virtual_lab/code_editor/code_editor.html
🧠 Learnings (3)
📓 Common learnings
Learnt from: Abhishek-Punhani
PR: alphaonelabs/alphaonelabs-education-website#337
File: web/templates/courses/detail.html:1506-1560
Timestamp: 2025-04-07T11:33:41.277Z
Learning: For the alphaonelabs-education-website project, the team prefers to keep PRs focused and manageable in size. Additional enhancements like accessibility improvements should be addressed in separate follow-up issues rather than expanding the scope of an existing PR.
web/virtual_lab/views.py (2)
Learnt from: bits-and-atoms
PR: alphaonelabs/alphaonelabs-education-website#415
File: web/views.py:6984-7020
Timestamp: 2025-04-02T19:25:04.859Z
Learning: When implementing exception handling, replace generic `except Exception:` blocks with specific exception types based on the operations in the try block. For example:
- Use `except (ValueError, TypeError)` for data processing errors
- Use `except (requests.RequestException, ConnectionError)` for network operations
- Use `except DatabaseError` for database operations
- Always add logging with the specific error message using `logger.exception(f"Error message: {str(e)}")`
- Maintain a fallback `except Exception as e:` with detailed logging for unexpected errors
Learnt from: IITI-tushar
PR: alphaonelabs/alphaonelabs-education-website#264
File: web/views.py:3825-3848
Timestamp: 2025-03-30T09:52:47.021Z
Learning: In Django form handling, error messages like `messages.error(request, "Please correct the errors below.")` should be placed inside the `else` clause of a `form.is_valid()` check to ensure they only appear when the form has validation errors.
web/virtual_lab/templates/virtual_lab/code_editor/code_editor.html (18)
Learnt from: IITI-tushar
PR: alphaonelabs/alphaonelabs-education-website#0
File: :0-0
Timestamp: 2025-03-26T22:03:07.847Z
Learning: The alphaonelabs-education-website optimizes external resource loading by using preconnect links for external domains and adding defer/async attributes to JavaScript files to improve parsing and execution timing.
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : For form labels, use 'block text-sm font-medium text-gray-700 dark:text-gray-300'
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : For form inputs, use 'w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg focus:ring-2 focus:ring-blue-500'
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : Include proper ARIA labels where needed
Learnt from: Legacywave1
PR: alphaonelabs/alphaonelabs-education-website#457
File: web/templates/base.html:149-357
Timestamp: 2025-04-05T16:36:48.539Z
Learning: In the alphaonelabs-education-website project, avoid using nested CSS syntax like `.dark & {}` which is only valid in preprocessors like SCSS. Instead, use standard CSS selectors like `.dark .element-class {}` since the website appears to use standard CSS.
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : Use 'bg-white dark:bg-gray-800 rounded-lg shadow-lg' for cards
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : For secondary buttons, use 'bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300'
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : For headings, use 'text-2xl font-bold' (adjust size as needed)
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : For primary buttons, use 'bg-teal-300 hover:bg-teal-400 text-white px-6 py-2 rounded-lg transition duration-200'
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : Follow the project's color scheme using Tailwind's color classes: Primary: teal-300, Secondary: gray-600, Success: green-600, Warning: yellow-600, Danger: red-600, and use dark mode variants with the dark: prefix
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : For links, use 'text-blue-600 hover:text-blue-800 dark:text-blue-400'
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : Use dark:text-gray-300 for text
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : Always include dark mode alternatives using the dark: prefix
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : Use dark:bg-gray-800 for card backgrounds
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : Ensure sufficient color contrast
Learnt from: Inshamhaque
PR: alphaonelabs/alphaonelabs-education-website#279
File: web/static/js/classes_map.js:0-0
Timestamp: 2025-03-24T20:02:40.021Z
Learning: In Django applications with i18n enabled, static assets referenced in JavaScript files should use absolute paths (starting with '/') rather than relative paths to prevent URL resolution issues when accessed from localized URLs (e.g., /en/some-page/).
Learnt from: IITI-tushar
PR: alphaonelabs/alphaonelabs-education-website#79
File: web/forms.py:1186-1186
Timestamp: 2025-03-20T11:51:16.027Z
Learning: The codebase provides custom Tailwind widgets in web/forms.py that should be used instead of standard Django form widgets with manual Tailwind CSS classes. Available widgets include: TailwindInput, TailwindTextarea, TailwindSelect, TailwindDateTimeInput, TailwindEmailInput, TailwindFileInput, TailwindNumberInput, TailwindCheckboxInput, and TailwindCaptchaTextInput.
Learnt from: CR
PR: alphaonelabs/alphaonelabs-education-website#0
File: .cursorrules:0-0
Timestamp: 2025-07-04T20:33:32.533Z
Learning: Applies to **/*.{html,jsx,tsx,vue} : Never use inline styles
🪛 Ruff (0.11.9)
web/virtual_lab/views.py

77-77: Comment contains ambiguous (RIGHT SINGLE QUOTATION MARK). Did you mean ``` (GRAVE ACCENT)?

(RUF003)


88-88: Missing return type annotation for public function code_editor_view

(ANN201)


88-88: Missing type annotation for function argument request

(ANN001)


93-93: Missing return type annotation for public function evaluate_code

(ANN201)


93-93: Missing type annotation for function argument request

(ANN001)


127-127: Trailing comma missing

Add trailing comma

(COM812)

🪛 GitHub Check: CodeQL
web/virtual_lab/views.py

[warning] 117-117: Information exposure through an exception
Stack trace information flows to this location and may be exposed to an external user.

web/virtual_lab/templates/virtual_lab/code_editor/code_editor.html

[warning] 7-7: Inclusion of functionality from an untrusted source
Script loaded from content delivery network with no integrity check.

⏰ 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). (4)
  • GitHub Check: Run Tests
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: build-and-test

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 8, 2025
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: 2

♻️ Duplicate comments (2)
web/virtual_lab/views.py (2)

100-103: Add JSON parsing error handling

The code doesn't handle malformed JSON payloads, which could cause 500 errors for invalid requests.

-    data = json.loads(request.body)
+    try:
+        data = json.loads(request.body)
+    except json.JSONDecodeError:
+        return JsonResponse({"error": "Invalid JSON payload"}, status=400)

91-92: Add type annotations for better maintainability

The function lacks proper type annotations as noted by static analysis.

+from django.http import HttpRequest, HttpResponse
+
-def code_editor_view(request):
+def code_editor_view(request: HttpRequest) -> HttpResponse:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0742abb and 97a05c0.

📒 Files selected for processing (1)
  • web/virtual_lab/views.py (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Abhishek-Punhani
PR: alphaonelabs/alphaonelabs-education-website#337
File: web/templates/courses/detail.html:1506-1560
Timestamp: 2025-04-07T11:33:41.277Z
Learning: For the alphaonelabs-education-website project, the team prefers to keep PRs focused and manageable in size. Additional enhancements like accessibility improvements should be addressed in separate follow-up issues rather than expanding the scope of an existing PR.
web/virtual_lab/views.py (3)
Learnt from: bits-and-atoms
PR: alphaonelabs/alphaonelabs-education-website#415
File: web/views.py:6984-7020
Timestamp: 2025-04-02T19:25:04.859Z
Learning: When implementing exception handling, replace generic `except Exception:` blocks with specific exception types based on the operations in the try block. For example:
- Use `except (ValueError, TypeError)` for data processing errors
- Use `except (requests.RequestException, ConnectionError)` for network operations
- Use `except DatabaseError` for database operations
- Always add logging with the specific error message using `logger.exception(f"Error message: {str(e)}")`
- Maintain a fallback `except Exception as e:` with detailed logging for unexpected errors
Learnt from: IITI-tushar
PR: alphaonelabs/alphaonelabs-education-website#264
File: web/views.py:3825-3848
Timestamp: 2025-03-30T09:52:47.021Z
Learning: In Django form handling, error messages like `messages.error(request, "Please correct the errors below.")` should be placed inside the `else` clause of a `form.is_valid()` check to ensure they only appear when the form has validation errors.
Learnt from: Abhishek-Punhani
PR: alphaonelabs/alphaonelabs-education-website#337
File: web/templates/courses/detail.html:1506-1560
Timestamp: 2025-04-07T11:33:41.277Z
Learning: For the alphaonelabs-education-website project, the team prefers to keep PRs focused and manageable in size. Additional enhancements like accessibility improvements should be addressed in separate follow-up issues rather than expanding the scope of an existing PR.
🪛 Ruff (0.11.9)
web/virtual_lab/views.py

80-80: Comment contains ambiguous (RIGHT SINGLE QUOTATION MARK). Did you mean ``` (GRAVE ACCENT)?

(RUF003)


91-91: Missing return type annotation for public function code_editor_view

(ANN201)


91-91: Missing type annotation for function argument request

(ANN001)


96-96: Missing return type annotation for public function evaluate_code

(ANN201)


96-96: Missing type annotation for function argument request

(ANN001)


124-124: Trailing comma missing

Add trailing comma

(COM812)


135-135: Trailing comma missing

Add trailing comma

(COM812)

⏰ 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). (6)
  • GitHub Check: Linting
  • GitHub Check: Run Tests
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (python)
  • GitHub Check: Analyze (actions)
  • GitHub Check: build-and-test
🔇 Additional comments (3)
web/virtual_lab/views.py (3)

3-11: LGTM: Clean import organization

The new imports are properly organized and necessary for the code editor functionality. The logging setup follows best practices.


116-125: LGTM: Proper exception handling and security

Excellent work switching from subprocess to the Piston API! The exception handling properly logs errors server-side while returning generic error messages to clients, preventing information leakage.


127-136: LGTM: Clean JSON response handling

The response parsing and JSON formatting is well-implemented, correctly extracting stdout/stderr from the Piston API response structure.

@A1L13N A1L13N added this pull request to the merge queue Jul 9, 2025
Merged via the queue into alphaonelabs:main with commit 45973f5 Jul 9, 2025
11 checks passed
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.

Code Editor Feature

2 participants