Changeset - db1c6ce454d0
[Not reviewed]
default
0 1 0
Dennis Fink - 10 years ago 2015-07-07 19:54:56

Use abort function in state.py
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
spaceapi/state.py
Show inline comments
 
import json
 

	
 
from time import time
 

	
 
from flask import Blueprint, jsonify, request, current_app
 
from flask import Blueprint, jsonify, request, current_app, abort
 

	
 
from .active import active_json, save_last_state
 
from .auth import httpauth
 

	
 
state_views = Blueprint('state', __name__)
 

	
 
ALLOWED_STATE_KEYS = {
 
    'open': bool,
 
    'lastchange': int,
 
    'trigger_person': str,
 
    'message': str
 
}
 
@@ -24,13 +24,13 @@ def set_state(key):
 
    current_app.logger.info(value)
 
    current_app.logger.info(type(value))
 

	
 
    if key in ALLOWED_STATE_KEYS:
 
        active_json['state'][key] = value
 

	
 
        if key == 'open':
 
            active_json['state']['lastchange'] = int(time())
 

	
 
        save_last_state()
 
        return jsonify(active_json)
 
    else:
 
        return 400
 
        return abort(400)
0 comments (0 inline, 0 general)