Skip to content

Conversation

@BrennanB
Copy link
Member

Adds support to send notifications when a world record is set to a discord web hook.

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@BrennanB BrennanB requested a review from Copilot June 11, 2025 19:58
Copy link

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

Adds Discord webhook notifications and an admin test interface for world record events.

  • Prevents horizontal overflow in the base template and enforces navbar wrapping rules.
  • Introduces an admin_required decorator, a webhook_test view, URL routing, and a test page for Discord webhooks.
  • Implements send_world_record_webhook and test_world_record_webhook in highscores/lib.py and hooks into approve_score.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
home/templates/home/base.html Added CSS to prevent horizontal overflow and force navbar nowrap.
highscores/views.py Added admin_required decorator and webhook_test admin view.
highscores/urls.py Registered the webhook_test/ endpoint.
highscores/templates/highscores/webhook_test.html Created admin UI for sending test webhooks.
highscores/lib.py Added webhook-sending functions and integrated them into score approval.
Comments suppressed due to low confidence (2)

highscores/lib.py:120

  • The logging module is used here but not imported; add import logging at the top to avoid a NameError.
logging.error(f"Discord webhook failed with status: {response.status}")

highscores/urls.py:14

  • [nitpick] Indentation is inconsistent with other routes in urlpatterns; align this line with the others for readability.
     path('webhook-test/', views.webhook_test, name='webhook-test'),



def admin_required(view_func):
"""Custom decorator to require admin access (staff or superuser)"""
Copy link

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

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

Use functools.wraps on the wrapper to preserve the original view function's metadata (name, docstring, etc.).

Suggested change
"""Custom decorator to require admin access (staff or superuser)"""
"""Custom decorator to require admin access (staff or superuser)"""
@functools.wraps(view_func)

Copilot uses AI. Check for mistakes.
Copy link
Member

@NicholasBottone NicholasBottone left a comment

Choose a reason for hiding this comment

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

lgtm

@BrennanB
Copy link
Member Author

@NicholasBottone probably good to merge if you think is good, need to put the webhook url in prod env vars.

I did notice the test is failing now for the home page, but I don't really understand why. The text it's looking for is still the same.

@NicholasBottone NicholasBottone merged commit a77d2af into main Jun 26, 2025
1 check passed
@NicholasBottone NicholasBottone deleted the Highscores-webhook branch June 26, 2025 03:33
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.

3 participants