@@ -9,13 +9,13 @@ def _wrapped_view(request, *args, **kwargs):
99 r = data .get (syllable_id )
1010 if r == None :
1111 return Response (
12- {" detail" : " syllable {sid} is required" .format (sid = syllable_id )},
12+ {' detail' : ' syllable {sid} is required' .format (sid = syllable_id )},
1313 status = status .HTTP_400_BAD_REQUEST ,
1414 )
1515
1616 if syllable_type != None and type (r ) != syllable_type :
1717 return Response (
18- {" detail" : " syllable {sid} has wrong type" .format (sid = syllable_id )},
18+ {' detail' : ' syllable {sid} has wrong type' .format (sid = syllable_id )},
1919 status = status .HTTP_400_BAD_REQUEST ,
2020 )
2121
@@ -31,7 +31,7 @@ def _wrapped_view(request, *args, **kwargs):
3131 target = kwargs .get (parameter_id )
3232 if target == None :
3333 return Response (
34- {" detail" : " {pid} in URI is required" .format (pid = parameter_id )},
34+ {' detail' : ' {pid} in URI is required' .format (pid = parameter_id )},
3535 status = status .HTTP_404_NOT_FOUND ,
3636 )
3737
@@ -47,11 +47,29 @@ def decorator(func):
4747 def _wrapped_view (request , * args , ** kwargs ):
4848 if not request .user .is_authenticated :
4949 return Response (
50- {" detail" : " Login Required" }, status = status .HTTP_401_UNAUTHORIZED
50+ {' detail' : ' Login Required' }, status = status .HTTP_401_UNAUTHORIZED
5151 )
5252
5353 return func (request , * args , ** kwargs )
5454
5555 return _wrapped_view
5656
5757 return decorator
58+
59+ def parse_as_integer (sid ):
60+ def decorator (func ):
61+ def _wrapped_view (request , * args , ** kwargs ):
62+ data = request .GET .copy ()
63+ if data .get (sid ) is not None :
64+ if data [sid ].isdecimal ():
65+ data [sid ] = int (data [sid ])
66+ else :
67+ del data [sid ]
68+
69+ request .GET = data
70+
71+ return func (request , * args , ** kwargs )
72+
73+ return _wrapped_view
74+
75+ return decorator
0 commit comments