Changeset - f99bd2c57c77
[Not reviewed]
default
0 1 0
Dennis Fink - 11 years ago 2014-07-13 16:43:34
dennis.fink@c3l.lu
remove uncommitted function imports
1 file changed with 2 insertions and 3 deletions:
0 comments (0 inline, 0 general)
ennstatus/stats/views.py
Show inline comments
 
from flask import (Blueprint, render_template, request, current_app,
 
                   redirect, url_for)
 

	
 
from ennstatus.stats.functions import (make_worldmap, make_total_pie,
 
                                       make_type_pie)
 
from ennstatus.stats.forms import (WorldmapStyleForm)
 
from ennstatus.stats.functions import make_worldmap
 
from ennstatus.stats.forms import WorldmapStyleForm
 

	
 
stats_page = Blueprint('stats', __name__)
 

	
 

	
 
@stats_page.route('/')
 
def index():
 
    return render_template('stats/index.html')
 

	
 

	
 
@stats_page.route('/worldmap', methods=('GET', 'POST'))
 
def worldmap():
 

	
 
    current_app.logger.info('Handling worldmap')
 
    form = WorldmapStyleForm()
 
    style_choices = [choice[0] for choice in form.style.choices]
 
    server_choices = [choice[0] for choice in form.server_type.choices]
 

	
 
    if request.method == 'POST':
 
        current_app.logger.debug('Validating form')
 
        if form.validate_on_submit():
 
            style = form.style.data
 
            server_type = form.server_type.data
 
            return redirect(url_for('stats.worldmap', server_type=server_type,
 
                                    style=style))
 
    else:
 
        if 'style' in request.args:
 
            style = request.args['style']
 
            if style in style_choices:
 
                current_app.logger.info('Using style %s' % style)
 
            else:
 
                current_app.logger.warn('Style %s not found' % style)
 
                style = 'default'
 
        else:
 
            current_app.logger.info('Using default style')
 
            style = 'default'
 

	
 
        if 'server_type' in request.args:
 
            server_type = request.args['server_type']
 
            if server_type in server_choices:
 
                current_app.logger.info('Showing %s nodes' % server_type)
 
            else:
 
                current_app.logger.warn('Server type %s not found' % style)
 
                server_type = 'all'
 
        else:
 
            current_app.logger.info('Showing all servers')
 
            server_type = 'all'
 
            
 

	
0 comments (0 inline, 0 general)