Esempio n. 1
0
def create_staff():
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/')
    new_staff = Staff.new(request.form)
    return redirect('/admin/account')
Esempio n. 2
0
def admin_edit(id):
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/')
    get_staff = Staff.get(id)
    print(get_staff)
    return render_template('accedit.html', staff=get_staff)
Esempio n. 3
0
def admin_acc():
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/store')
    cur_staff = Staff.get_all()
    print(cur_staff)
    return render_template('adaccount.html', staff=cur_staff)
Esempio n. 4
0
def staff_login():
    # print(' staff_login '*20)
    employee = Staff.validate_login(request.form)
    # print('*'*80,employee)
    if employee:
        session['employee_id'] = employee.id
        session['user_name'] = employee.first_name + ' ' + employee.last_name
        session['login_session'] = Staff.get_session_key(employee.id)
        if employee.user_level < 6:
            return redirect('/store')
        if employee.user_level >= 6:
            return redirect('/admin/dash')
    return redirect('/admin')
Esempio n. 5
0
def store():
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in(session['employee_id'],
                              session['login_session']):
        return redirect('/')
    orders = Order.get_entered()
    return render_template('restdash.html', orders=orders)
Esempio n. 6
0
def create_order_type():
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/')
    order_type = OrderType.new(request.form['name'])
    return redirect('/admin/dash#tabs-4')
Esempio n. 7
0
def update_topping_availability():
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/')
    print(request.form)
    return Topping.set_availability(request.form['topping_id'],
                                    request.form['availability'])
Esempio n. 8
0
def update_size(id):
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/')
    size = Size.query.get(id)
    size.update(request.form)
    return redirect('/admin/dash#tabs-3')
Esempio n. 9
0
def create_style():
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/')
    print(request.form)
    new_style = Style.new(request.form['name'], request.form['description'],
                          request.form['price'])
    return redirect('/admin/dash#tabs-2')
Esempio n. 10
0
def update_topping(id):
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/')
    print(request.form)
    topping = ToppingMenu.query.get(id)
    topping.update(request.form)
    return redirect('/admin/dash#tabs-1')
Esempio n. 11
0
def delete_user(id):
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/')
    staff_delete = Staff.query.get(id)
    #session['usr_id'] = staff_delete.id
    db.session.delete(staff_delete)
    db.session.commit()
    return redirect('/admin/account')
Esempio n. 12
0
def edit_user(id):
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/')
    staff_update = Staff.query.get(id)
    session['usr_id'] = staff_update.id
    print(staff_update.id)
    staff_update.edit_user(request.form)
    return redirect('/admin/account')
Esempio n. 13
0
def create_topping():
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/')
    print(request.form)
    new_topping = ToppingMenu.new(request.form['top_name'],
                                  request.form['description'],
                                  request.form['price'])
    # maybe change to Ajax partial:
    # return render_template('topping_menu_item.html',topping=new_topping)
    return redirect('/admin/dash')
Esempio n. 14
0
def admin_dash():
    if not 'employee_id' in session.keys():
        return redirect('/admin')
    if not Staff.is_logged_in_as_admin(session['employee_id'],
                                       session['login_session']):
        return redirect('/store')
    topping_menu = ToppingMenu.get_all()
    sizes = Size.get_all()
    styles = Style.get_all()
    order_types = OrderType.get_all()
    return render_template('admindash.html',
                           topping_menu=topping_menu,
                           sizes=sizes,
                           styles=styles,
                           order_types=order_types)