Skip to content
This repository was archived by the owner on Nov 14, 2022. It is now read-only.

Commit d50f265

Browse files
author
Dimitar Tasev
authored
Merge pull request #1265 from ISISScientificComputing/accept_negative_experiment
2 parents 41e3bf9 + 19c5079 commit d50f265

File tree

1 file changed

+24
-2
lines changed
  • WebApp/autoreduce_webapp/autoreduce_webapp

1 file changed

+24
-2
lines changed

WebApp/autoreduce_webapp/autoreduce_webapp/urls.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from django.conf import settings
99
from django.conf.urls import include
1010
from django.contrib import admin
11-
from django.urls import path
11+
from django.urls import register_converter, path
12+
1213
from instrument.views import runs
1314
from reduction_viewer import views as reduction_viewer_views
1415

@@ -18,6 +19,27 @@
1819
handler404 = 'autoreduce_webapp.views.handler404'
1920
handler500 = 'autoreduce_webapp.views.handler500'
2021

22+
23+
class NegativeIntConverter:
24+
regex = r'-?\d+'
25+
26+
@staticmethod
27+
def to_python(value):
28+
"""
29+
Return the value as a Python object
30+
"""
31+
return int(value)
32+
33+
@staticmethod
34+
def to_url(value):
35+
"""
36+
Return the value as a URL string
37+
"""
38+
return '%d' % value
39+
40+
41+
register_converter(NegativeIntConverter, 'negint')
42+
2143
urlpatterns = [
2244
# ===========================MISC================================= #
2345
path('', reduction_viewer_views.index, name='index'),
@@ -34,7 +56,7 @@
3456
path('instrument/', include('instrument.urls')),
3557

3658
# ===========================EXPERIMENT========================== #
37-
path('experiment/<int:reference_number>/', reduction_viewer_views.experiment_summary, name='experiment_summary'),
59+
path('experiment/<negint:reference_number>/', reduction_viewer_views.experiment_summary, name='experiment_summary'),
3860

3961
# ===========================SCRIPTS============================= #
4062
path('graph/', reduction_viewer_views.graph_home, name="graph"),

0 commit comments

Comments
 (0)