From 2ed4bb871e9637c1e3721fbc19701da15f92c737 Mon Sep 17 00:00:00 2001 From: Shea Craig Date: Thu, 15 Feb 2018 21:28:09 -0500 Subject: [PATCH 1/3] Update urls.py Add additional route to retrieve computer info by serial. --- server/urls.py | 1 + 1 file changed, 1 insertion(+) diff --git a/server/urls.py b/server/urls.py index 86d49f0..8bcebf6 100755 --- a/server/urls.py +++ b/server/urls.py @@ -14,6 +14,7 @@ #computerinfo url(r'^info/(?P.+)/', computer_info, name='computer_info'), + url(r'^info/(?P[A-Z0-9]{11,12}.+)/', computer_info, name='computer_info'), #request url(r'^request/(?P.+)/', request, name='request'), From aa9e346493b0465404c089f27d6cf1446a61692f Mon Sep 17 00:00:00 2001 From: Shea Craig Date: Thu, 15 Feb 2018 21:32:30 -0500 Subject: [PATCH 2/3] Update views.py Handle computer lookups by either ID or serial. --- server/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/views.py b/server/views.py index 31090e0..7531953 100644 --- a/server/views.py +++ b/server/views.py @@ -50,9 +50,12 @@ def index(request): ##view to see computer info @login_required -def computer_info(request, computer_id): +def computer_info(request, computer_id=None, serial=None): cleanup() - computer = get_object_or_404(Computer, pk=computer_id) + if computer_id: + computer = get_object_or_404(Computer, pk=computer_id) + else: + computer = get_object_or_404(Computer, serial=serial) can_request = None approved = None From 94aeee21b91ff4ac221b6545a9877155b3c3927c Mon Sep 17 00:00:00 2001 From: Shea Craig Date: Thu, 15 Feb 2018 21:34:17 -0500 Subject: [PATCH 3/3] Update urls.py Might as well restrict computer ID to numbers while we're here, just to prevent someone with around a trillion computers from hitting the serial number route instead of the ID route. --- server/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/urls.py b/server/urls.py index 8bcebf6..729eacb 100755 --- a/server/urls.py +++ b/server/urls.py @@ -13,7 +13,7 @@ url(r'^info/secret/(?P.+)/', secret_info, name='secret_info'), #computerinfo - url(r'^info/(?P.+)/', computer_info, name='computer_info'), + url(r'^info/(?P[0-9]+)/', computer_info, name='computer_info'), url(r'^info/(?P[A-Z0-9]{11,12}.+)/', computer_info, name='computer_info'), #request