def update_work_end_time(message): global end_time end_time = message.text update_schedule(chat_id=message.chat.id, day=day, start_time=start_time, end_time=end_time) bot.send_message(message.from_user.id, "Ինֆորմացիան հաջողությամբ խմբագրված է ։")
def schedule(): if not "uid" in session: return redirect("/") if request.method == "GET": # fetch current schedule return render_template("schedule.html") if request.method == "POST": period_1 = request.form["period-1"] period_2 = request.form["period-2"] period_3 = request.form["period-3"] period_4 = request.form["period-4"] period_5 = request.form["period-5"] period_6 = request.form["period-6"] period_7 = request.form["period-7"] period_8 = request.form["period-8"] period_9 = request.form["period-9"] period_10 = request.form["period-10"] db.update_schedule(session["uid"], (period_1, period_2, period_3, period_4, period_5, period_6, period_7, period_8, period_9, period_10)); return redirect(url_for("user", id=session["uid"]))
def editSchedule(): user = db.find_user({'username': session['username']}) if request.method == 'GET': return render_template('edit_schedule.html', staff=staff, user=user) else: button = request.form['button'] if button == 'cancel': return redirect('/') else: user = db.find_user({'username': session['username']}) sL = [] xd = 1 while xd != 11: sL.append(request.form['teacher' + str(xd)]) xd += 1 while xd != 21: sL.append(request.form['course' + str(xd - 10)]) xd += 1 db.update_schedule(user, sL) return redirect('/view_schedule')
def editSchedule(): user = db.find_user({'username': session['username']}) if request.method == 'GET': return render_template('edit_schedule.html', staff=staff, user=user) else: button = request.form['button'] if button == 'cancel': return redirect('/') else: user = db.find_user({'username': session['username']}) sL=[] xd = 1 while xd !=11: sL.append( request.form['teacher'+str(xd)]) xd+= 1 while xd !=21: sL.append(request.form['course'+str(xd-10)]) xd+=1 db.update_schedule(user,sL) return redirect('/view_schedule')
def schedule_update(schedule_id): try: data = request.get_json() except BaseException: logger.error("Error reading the request body") return jsonify({"message": "invalid request"}) schedule = get_schedule(schedule_id) if schedule is not None and data.get('enable_schedule') is False and \ schedule.enable_schedule is True: update_relay(schedule.id, schedule.device_id, OFF) update_schedule( schedule_id, start_schedule=data.get('start_schedule'), end_schedule=data.get('end_schedule'), enabled=int(data.get('enable_schedule')), device_id=data.get('device_id'), sensor=SensorEnum(data.get('sensor')) if data.get('sensor') else None, sensor_min=data.get('sensor_min'), sensor_max=data.get('sensor_max'), ) return jsonify({"message": "schedule was updated successfully"})
def update_relay(schedule_id, device_id, state): logger.debug("Setting relay state to %s for: %d", 'ON' if state == ON else 'OFF', device_id) set_relay(device_id, state) update_schedule(schedule_id, device_id=device_id, last_state=state)