Exemplo n.º 1
0
def sql_work():
    return render_template(
        "sql_work_add.html",
        host_infos=sql_manager.get_execute_mysql_host(),
        dba_users=cache.MyCache().get_user_info_by_group_id(
            settings.DBA_GROUP_ID),
        audit_user_infos=cache.MyCache().get_audit_user_infos())
Exemplo n.º 2
0
def sql_list_home():
    user_info = cache.MyCache().get_user_info(current_user.id)
    if (user_info.group_id == settings.DBA_GROUP_ID and user_info.role_id == settings.ROLE_DEV):
        return render_template("list_for_dba.html")
    if (user_info.role_id == settings.ROLE_DEV):
        return render_template("list_for_dev.html")
    if (user_info.role_id == settings.ROLE_LEADER):
        return render_template("list_for_leader.html")
    if (user_info.role_id == settings.ROLE_ADMINISTRATOR):
        return render_template("list_for_admin.html", user_infos=cache.MyCache().get_user_info(), sql_work_status=settings.SQL_WORK_STATUS_DICT)
    return render_template("list.html", user_infos=cache.MyCache().get_user_info(), sql_work_status=settings.SQL_WORK_STATUS_DICT)
Exemplo n.º 3
0
def get_update_sql_work_html(sql_id):
    return render_template("sql_edit_home.html",
                           work_info=sql_manager.get_sql_info_by_id(sql_id),
                           host_infos=sql_manager.get_audit_mysql_host(),
                           dba_users=cache.MyCache().get_user_info_by_group_id(settings.DBA_GROUP_ID),
                           audit_user_infos=cache.MyCache().get_audit_user_infos())

    return render_template("sql_update_view.html",
                           work_info=sql_manager.get_sql_info_by_id(sql_id),
                           host_infos=sql_manager.get_audit_mysql_host(),
                           dba_users=cache.MyCache().get_user_info_by_group_id(settings.DBA_GROUP_ID),
                           audit_user_infos=cache.MyCache().get_audit_user_infos())
Exemplo n.º 4
0
def query_sql_list():
    user_info = cache.MyCache().get_user_info(current_user.id)
    if (user_info.group_id == settings.DBA_GROUP_ID and user_info.role_id == settings.ROLE_DEV):
        obj = get_object_from_json_tmp(request.get_data())
        result_sql_list = sql_manager.get_sql_work_for_dba(obj)
    elif (user_info.role_id == settings.ROLE_DEV):
        obj = get_object_from_json_tmp(request.get_data())
        result_sql_list = sql_manager.get_sql_work_for_dev(obj)
    elif (user_info.role_id == settings.ROLE_LEADER):
        obj = get_object_from_json_tmp(request.get_data())
        result_sql_list = sql_manager.get_sql_work_for_leader(obj)
    else:
        obj = get_object_from_json(request.form)
        result_sql_list = sql_manager.get_sql_list(obj)
    return render_template("list_view.html",
                           sql_list=result_sql_list,
                           user_info=user_info,
                           page_number=obj.page_number,
                           page_list=get_page_number_list(obj.page_number),
                           min_id=get_min_id(result_sql_list, obj.page_number))
Exemplo n.º 5
0
def get_show_update_user_dialog(user_id):
    return render_template("user_update_view.html",
                           role_infos=cache.MyCache().get_role_info(),
                           group_infos=cache.MyCache().get_group_info(),
                           user_info=cache.MyCache().get_user_info(user_id))
Exemplo n.º 6
0
def get_user():
    return render_template("user.html",
                           role_infos=cache.MyCache().get_role_info(),
                           group_infos=cache.MyCache().get_group_info(),
                           host_infos=cache.MyCache().get_mysql_host_info())
Exemplo n.º 7
0
def main():
    return render_template("main.html",
                           user_info=cache.MyCache().get_user_info(
                               current_user.id),
                           administrator_role=settings.ROLE_ADMINISTRATOR)
Exemplo n.º 8
0
def get_sql_execute_home_new(id):
    return render_template("sql_execute_home.html",
                           sql_info=sql_manager.get_sql_info_by_id(id),
                           user_info=cache.MyCache().get_user_info(
                               current_user.id))
Exemplo n.º 9
0
import settings
from src import common_util, cache, user_login, sql_manager, host_manager, user_manager

app = Flask("mysql_audit",
            instance_relative_config=True,
            instance_path=os.getcwd())
app.config["SESSION_COOKIE_NAME"] = "mysql_audit"
app.logger.debug('A value for debugging')
app.logger.warning('A warning occurred (%d apples)', 42)
app.logger.error('An error occurred')
app.secret_key = os.urandom(24)
login_manager = LoginManager()
login_manager.session_protection = "strong"
login_manager.login_view = "login_home"
login_manager.init_app(app=app)
cache.MyCache().load_all_cache()

# region tab


@app.route("/main")
@login_required
def main():
    return render_template("main.html",
                           user_info=cache.MyCache().get_user_info(
                               current_user.id),
                           administrator_role=settings.ROLE_ADMINISTRATOR)


@app.route("/home")
@login_required
Exemplo n.º 10
0
 def check(*args, **kwargs):
     if (cache.MyCache().get_user_info(current_user.id).group_id == settings.ADMIN_GROUP_ID):
         return func(*args, **kwargs)
     else:
         return "你没有操作权限!"