Beispiel #1
0
def user_manager(user_id):
    err_msg = ""
    user = utils.get_user_by_id(user_id)
    if user.user_role == 'admin':
        return render_template("Admin/user_manager.html",
                               user=utils.get_user_by_id(user_id),
                               list_user=utils.get_list_user(),
                               err_msg=err_msg)
    elif user.user_role == 'user':
        err_msg = "You are not permission to here"
        return redirect('/', err_msg=err_msg)
Beispiel #2
0
def add_new_ticket(user_id):
    mes = ""
    err_msg = ""
    if request.method == 'POST':
        name = request.form.get('name')
        starting_place = request.form.get('starting_place')
        destination_place = request.form.get('destination_place')
        date_starting = request.form.get('starting_date')
        date_return = request.form.get('return_date')
        price = request.form.get('price')
        if utils.add_ticket(name=name,
                            starting_place=starting_place,
                            destination_place=destination_place,
                            starting_date=date_starting,
                            return_date=date_return,
                            price=price):
            mes = "Ticket was created"
            return redirect(url_for('ticket_manager', user_id=current_user.id))
        else:
            err_msg = "something wrong when creating user"
            return redirect(url_for('ticket_manager', user_id=current_user.id))
    return render_template("Admin/add_ticket.html",
                           user=utils.get_user_by_id(user_id),
                           mes=mes,
                           err_msg=err_msg)
Beispiel #3
0
def information(user_id):
    user = utils.get_user_by_id(user_id)
    if request.method == 'POST':
        name = request.form.get('name')
        username = request.form.get('username')
        new_password = request.form.get('new_password')
        confirm_password = request.form.get('confirm_password')
        if new_password == confirm_password:
            user = utils.update_user(user_id=user_id,
                                     name=name,
                                     username=username,
                                     password=new_password)
            if user:
                return redirect(
                    url_for('user_manager', user_id=current_user.id))
    return render_template("Admin/information.html", user=user)
Beispiel #4
0
def logined(user_id):
    user = utils.get_user_by_id(user_id)
    return render_template("LogIned.html",
                           user=user,
                           list_ticket=utils.get_ticket_detail(user_id))
Beispiel #5
0
def get_user(user_id):
    return utils.get_user_by_id(user_id=user_id)
Beispiel #6
0
def report(user_id):
    return render_template("Admin/report.html",
                           user=utils.get_user_by_id(user_id),
                           list_report=utils.load_report())
Beispiel #7
0
def ticket_manager(user_id):
    return render_template("Admin/ticket_manager.html",
                           user=utils.get_user_by_id(user_id),
                           list_tickets=utils.load_tickets())