()
Dashboard: Generate the Welcome/Status page for the dashboard
Dashboard: Generate the Welcome/Status page for the dashboard
Dashboard : Generate the Welcome / Status page for the dashboard
def dashboard_page():
    ''' Dashboard: Generate the Welcome/Status page for the dashboard '''
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        user.config = app.config
        user.get('uid', verify, g.rdb_conn)
        data = startData(user)
        data['active'] = 'dashboard'
        data['url'] = '/dashboard'
        data['js_bottom'].append("member/screen-o-death.js")
        data['js_bottom'].append("member/screen-o-death-chart.js")
        data['js_bottom'].append("member/monitors.js")
        if user.status != "active":
            data['url'] = '/dashboard/mod-subscription'
            page = render_template('member/mod-subscription.html', data=data)
        else:

            data['monitors'] = user.getMonitors(g.rdb_conn)
            data['reactions'] = user.getReactions(g.rdb_conn)
            data['monevents'] = user.getEvents(g.rdb_conn)
            data['moneventsnum'] = len(data['monevents'])
            data['monstats'] = {'true': 0,
                                'unknown': 0,
                                'false': 0}
            for key in data['monitors'].keys():
                if "true" in data['monitors'][key]['status']:
                    data['monstats']['true'] = data[
                        'monstats']['true'] + 1
                elif "false" in data['monitors'][key]['status']:
                    data['monstats']['false'] = data['monstats']['false'] + 1
                else:
                    data['monstats']['unknown'] = data[
                        'monstats']['unknown'] + 1

            # If there are no monitors print a welcome message
            if len(data['monitors']) < 1:
                data['welcome'] = True
                data['mons'] = False
            else:
                data['welcome'] = False
                data['mons'] = True

            if len(data['reactions']) < 1:
                data['reacts'] = False
            else:
                data['reacts'] = True

            from generalforms import subscribe
            form = subscribe.AddPackForm(request.form)
            page = render_template(
                'member/screen-o-death.html', data=data, form=form)
        return page
    else:
        flash('Please Login.', 'warning')
        return redirect(url_for('user.login_page'))
def dashboard_page ( ) : verify = verifyLogin ( app . config [ 'SECRET_KEY' ] , app . config [ 'COOKIE_TIMEOUT' ] , request . cookies ) if verify : user = User ( ) user . config = app . config user . get ( 'uid' , verify , g . rdb_conn ) data = startData ( user ) data [ 'active' ] = 'dashboard' data [ 'url' ] = '/dashboard' data [ 'js_bottom' ] . append ( "member/screen-o-death.js" ) data [ 'js_bottom' ] . append ( "member/screen-o-death-chart.js" ) data [ 'js_bottom' ] . append ( "member/monitors.js" ) if user . status != "active" : data [ 'url' ] = '/dashboard/mod-subscription' page = render_template ( 'member/mod-subscription.html' , data = data ) else : data [ 'monitors' ] = user . getMonitors ( g . rdb_conn ) data [ 'reactions' ] = user . getReactions ( g . rdb_conn ) data [ 'monevents' ] = user . getEvents ( g . rdb_conn ) data [ 'moneventsnum' ] = len ( data [ 'monevents' ] ) data [ 'monstats' ] = { 'true' : 0 , 'unknown' : 0 , 'false' : 0 } for key in data [ 'monitors' ] . keys ( ) : if "true" in data [ 'monitors' ] [ key ] [ 'status' ] : data [ 'monstats' ] [ 'true' ] = data [ 'monstats' ] [ 'true' ] + 1 elif "false" in data [ 'monitors' ] [ key ] [ 'status' ] : data [ 'monstats' ] [ 'false' ] = data [ 'monstats' ] [ 'false' ] + 1 else : data [ 'monstats' ] [ 'unknown' ] = data [ 'monstats' ] [ 'unknown' ] + 1 # If there are no monitors print a welcome message if len ( data [ 'monitors' ] ) < 1 : data [ 'welcome' ] = True data [ 'mons' ] = False else : data [ 'welcome' ] = False data [ 'mons' ] = True if len ( data [ 'reactions' ] ) < 1 : data [ 'reacts' ] = False else : data [ 'reacts' ] = True from generalforms import subscribe form = subscribe . AddPackForm ( request . form ) page = render_template ( 'member/screen-o-death.html' , data = data , form = form ) return page else : flash ( 'Please Login.' , 'warning' ) return redirect ( url_for ( 'user.login_page' ) )