Exemplo n.º 1
0
def user_manager():
    """
    Страница управления списков пользователей системы

    Returns:
        
    """
    global attempt
    attempt = False
    page_controller = UserManagerPageController()
    mpc = MainMenuPageController()

    # страница доступна только администратору
    if not flask_login.current_user.is_admin():
        return redirect("main_page")

    endpoint = request.endpoint

    # if request.method == 'POST':
    #     action = request.form['action']
    #     if action == 'add_user':
    #         pass
    #добавиим просто нового пользователя
    # page_controller.create_user("user", "user", "user", "user", "*****@*****.**")

    return render_template(
        'user_manager.html',
        view="user_manager",
        _menu=mpc.get_main_menu(),
        _active_main_menu_item=mpc.get_active_menu_item_number(endpoint),
        _data=page_controller.get_users_list_view(),
        _is_current_user_admin=flask_login.current_user.is_admin())
Exemplo n.º 2
0
def settings():
    """
    Генерация страницы просмотра и редактирования настроек системы

    Returns:
        
    """

    page_controller = SettingsPageController()
    mpc = MainMenuPageController()

    endpoint = request.endpoint

    return render_template(
        'settings.html',
        view="settings",
        _menu=mpc.get_main_menu(),
        _active_main_menu_item=mpc.get_active_menu_item_number(endpoint),
        _data=page_controller.get_data())
Exemplo n.º 3
0
def results():
    """
    Просмотр результатов тестирования

    Returns:
        
    """

    page_controller = ResultsPageController()
    mpc = MainMenuPageController()

    endpoint = request.endpoint

    return render_template(
        'results.html',
        view="results",
        _menu=mpc.get_main_menu(),
        _active_main_menu_item=mpc.get_active_menu_item_number(endpoint),
        _data=page_controller.get_data())
Exemplo n.º 4
0
def probes():
    """
    Просмотр проведение нейро-психологических проб

    Returns:
        
    """

    page_controller = ProbesPageController()
    mpc = MainMenuPageController()

    endpoint = request.endpoint

    return render_template(
        'probes.html',
        view="probes",
        _menu=mpc.get_main_menu(),
        _active_main_menu_item=mpc.get_active_menu_item_number(endpoint),
        _data=page_controller.get_data())
Exemplo n.º 5
0
def corrections():
    """
    Просмотр выполнение нейро-психологических коррекций

    Returns:
        
    """

    page_controller = CorrectionsPageController()
    mpc = MainMenuPageController()

    endpoint = request.endpoint

    return render_template(
        'corrections.html',
        view="corrections",
        _menu=mpc.get_main_menu(),
        _active_main_menu_item=mpc.get_active_menu_item_number(endpoint),
        _data=page_controller.get_data())
Exemplo n.º 6
0
def main_page():
    """
    Просмотр и редактирование собственнного профиля

    Returns:
        
    """

    page_controller = MainPageController()
    mpc = MainMenuPageController()

    endpoint = request.endpoint

    return render_template(
        'main_page.html',
        view="main_page",
        _menu=mpc.get_main_menu(),
        _active_main_menu_item=mpc.get_active_menu_item_number(endpoint),
        _data=page_controller.get_data())
Exemplo n.º 7
0
def probationers():
    """
    Просмотр списка испытуемых

    Returns:
        
    """

    page_controller = ProbationersPageController()
    mpc = MainMenuPageController()

    global attempt
    attempt = False

    endpoint = request.endpoint

    return render_template(
        'probationers.html',
        view="probationers",
        _menu=mpc.get_main_menu(),
        _active_main_menu_item=mpc.get_active_menu_item_number(endpoint),
        _data=page_controller.get_probationers_list_view(),
        _is_current_user_admin=flask_login.current_user.is_admin())
Exemplo n.º 8
0
def probationer_card():
    """
        Страница просмотра, редактирования и добавления карточки испытуемого
    """

    page_controller = ProbationerCardPageController()
    mpc = MainMenuPageController()
    endpoint = "probationers"

    probationer_id = request.args.get('probationer_id')
    global attempt
    error = None
    error_type = None

    if probationer_id is not None:
        mode = "view"
    else:
        mode = "new"
        probationer_id = ""

    user_id = flask_login.current_user.user_id
    user_login = UserProfilePageController().get_users_profile_view(
        user_id).login

    data_begin = page_controller.get_probationer_card_view(probationer_id)
    data = {}

    if request.method == 'POST':
        if request.form["button"] == "add_save_edit":
            if mode == "new":
                # добавляем нового пользователя и получаем список с ошибками
                # если их нет, то получаем пустой список
                attempt = True
                probationer = {}
                probationer["name_probationer"] = request.form[
                    "name_probationer"]
                probationer["date_of_birth"] = request.form["date_of_birth"]
                probationer["name_parent"] = request.form["name_parent"]
                probationer["educational_institution"] = request.form[
                    "educational_institution"]
                probationer["contacts"] = request.form["contacts"]
                probationer["diagnoses"] = request.form["diagnoses"]
                probationer["reasons_for_contact"] = request.form[
                    "reasons_for_contact"]

                error = page_controller.create_probationers(
                    user_login, probationer["name_probationer"],
                    probationer["date_of_birth"], probationer["name_parent"],
                    probationer["educational_institution"],
                    probationer["contacts"], probationer["diagnoses"],
                    probationer["reasons_for_contact"])

                if error is None:
                    mode = "view"
                    error = "Испытуемый сохранён!"
                    error_type = "Successful"
                    attempt = False

                data = probationer

    if data == {}:
        data = data_begin

    return render_template(
        'probationer_card.html',
        view="probationer_card",
        _menu=mpc.get_main_menu(),
        _active_main_menu_item=mpc.get_active_menu_item_number(endpoint),
        _data=data,
        _mode=mode,
        _data_begin=data_begin,
        _error=error,
        _error_type=error_type,
        _attempt=attempt)
Exemplo n.º 9
0
def user_profile():
    """
    Страница просмотра и редактирования профиля пользователя        
    """

    page_controller = UserProfilePageController()
    mpc = MainMenuPageController()

    endpoint = "user_manager"
    user_id = request.args.get('user_id')

    global attempt
    if not (attempt and user_id is not None):
        mode = "view"
    else:
        if attempt and request.form["button"] == "discharge":
            mode = "discharge"
        else:
            mode = "edit"

    error = None

    if user_id == None:
        # если пользователь не задан, то открываем страницу в режиме создания нового пользователя
        # страница доступна только администратору
        if not flask_login.current_user.is_admin():
            return redirect("main_page")

        mode = "new"
        user_id = ""
    else:
        if not flask_login.current_user.is_admin():
            mode = "edit"

    data_begin = page_controller.get_users_profile_view(user_id)
    data = {}
    if isinstance(data_begin, dict):
        active = True
    else:
        active = data_begin.active
    error_type = False

    if request.method == 'POST':
        if request.form["button"] == "add_save_edit":
            if mode == "new":
                # добавляем нового пользователя и получаем список с ошибками
                # если их нет, то получаем пустой список
                attempt = True
                manager_page_controller = UserManagerPageController()
                user = {}
                user["login"] = request.form["login"]
                user["name"] = request.form["name_user"]
                user["password"] = request.form["password"]
                user["password2"] = request.form["password2"]
                user["email"] = request.form["email"]
                user["role"] = request.form["role"]
                user["probationers_number"] = int(
                    request.form["probationers_number"])
                user["access_time"] = request.form["access_time"]

                active = True

                error = manager_page_controller.create_user(
                    user["login"], user["name"], user["password"],
                    user["password2"], user["email"], user["role"],
                    user["probationers_number"], user["access_time"])

                if error is None:
                    mode = "view"

                    error = "Пользователь сохранён!"
                    error_type = "Successful"

                    attempt = False

                data = user

            elif mode == "view":
                attempt = True
                mode = "edit"

            elif mode == "edit":
                manager_page_controller = UserManagerPageController()
                user = {}
                user["login"] = request.form["login"]
                user["name"] = request.form["name_user"]
                user["email"] = request.form["email"]
                user["role"] = request.form["role"]
                user["probationers_number"] = int(
                    request.form["probationers_number"])
                user["access_time"] = request.form["access_time"]
                user["created_date"] = data_begin.created_date

                manager_page_controller.change_user(
                    user["login"], user["name"], user["email"], user["role"],
                    user["probationers_number"], user["access_time"],
                    user["created_date"], user["active"])

                data = user
                mode = "view"
                attempt = False
                error = "Изменения сохранены!"
                error_type = "Successful"

        elif request.form["button"] == "discharge":
            if mode == "discharge" and attempt:
                manager_page_controller = UserManagerPageController()
                user = {}
                user["login"] = request.form["login"]
                user["password"] = request.form["password"]
                user["password2"] = request.form["password2"]

                error = manager_page_controller.discharge_password(
                    user["login"], user["password"], user["password2"])

                if error is None:
                    mode = "view"

                    error = "Пароль успешно изменен!"
                    error_type = "Successful"

                    attempt = False

            else:
                attempt = True
                mode = "discharge"

        elif request.form["button"] == "is_active":
            manager_page_controller = UserManagerPageController()
            active = manager_page_controller.activation_deactivation(
                data_begin.login)
            error_type = "Successful"

            if active:
                error = "Пользователь успешно разблокирован!"
            else:
                error = "Пользователь успешно заблокирован!"

    if data == {}:
        data = data_begin

    return render_template(
        'user_profile.html',
        view="user_profile",
        _menu=mpc.get_main_menu(),
        _active_main_menu_item=mpc.get_active_menu_item_number(endpoint),
        _data=data,
        _data_begin=data_begin,
        _is_current_user_admin=flask_login.current_user.is_admin(),
        _mode=mode,
        _error=error,
        _attempt=attempt,
        _active=active,
        _error_type=error_type)