Example #1
0
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")
Example #2
0
 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
Example #3
0
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")
Example #4
0
 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
Example #5
0
def getCourses():
    courses = Courses.getAll()
    return render_template("courses.html", data=enumerate(courses, 1))
Example #6
0
def deleteCourse(id):
    courses = Courses.findById(id)
    courses.delete()
    return redirect("/courses")
Example #7
0
def updateCoursesForm(id):
    courses = Courses.getById(id)
    return render_template("courses_update.html", data=courses)
Example #8
0
 def __init__(self, colleger_id, courses_id):
     self.colleger_id = Colleger.findById(colleger_id).id
     self.courses_id = Courses.findById(courses_id).id