Skip to content

Commit

Permalink
fixes handling of negative dashboard widget ids
Browse files Browse the repository at this point in the history
  • Loading branch information
eug3nix committed Feb 4, 2025
1 parent 2409aca commit 7b40275
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions pgmanage/app/converters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class SignedIntConverter:
regex = '-?\d+'

def to_python(self, value):
return int(value)

def to_url(self, value):
return '%d' % value
10 changes: 6 additions & 4 deletions pgmanage/app/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from django.urls import include, path
from . import views
from django.urls import include, path, register_converter
from . import views, converters
from django.conf import settings
from django.conf.urls.static import static

register_converter(converters.SignedIntConverter, 'signedint')

base_urlpatterns = [

# path('social-auth/', include('social_django.urls', namespace="social")),
Expand Down Expand Up @@ -292,8 +294,8 @@
path("monitoring-widgets/list", views.monitoring_dashboard.monitoring_widgets_list, name="monitoring-widgets-list"),
path("monitoring-widgets/test", views.monitoring_dashboard.test_monitoring_widget, name="test-monitoring-widget"),
path("monitoring-widgets/create", views.monitoring_dashboard.create_dashboard_monitoring_widget, name="create-dashboard-widget"),
path("monitoring-widgets/<int:widget_id>", views.monitoring_dashboard.widget_detail, name="dashboard-widget-detail"),
path("monitoring-widgets/<int:widget_id>/template", views.monitoring_dashboard.widget_template, name="widget-template"),
path("monitoring-widgets/<signedint:widget_id>", views.monitoring_dashboard.widget_detail, name="dashboard-widget-detail"),
path("monitoring-widgets/<signedint:widget_id>/template", views.monitoring_dashboard.widget_template, name="widget-template"),
path("monitoring-widgets/<int:widget_saved_id>/refresh", views.monitoring_dashboard.refresh_monitoring_widget, name="refresh-monitoring-widget"),
path("monitoring-widgets/user-created", views.monitoring_dashboard.create_widget, name="create-custom-widget"),
path("monitoring-widgets/user-created/<int:widget_id>", views.monitoring_dashboard.user_created_widget_detail, name="widget-detail"),
Expand Down

0 comments on commit 7b40275

Please sign in to comment.