def get_attendance_list(date):
        """
        Sets the state of the presence each student at today
        :param date: str 'YYYY-MM-DD'
        :return list_of_attendance: list with Attendance objects
        """

        # EXAMPLE: today = '2017-03-07', date = '2017-03-07'
        today = str(datetime.date.today())
        attendance = Attendance.query.filter_by(DATE=date).first()

        if today == date:
            if attendance:
                pass
            else:
                for student in Student.students_list():
                    new_attendance = Attendance(id_student=student.ID,
                                                date=today)
                    db.session.add(new_attendance)
                db.session.commit()
        list_of_attendance = Attendance.create_attendance_list(date)

        return list_of_attendance
Example #2
0
def student_list():
    table = Student.students_list()
    if table:
        return render_template('student/student_list.html', table=table, user=session['user'])
    return render_template('student/student_list.html', user=session['user'])