Skip to content

Allow forum posts to link to GitHub issue or milestoneForum issues#506

Closed
10done wants to merge 97 commits intoalphaonelabs:mainfrom
10done:ForumIssues
Closed

Allow forum posts to link to GitHub issue or milestoneForum issues#506
10done wants to merge 97 commits intoalphaonelabs:mainfrom
10done:ForumIssues

Conversation

@10done
Copy link
Contributor

@10done 10done commented Apr 8, 2025

Fixes #463

I implemented this by wrapping the GitHub issue and milestone links in a flex container using Tailwind CSS utility classes, which allowed me to horizontally align the icons and text uniformly. By applying classes like "mt-4 flex items-center space-x-4" to the container and "inline-flex items-center" to each link, I ensured consistent spacing and alignment, resulting in a cleaner and more organized appearance on the forum page.

forum.Issues.mp4

Summary by CodeRabbit

  • New Features

    • Enabled GitHub integration by adding optional fields for linking issues and milestones in forum topics.
    • Introduced a dedicated view for displaying topic details with integrated GitHub links.
  • Bug Fixes

    • Implemented validation for GitHub URLs to ensure correct formatting and provide user feedback.
  • Style

    • Updated form interfaces for creating and editing topics.
    • Refined breadcrumb navigation and adjusted layout, including removal of redundant links, for a cleaner user experience.

10done and others added 30 commits March 23, 2025 17:07
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 91dc912 and f6905eb.

📒 Files selected for processing (2)
  • web/templates/web/forum/topic.html (2 hunks)
  • web/views.py (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
web/views.py (1)
web/models.py (2)
  • ForumTopic (789-808)
  • ForumCategory (765-786)
🪛 Ruff (0.8.2)
web/views.py

1894-1894: Missing return type annotation for public function topic_detail

(ANN201)


1894-1894: Missing type annotation for function argument request

(ANN001)


1894-1894: Missing type annotation for function argument topic_id

(ANN001)


1901-1901: Missing return type annotation for public function peer_connections

(ANN201)


1901-1901: Missing type annotation for function argument request

(ANN001)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-and-test
  • GitHub Check: Run Tests
🔇 Additional comments (3)
web/templates/web/forum/topic.html (1)

95-96: Optimized Edit Link Layout
The "Edit" link now cleanly aligns the FontAwesome icon with its text, which improves the visual consistency and usability of the interface.

web/views.py (2)

1880-1881: Good job adding GitHub URL support to the topic creation!

These lines properly retrieve and pass the GitHub issue and milestone URLs from the form to the ForumTopic creation, allowing forum topics to link to GitHub resources as intended.


1893-1906: Well-implemented topic_detail function with type hints and view counter.

You've created a new view function with proper type annotations and implemented view counting correctly. This provides a direct way to access forum topics by ID without needing the category slug in the URL path.

One note: Unlike the existing forum_topic function (lines 1830-1863), this one doesn't handle POST requests for replies or topic deletion. If that's intentional, it's fine, but if users should be able to add replies from this view as well, you'll need to add similar POST handling logic.

🧰 Tools
🪛 Ruff (0.8.2)

1894-1894: Missing return type annotation for public function topic_detail

(ANN201)


1894-1894: Missing type annotation for function argument request

(ANN001)


1894-1894: Missing type annotation for function argument topic_id

(ANN001)


1901-1901: Missing return type annotation for public function peer_connections

(ANN201)


1901-1901: Missing type annotation for function argument request

(ANN001)

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

♻️ Duplicate comments (1)
web/views.py (1)

1894-1906: ⚠️ Potential issue

Consider adding type hints for better code quality.

The new view function correctly handles displaying a topic by ID and increments the view count similar to the existing forum_topic function. However, you should add type annotations as suggested by the static analysis tool:

@login_required
-def topic_detail(request, topic_id):
+def topic_detail(request: HttpRequest, topic_id: int) -> HttpResponse:
    topic = get_object_or_404(ForumTopic, id=topic_id)
    categories = ForumCategory.objects.all()

    # Increment view count
    view_count = (
        WebRequest.objects.filter(path=request.path).aggregate(total_views=models.Sum("count"))["total_views"] or 0
    )
    topic.views = view_count
    topic.save()

    return render(request, "web/forum/topic.html", {"topic": topic, "categories": categories})
🧰 Tools
🪛 Ruff (0.8.2)

1894-1894: Missing return type annotation for public function topic_detail

(ANN201)


1894-1894: Missing type annotation for function argument request

(ANN001)


1894-1894: Missing type annotation for function argument topic_id

(ANN001)


1901-1901: Missing return type annotation for public function peer_connections

(ANN201)


1901-1901: Missing type annotation for function argument request

(ANN001)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f6905eb and 136efba.

📒 Files selected for processing (2)
  • web/templates/web/forum/topic.html (2 hunks)
  • web/views.py (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
web/views.py (1)
web/models.py (2)
  • ForumTopic (789-808)
  • ForumCategory (765-786)
🪛 Ruff (0.8.2)
web/views.py

1894-1894: Missing return type annotation for public function topic_detail

(ANN201)


1894-1894: Missing type annotation for function argument request

(ANN001)


1894-1894: Missing type annotation for function argument topic_id

(ANN001)


1901-1901: Missing return type annotation for public function peer_connections

(ANN201)


1901-1901: Missing type annotation for function argument request

(ANN001)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Run Tests
  • GitHub Check: build-and-test
🔇 Additional comments (2)
web/templates/web/forum/topic.html (1)

92-97: Consistent Edit Link Formatting
The edit link is now formatted using inline-flex, ensuring that the FontAwesome icon and the "Edit" text are neatly aligned on the same line. This minor adjustment improves visual consistency and overall layout clarity when the topic author views the edit option.

web/views.py (1)

1880-1881: Good implementation of GitHub URL fields.

The addition of GitHub issue and milestone URLs to forum topics is well-implemented. Using get() on the form's cleaned_data is a good practice as it safely handles cases where these fields might be optional.

Copy link
Contributor

@A1L13N A1L13N left a comment

Choose a reason for hiding this comment

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

Please add back replies

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 8, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 8, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 8, 2025
@10done
Copy link
Contributor Author

10done commented Apr 8, 2025

@coderabbitai Why is my docker build-and-test failing ?
Please help me resolve it

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 8, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the Docker configuration
echo "=== Checking Docker configuration ==="
if [ -f "Dockerfile" ]; then
  cat Dockerfile
fi
if [ -f "docker-compose.yml" ]; then
  cat docker-compose.yml
fi

# Check the GitHub workflow file that was changed
echo "=== Checking GitHub workflow file ==="
cat .github/workflows/test.yml

# Check if there are any recent GitHub Action failures
echo "=== Recent GitHub Action runs ==="
gh run list -L 5

# Check the latest workflow run details
echo "=== Latest workflow run details ==="
LATEST_RUN_ID=$(gh run list -L 1 --json databaseId --jq '.[0].databaseId')
if [ ! -z "$LATEST_RUN_ID" ]; then
  gh run view $LATEST_RUN_ID
fi

# Check for database or migration-related commands
echo "=== Database commands in project ==="
grep -r "manage.py migrate" --include="*.py" --include="*.sh" --include="*.yml" .

Length of output: 5932


🏁 Script executed:

#!/bin/bash
# Check the Docker test workflow file
echo "=== Checking Docker test workflow file ==="
cat .github/workflows/docker-test.yml

# Check the specific failing workflow run
echo "=== Failing workflow run details ==="
gh run view 14333430215

# Let's check the logs of the failing workflow
echo "=== Logs from failing Docker Build & Test workflow ==="
gh run view 14333430215 --log

Length of output: 71348


🏁 Script executed:

#!/bin/bash
# Checking the actual failure in the Docker Build & Test workflow
echo "=== Logs of the failed step from Docker Build & Test workflow ==="
gh run view 14333430215 --log-failed

# Check the .env.sample file to see the environment variables
echo "=== Environment variables from .env.sample ==="
cat .env.sample

# Check if there are missing migrations in the test
echo "=== Looking for any test files that might be related to ForumTopic ==="
find . -name "test_*.py" | xargs grep -l "ForumTopic"

Length of output: 14707


@10done I found why your Docker build-and-test is failing!

The error is coming from the tests trying to access the new GitHub URL fields you added, but those columns don't exist in the test database:

MySQLdb.OperationalError: (1054, "Unknown column 'github_issue_url' in 'web_forumtopic'")

Here's what's happening:

  1. You added new fields (github_issue_url and github_milestone_url) to the ForumTopic model
  2. You created a migration file 0056_forumtopic_github_issue_url_and_more.py
  3. You updated .github/workflows/test.yml to run migrations before tests
  4. But in .github/workflows/docker-test.yml, the new migrations aren't being applied correctly

Solution:

Add the migration command to your Docker test workflow by updating .github/workflows/docker-test.yml. You need to run all migrations including your new one when setting up the test database.

The issue is that you're relying on a migration that's run during the container startup, but it's not picking up your new migration that adds the GitHub URL fields.

# Add this to the Docker container setup before running tests
docker exec education-app python manage.py migrate

This ensures the test database has all required columns before tests run against it.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 340b936 and d246fd0.

📒 Files selected for processing (1)
  • .github/workflows/docker-test.yml (4 hunks)
🔇 Additional comments (4)
.github/workflows/docker-test.yml (4)

48-49: Clarify Dockerfile Creation Context
The comment and block creating the temporary Dockerfile are clear. It properly emphasizes that no migrations are run during the image build, which is essential for later executing migrations on container startup.


86-88: Confirm CMD Behavior in Test Dockerfile
The comment and CMD instruction correctly indicate that migrations are skipped during the build, relying on runtime commands to update the database schema. This approach helps keep the build lightweight.


106-108: Ensure Clean Container State
Removing any existing container with docker rm -f education-app || true is a good practice to avoid conflicts. The inline comment clearly explains the intent.


129-131: Update Migration Command for Non-interactive Execution
Updating the migration command to include the --noinput flag ensures that migrations run without manual intervention, which is vital in CI/CD environments. This change directly addresses the reported issue with missing migration fields in the test database.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 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: 1

♻️ Duplicate comments (2)
web/forms.py (2)

1178-1183: Refine error handling messages (existing suggestion noted).

These validation checks effectively ensure GitHub issue URLs follow the intended format. If you wish to add more descriptive messages or check for additional patterns (e.g., specific repository names), it’s fine to do so. Otherwise, this is good as is.

🧰 Tools
🪛 Ruff (0.8.2)

1178-1178: Missing return type annotation for public function clean_github_issue_url

(ANN201)


1181-1181: Avoid specifying long messages outside the exception class

(TRY003)


1184-1188: Refine milestone URL validation (existing suggestion noted).

The milestone validation logic is sufficient. For an even better user experience, you might provide a more descriptive error message indicating the expected milestone URL structure.

🧰 Tools
🪛 Ruff (0.8.2)

1184-1184: Missing return type annotation for public function clean_github_milestone_url

(ANN201)


1187-1187: Avoid specifying long messages outside the exception class

(TRY003)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d246fd0 and fabb1ee.

📒 Files selected for processing (2)
  • web/forms.py (2 hunks)
  • web/migrations/0056_forumtopic_github_issue_url_and_more.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
web/migrations/0056_forumtopic_github_issue_url_and_more.py

8-10: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)


12-23: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)

web/forms.py

1163-1163: Trailing comma missing

Add trailing comma

(COM812)


1170-1170: Trailing comma missing

Add trailing comma

(COM812)


1176-1176: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)


1178-1178: Missing return type annotation for public function clean_github_issue_url

(ANN201)


1181-1181: Avoid specifying long messages outside the exception class

(TRY003)


1184-1184: Missing return type annotation for public function clean_github_milestone_url

(ANN201)


1187-1187: Avoid specifying long messages outside the exception class

(TRY003)

🔇 Additional comments (2)
web/migrations/0056_forumtopic_github_issue_url_and_more.py (1)

13-22: Migration logic appears correct.

The new fields are added with blank=True and appropriate help texts, aligning with Django conventions. There are no concerns regarding concurrency, security, or performance in this migration step, and the usage of URLField is appropriate.

web/forms.py (1)

1174-1177: Retain standard Django usage.

Although static analysis flags mutable class attributes and missing type annotations, this is standard Django form Meta usage, and typically not an issue. These warnings can be safely ignored unless your team’s style guide enforces type annotations for class-level attributes.

🧰 Tools
🪛 Ruff (0.8.2)

1176-1176: Mutable class attributes should be annotated with typing.ClassVar

(RUF012)

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 8, 2025
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.

Allow forum posts to link to GitHub issue or milestone

2 participants