Changeset - 0096d4dce428
[Not reviewed]
default
0 1 0
Dennis Fink - 9 years ago 2016-09-19 17:41:03
dennis.fink@c3l.lu
Simplified open endpoint
1 file changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
spaceapi/views.py
Show inline comments
 
@@ -20,51 +20,51 @@ def status_json():
 

	
 
@root_views.route('/reload')
 
@httpauth.login_required
 
def reload():
 
    active = ActiveStatus()
 
    active.reload()
 
    return jsonify(active)
 

	
 

	
 
@root_views.route('/open', methods=('GET', 'POST'))
 
@httpauth.login_required
 
def open():
 
    if request.method == 'POST':
 
        active = ActiveStatus()
 

	
 
        try:
 
            if httpauth.username() in current_app.config['STATE_TRIGGER_PERSON_ALLOWED']:
 
                trigger_person = httpauth.username()
 
            else:
 
                trigger_person = None
 
        except KeyError:
 
            trigger_person = None
 

	
 
        if 'close' in request.form:
 
            active.set_new_state(value=False, trigger_person=trigger_person)
 
            active.save_last_state()
 
            return redirect(url_for('root.index'))
 
            new_state = False
 
        elif 'open' in request.form:
 
            active.set_new_state(value=True, trigger_person=trigger_person)
 
            new_state = True
 

	
 
        active.set_new_state(value=new_state, trigger_person=trigger_person)
 
            active.save_last_state()
 
            return redirect(url_for('root.index'))
 

	
 
    return render_template('open.html')
 

	
 

	
 
@root_views.route('/present', methods=('GET', 'POST'))
 
@httpauth.login_required
 
def present():
 
    if request.method == 'POST':
 

	
 
        active = ActiveStatus()
 

	
 
        if active['state']['open']:
 
            if 'present' in request.form:
 
                active.add_user_present(httpauth.username())
 
            elif 'leave' in request.form:
 
                active.remove_user_present(httpauth.username())
 
            active.save_last_state()
 
        return redirect(url_for('root.index'))
 

	
 
    return render_template('present.html')
0 comments (0 inline, 0 general)