4bd10335d972 — Peter Sanchez 13 years ago
Added RENEW command
1 files changed, 4 insertions(+), 5 deletions(-)

M cartfreakapi/views.py
M cartfreakapi/views.py +4 -5
@@ 5,6 5,8 @@ from django.core.exceptions import Impro
 from cartfreakapi import CartFreakError
 
 
+REQUIRED_VARS = ('command', 'hash')
+VALID_COMMANDS = ('CREATE', 'REMOVE', 'RENEW', 'COMPLETE')
 ERROR_STR = 'ERROR %s'
 
 

          
@@ 13,12 15,9 @@ def handle_api(request, callback=None, k
         raise ImproperlyConfigured(
             u'No CartFreak API setting configured for %s' % key_name
         )
-
-    required = ('command', 'hash')
-    valid_commands = ('CREATE', 'REMOVE', 'COMPLETE')
     
     cf_key = getattr(settings, key_name)
-    for req in required:
+    for req in REQUIRED_VARS:
         if req not in request.POST:
             err_msg = 'No %s varaible was sent' % req
             return HttpResponse(ERROR_STR % err_msg)

          
@@ 27,7 26,7 @@ def handle_api(request, callback=None, k
     command = request.POST.get('command')
     _hash = hashlib.sha1(cf_key + command).hexdigest()
 
-    if command not in valid_commands:
+    if command not in VALID_COMMANDS:
         return HttpResponse(ERROR_STR % 'Invalid command sent')
 
     if _hash != in_hash: