Пример #1
0
def app_before():

    g.user_token = get_usertoken_from_session(session)
    g.user = get_current_user_profile(g.user_token)
    g.locale = request.accept_languages.best_match(config.LANGUAGES.keys())

    g.def_title = config.DEF_TITLE.decode('utf-8')
    g.def_url = config.DEF_URL

    path = request.path
    if not g.user and not path.startswith("/auth/login") and \
            not path.startswith("/static/") and \
            not path.startswith("/portal/links/") and \
            not path.startswith("/auth/register"):
        return redirect("/auth/login")

    if path.startswith("/screen"):
        g.nav_menu = "nav_screen"
    elif path.startswith("/portal/hostgroup") or path.startswith("/portal/group"):
        g.nav_menu = "p_hostgroup"
    elif path.startswith("/portal/template"):
        g.nav_menu = "p_template"
    elif path.startswith("/portal/expression"):
        g.nav_menu = "p_expression"
    elif path.startswith("/portal/nodata"):
        g.nav_menu = "p_nodata"
    elif path.startswith("/portal/alarm-dash"):
        g.nav_menu = "p_alarm-dash"
    elif path.startswith("/user") or path.startswith("/team") or path.startswith("/auth"):
        g.nav_menu = "p_system"
    else:
        g.nav_menu = "nav_dashboard"
Пример #2
0
def app_before():
    g.user_token = get_usertoken_from_session(session)
    g.user = get_current_user_profile(g.user_token)
    g.locale = request.accept_languages.best_match(config.LANGUAGES.keys())

    path = request.path
    if not g.user and not path.startswith("/auth/login") and \
            not path.startswith("/static/") and \
            not path.startswith("/portal/links/") and \
            not path.startswith("/auth/register"):
        return redirect("/auth/login")

    if path.startswith("/screen"):
        g.nav_menu = "nav_screen"
    elif path.startswith("/portal/hostgroup") or path.startswith("/portal/group"):
        g.nav_menu = "p_hostgroup"
    elif path.startswith("/portal/template"):
        g.nav_menu = "p_template"
    elif path.startswith("/portal/expression"):
        g.nav_menu = "p_expression"
    elif path.startswith("/portal/nodata"):
        g.nav_menu = "p_nodata"
    elif path.endswith("/portal/alarm-dash/case"):
        g.nav_menu = "p_alarm-dash"
    elif path.endswith("/portal/alarm-dash-V2/case_point"):
        g.nav_menu = "p_alarm-dash-V2"       
    else:
        g.nav_menu = ""
Пример #3
0
def app_before():
    g.user_token = get_usertoken_from_session(session)
    g.user = get_current_user_profile(g.user_token)

    path = request.path
    if not g.user and not path.startswith("/auth/login") and \
            not path.startswith("/static/") and \
            not path.startswith("/portal/links/") and \
            not path.startswith("/auth/register"):
        return redirect("/auth/login")

    if path.startswith("/screen"):
        g.nav_menu = "nav_screen"
    elif path.startswith("/portal/hostgroup") or path.startswith("/portal/group"):
        g.nav_menu = "p_hostgroup"
    elif path.startswith("/portal/template"):
        g.nav_menu = "p_template"
    elif path.startswith("/portal/expression"):
        g.nav_menu = "p_expression"
    elif path.startswith("/portal/nodata"):
        g.nav_menu = "p_nodata"
    elif path.startswith("/portal/alarm-dash"):
        g.nav_menu = "p_alarm-dash"
    else:
        g.nav_menu = ""
Пример #4
0
def app_before():
    g.user_token = get_usertoken_from_session(session)
    g.user = get_current_user_profile(g.user_token)
    g.locale = request.accept_languages.best_match(config.LANGUAGES.keys())

    path = request.path
    if not g.user and not path.startswith("/auth/login") and \
            not path.startswith("/static/") and \
            not path.startswith("/portal/links/") and \
            not path.startswith("/auth/register"):
        return redirect("/auth/login")

    if path.startswith("/screen"):
        g.nav_menu = "nav_screen"
    elif path.startswith("/portal/hostgroup") or path.startswith("/portal/group"):
        g.nav_menu = "p_hostgroup"
    elif path.startswith("/portal/template"):
        g.nav_menu = "p_template"
    elif path.startswith("/portal/expression"):
        g.nav_menu = "p_expression"
    elif path.startswith("/portal/nodata"):
        g.nav_menu = "p_nodata"
    elif path.startswith("/portal/alarm-dash"):
        g.nav_menu = "p_alarm-dash"
    else:
        g.nav_menu = ""
Пример #5
0
def app_before():
    g.user_token = get_usertoken_from_session(session)
    g.user = get_current_user_profile(g.user_token)
    g.locale = request.accept_languages.best_match(config.LANGUAGES.keys())

    path = request.path
    if not g.user and not path.startswith("/auth/login") and \
            not path.startswith("/static/") and \
            not path.startswith("/portal/links/") and \
            not path.startswith("/auth/register") and \
            not path.startswith("/v3/"):
        return redirect("/auth/login")

    if g.user and path == "/auth/login":
        return redirect("/")

    if g.user and g.user.role == 0 and \
            path not in ['/auth/logout', '/user/profile', '/portal/hostgroup', '/', '/user/chpwd'] and \
            not path.startswith('/chart') and \
            not (path.startswith('/portal/group/') and (path.endswith('/graph') or path.endswith('hosts'))) and \
            not (path == '/api/counters' and request.method == 'POST') and \
            not (path == '/api/endpoints' and request.method == 'GET'):
        return jsonify({'msg': 'You have no permission'})

    if path.startswith("/screen"):
        g.nav_menu = "nav_screen"
    elif path.startswith("/portal/hostgroup") or path.startswith(
            "/portal/group"):
        g.nav_menu = "p_hostgroup"
    elif path.startswith("/portal/template"):
        g.nav_menu = "p_template"
    elif path.startswith("/portal/expression"):
        g.nav_menu = "p_expression"
    elif path.startswith("/portal/nodata"):
        g.nav_menu = "p_nodata"
    elif path.startswith("/portal/alarm-dash"):
        g.nav_menu = "p_alarm-dash"
    elif path.startswith("/portal/metric") or path.startswith("/portal/tag"):
        g.nav_menu = "p_metric"
    else:
        g.nav_menu = ""