def enters(un): db = get_db() dbase = FDataBase(db) res = dbase.get_by_number(un) status = res['Status'] if status =="работник охраны": Data = dbase.get_enters_db() en = list() sna = list() na = list() foto = list() time = list() for d in Data: en.append(d['Entry']) sna.append(d['Surname']) na.append(d['Name']) foto.append('/static/image/'+d['Foto']) time.append(d['Time']) length = len(en) return render_template('enters.html', UN=un, EN=en, Sna=sna, Name=na, Foto=foto, Time=time, LEN=length) else: flash('У вас нет доступа к данным пропусконого пункта', category='error') global _current_un _current_un = un return redirect('/profile')
def profile(un): db = get_db() dbase = FDataBase(db) res = dbase.get_by_number(un) na = res['Name'] sna = res['Surname'] st = res['Status'] f = '/static/image/'+res['Foto'] return render_template('profile.html', UN=un, Status=st, Name=na, Surname=sna, Foto=f)
def allert_post(un): db = get_db() dbase = FDataBase(db) t = datetime.now() dbase.add_disturbance('Кнопка тревоги', int(1), t) global _current_un _current_un = un flash('Сработала кнопка тревоги', category='error') return redirect('/profile')
def out(un): db = get_db() dbase = FDataBase(db) res = dbase.get_by_number(un) na = res['Name'] sna = res['Surname'] st = res['Status'] f = res['Foto'] t = datetime.now() dbase.add_entery(un, na, sna, st, f, 'Вышел', t) return redirect('/')
def add_number_get(un): db = get_db() dbase = FDataBase(db) res = dbase.get_by_number(un) status = res['Status'] if status =="работник отдела кадров": return render_template('add_number.html', UN=un) else: flash('У вас нет доступа к добавлению новых работников', category='error') global _current_un _current_un = un return redirect('/profile')
def index_post(): db = get_db() dbase = FDataBase(db) un = request.form['UN'] tmp = dbase.get_by_number(un) if tmp != False: global _current_un _current_un = un na = tmp['Name'] sna = tmp['Surname'] st = tmp['status'] f = tmp['Foto'] t = datetime.now() dbase.add_entery(un, na, sna, st, f, 'Зашол', t) foto = '/static/image/'+f flash('Успешный вход ', category='success') return render_template('profile.html', UN=un, Status=st, Name=na, Surname=sna,Foto=foto) else: flash('Ошибка входа ', category='error') return render_template('index.html', UN=0)
def sensors_post(un): db = get_db() dbase = FDataBase(db) res = dbase.get_by_number(un) status = res['Status'] if status =="работник охраны": sen = get_sensors() for s in sen: s.install_state() if s.status == 'Обнаружено нарушение': t = datetime.now() dbase.add_disturbance(s.type, s.id,t) sen_db = dbase.get_disturbance() type = list() id = list() time = list() for d in sen_db: type.append(d['Type']) id.append(d['number']) time.append(d['Time']) length = len(id) return render_template('Sensors.html', UN=un, Sensors=sen, Type=type, Time=time, ID=id, LEN=length) else: flash('У вас нет доступа к показаниям датчиков', category='error') global _current_un _current_un = un return redirect('/profile')
def add_number_post(un): db = get_db() dbase = FDataBase(db) res = dbase.get_by_number(un) status = res['Status'] if status =="работник отдела кадров": UN = request.form['UN'] Name = request.form['Name'] Surname = request.form['Surname'] Foto = request.form['Foto'] Status = request.form['Status'] res = dbase.add_number(UN, Name, Surname, Foto, Status) if not res: flash('Ошибка добавления ', category='error') else: flash('Успешное добавление ', category='success') return render_template('add_number.html', UN=un) else: flash('У вас нет доступа к добавлению новых работников', category='error') global _current_un _current_un = un return redirect('/profile')