feat: add student list view with attendance statistics and configure project gitignore
This commit is contained in:
parent
b8f2bbbadf
commit
994f4db5e1
3 changed files with 244 additions and 243 deletions
|
|
@ -12,14 +12,15 @@ def record_attendance(request):
|
|||
if request.method == 'POST':
|
||||
student_ids = request.POST.getlist('student_id')
|
||||
current_datetime = datetime.now()
|
||||
one_hour_ago = current_datetime - timedelta(hours=1)
|
||||
# one_hour_ago = current_datetime - timedelta(hours=1)
|
||||
four_hours_ago = current_datetime - timedelta(hours=4)
|
||||
|
||||
for student_id in student_ids:
|
||||
try:
|
||||
student = Student.objects.get(student_id=student_id)
|
||||
|
||||
# 檢查該學生在一小時內是否有點名紀錄
|
||||
if not PointRecord.objects.filter(student=student, datetime__gte=one_hour_ago).exists():
|
||||
# 檢查該學生在4小時內是否有點名紀錄
|
||||
if not PointRecord.objects.filter(student=student, datetime__gte=four_hours_ago).exists():
|
||||
point_record = PointRecord.objects.create(student=student, datetime=current_datetime)
|
||||
point_records.append(point_record)
|
||||
except Student.DoesNotExist:
|
||||
|
|
|
|||
Loading…
Reference in a new issue