Example #1
0
def create(data, fail_silently=False):
    students_affected = (
        Student.select(Student.id)
        .join(StudentToGroup)
        .join(Group)
        .where(Group.id == data['group'])
    )
    count_conflict_lessons = (
        Lesson.select()
        .join(Room).switch(Lesson)
        .join(Lecturer).switch(Lesson)
        .join(Group).join(StudentToGroup).join(Student).switch(Lesson)
        .where(
            (Lesson.date == data['date'])
            & (
                (data['start'] >= Lesson.start) & (data['start'] <= Lesson.end)
                | (data['end'] >= Lesson.start) & (  data['end'] <= Lesson.end)
            )
            & (
                (Lesson.room == data['room'])
                | (Lesson.lecturer == data['lecturer'])
                | (Lesson.group == data['group'])
            )
        )
        .group_by(Lesson)
        .count()
    )
    if (count_conflict_lessons == 0):
        l = Lesson(**data)
        l.save()
    elif not fail_silently:
        raise Exception(f'Lessons conflicting: {count_conflict_lessons}')
Example #2
0
def select():
    try:
         pk = int(request.args.get('id'))
         student = Student.select().where(Student.id == pk)
  	 return render_template('update.html', student=student[0])
    except Exception as e:
        flash(str(e))
Example #3
0
def students():
    return Student.select()
Example #4
0
def home():
    students = Student.select()
    return render_template("users_table.html", students=students)
Example #5
0
def index():
    students = Student.select()
    return render_template('index.html', students=students)