def createSlot(): slot_name = request.form['slot_name'] slot_type = request.form['slot_type'] slot_obj = Slot(name=slot_name, type_slot=slot_type) db.session.add(slot_obj) db.session.commit() return render_template("success.html", message="Added slot to DB")
def set_slot(num: int) -> Slot: """Set roulette Slot numbers and colors.""" blacks: List[int] = [ 2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33, 35 ] color = 'RED' if num in blacks: color = 'BLACK' elif num == 0: color = 'WHITE' return Slot(number=num, color=color)
def put(self, jwt): body = request.get_json() title = body['title'] description = body['description'] start_time = body['start_time'] capacity = body['capacity'] try: slot = Slot() slot.title = title slot.description = description slot.start_time = start_time slot.capacity = capacity db.session.add(slot) db.session.commit() except: db.session.rollback() abort(422, "unprocessable") return jsonify( { "success": True, "id": slot.id } )