Selaa lähdekoodia

fix(django): variable naming

Nils Wisiol 8 vuotta sitten
vanhempi
commit
273b9f9b72
2 muutettua tiedostoa jossa 11 lisäystä ja 11 poistoa
  1. 3 3
      api/desecapi/authentication.py
  2. 8 8
      api/desecapi/views.py

+ 3 - 3
api/desecapi/authentication.py

@@ -71,14 +71,14 @@ class URLParamAuthentication(BaseAuthentication):
         using URL parameters.  Otherwise returns `None`.
         using URL parameters.  Otherwise returns `None`.
         """
         """
 
 
-        if not 'username' in request.QUERY_PARAMS:
+        if not 'username' in request.query_params:
             msg = 'No username URL parameter provided.'
             msg = 'No username URL parameter provided.'
             raise exceptions.AuthenticationFailed(msg)
             raise exceptions.AuthenticationFailed(msg)
-        if not 'password' in request.QUERY_PARAMS:
+        if not 'password' in request.query_params:
             msg = 'No password URL parameter provided.'
             msg = 'No password URL parameter provided.'
             raise exceptions.AuthenticationFailed(msg)
             raise exceptions.AuthenticationFailed(msg)
 
 
-        return self.authenticate_credentials(request.QUERY_PARAMS['username'], request.QUERY_PARAMS['password'])
+        return self.authenticate_credentials(request.query_params['username'], request.query_params['password'])
 
 
     def authenticate_credentials(self, userid, key):
     def authenticate_credentials(self, userid, key):
 
 

+ 8 - 8
api/desecapi/views.py

@@ -216,12 +216,12 @@ class DynDNS12Update(APIView):
 
 
         def findDomainname(request):
         def findDomainname(request):
             # 1. hostname parameter
             # 1. hostname parameter
-            if 'hostname' in request.QUERY_PARAMS and request.QUERY_PARAMS['hostname'] != 'YES':
-                return request.QUERY_PARAMS['hostname']
+            if 'hostname' in request.query_params and request.query_params['hostname'] != 'YES':
+                return request.query_params['hostname']
 
 
             # 2. host_id parameter
             # 2. host_id parameter
-            if 'host_id' in request.QUERY_PARAMS:
-                return request.QUERY_PARAMS['host_id']
+            if 'host_id' in request.query_params:
+                return request.query_params['host_id']
 
 
             # 3. http basic auth username
             # 3. http basic auth username
             try:
             try:
@@ -230,8 +230,8 @@ class DynDNS12Update(APIView):
                 pass
                 pass
 
 
             # 4. username parameter
             # 4. username parameter
-            if 'username' in request.QUERY_PARAMS:
-                return request.QUERY_PARAMS['username']
+            if 'username' in request.query_params:
+                return request.query_params['username']
 
 
             # 5. only domain associated with this user account
             # 5. only domain associated with this user account
             if len(request.user.domains.all()) == 1:
             if len(request.user.domains.all()) == 1:
@@ -260,8 +260,8 @@ class DynDNS12Update(APIView):
 
 
         # Check URL parameters
         # Check URL parameters
         for p in params:
         for p in params:
-            if p in request.QUERY_PARAMS and lookfor in request.QUERY_PARAMS[p]:
-                return request.QUERY_PARAMS[p]
+            if p in request.query_params and lookfor in request.query_params[p]:
+                return request.query_params[p]
 
 
         # Check remote IP address
         # Check remote IP address
         client_ip = self.get_client_ip(request)
         client_ip = self.get_client_ip(request)