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

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/copilot/agent.yaml

This file was deleted.

16 changes: 4 additions & 12 deletions blt/middleware/ip_restrict.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please revert

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ipaddress
import logging

from django.core.cache import cache
from django.db import models, transaction
Expand All @@ -9,12 +8,10 @@

MAX_COUNT = 2147483647

logger = logging.getLogger(__name__)


class IPRestrictMiddleware:
"""
Middleware to restrict access based on client IP addresses and user agent.
Middleware to restrict access based on client IP addresses and user agents.
"""

def __init__(self, get_response):
Expand Down Expand Up @@ -48,8 +45,8 @@ def blocked_ip_network(self):
try:
network = ipaddress.ip_network(range_str, strict=False)
blocked_ip_network.append(network)
except ValueError as e:
logger.error(f"Invalid IP network {range_str}: {str(e)}")
except ValueError:
# Log the error or handle it as needed, but skip invalid networks
continue

return blocked_ip_network
Expand All @@ -73,12 +70,7 @@ def ip_in_range(self, ip, blocked_ip_network):
"""
Check if the IP address is within any of the blocked IP networks.
"""
try:
ip_obj = ipaddress.ip_address(ip)
except ValueError as e:
logger.error(f"Invalid IP address {ip}: {str(e)}")
return False

ip_obj = ipaddress.ip_address(ip)
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

Removed the try-catch block that was handling ValueError exceptions for invalid IP addresses. This will now cause unhandled exceptions if an invalid IP address is passed to this method.

Suggested change
ip_obj = ipaddress.ip_address(ip)
try:
ip_obj = ipaddress.ip_address(ip)
except ValueError:
# Invalid IP address, cannot be in any blocked range
return False

Copilot uses AI. Check for mistakes.
return any(ip_obj in ip_range for ip_range in blocked_ip_network)

def is_user_agent_blocked(self, user_agent, blocked_agents):
Expand Down
20 changes: 20 additions & 0 deletions website/static/css/custom-scrollbar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Custom scrollbar for WebKit browsers */
.scrollbar-hide::-webkit-scrollbar {
width: 8px;
}
.scrollbar-hide::-webkit-scrollbar-track {
background: transparent;
}
.scrollbar-hide::-webkit-scrollbar-thumb {
background-color: rgba(156, 163, 175, 0.5);
border-radius: 4px;
}
.scrollbar-hide::-webkit-scrollbar-thumb:hover {
background-color: rgba(156, 163, 175, 0.7);
}
.dark .scrollbar-hide::-webkit-scrollbar-thumb {
background-color: rgba(107, 114, 128, 0.5);
}
.dark .scrollbar-hide::-webkit-scrollbar-thumb:hover {
background-color: rgba(107, 114, 128, 0.7);
}
29 changes: 29 additions & 0 deletions website/static/js/darkMode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
document.addEventListener("DOMContentLoaded", () => {
const htmlElement = document.documentElement;

// Use event delegation to handle clicks on the theme toggle button,
// wherever it may be in the DOM.
document.addEventListener("click", (event) => {
const toggleButton = event.target.closest("#theme-toggle");
if (toggleButton) {
const isDark = htmlElement.classList.toggle("dark");
const newTheme = isDark ? "dark" : "light";

// Save user preference
localStorage.setItem("theme", newTheme);

// Send theme preference to server if CSRF token is available
const csrfToken = document.querySelector("[name=csrfmiddlewaretoken]")?.value;
if (csrfToken) {
fetch("/set-theme/", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-CSRFToken": csrfToken,
},
body: JSON.stringify({ theme: newTheme }),
}).catch(error => console.error("Error saving theme preference:", error));
}
}
});
});
111 changes: 0 additions & 111 deletions website/static/js/messages.js

This file was deleted.

Loading