|
8 | 8 | from django.conf import settings |
9 | 9 | from django.conf.urls import include |
10 | 10 | from django.contrib import admin |
11 | | -from django.urls import path |
| 11 | +from django.urls import register_converter, path |
| 12 | + |
12 | 13 | from instrument.views import runs |
13 | 14 | from reduction_viewer import views as reduction_viewer_views |
14 | 15 |
|
|
18 | 19 | handler404 = 'autoreduce_webapp.views.handler404' |
19 | 20 | handler500 = 'autoreduce_webapp.views.handler500' |
20 | 21 |
|
| 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 | + |
21 | 43 | urlpatterns = [ |
22 | 44 | # ===========================MISC================================= # |
23 | 45 | path('', reduction_viewer_views.index, name='index'), |
|
34 | 56 | path('instrument/', include('instrument.urls')), |
35 | 57 |
|
36 | 58 | # ===========================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'), |
38 | 60 |
|
39 | 61 | # ===========================SCRIPTS============================= # |
40 | 62 | path('graph/', reduction_viewer_views.graph_home, name="graph"), |
|
0 commit comments