def createCourses(): name = request.form["name"] sks = int(request.form["sks"]) semester = int(request.form["semester"]) courses = Courses(name=name, sks=sks, semester=semester) courses.save() return redirect("/courses")
def getById(id): data = TakeCourse.findById(id) result = { "id": data.id, "colleger": Colleger.getById(data.colleger_id), "courses": Courses.getById(data.courses.id), "value": data.value } return result
def updateCourses(id): courses = Courses.findById(id) name = request.form["name"] sks = int(request.form["sks"]) semester = int(request.form["semester"]) courses.name = name courses.sks = sks courses.semester = semester courses.save() return redirect("/courses")
def getAll(): data = TakeCourse.query.all() result = list() for value in data: obj = { "id": value.id, "colleger": Colleger.getById(value.colleger_id), "courses": Courses.getById(value.courses.id), "value": value.value } result.append(obj) return result
def getCourses(): courses = Courses.getAll() return render_template("courses.html", data=enumerate(courses, 1))
def deleteCourse(id): courses = Courses.findById(id) courses.delete() return redirect("/courses")
def updateCoursesForm(id): courses = Courses.getById(id) return render_template("courses_update.html", data=courses)
def __init__(self, colleger_id, courses_id): self.colleger_id = Colleger.findById(colleger_id).id self.courses_id = Courses.findById(courses_id).id