Skip to content

Commit ea73af4

Browse files
Google sheet sync (#36)
* google sheet sync fixed * indentation fix * indentaion fix
1 parent 99c6258 commit ea73af4

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
lines changed

attendance/models.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -369,23 +369,6 @@ def parse_slug_super_batch(self):
369369
self.super_batch_id = int(self.scaler_class_url.split("/")[5])
370370
self.class_topic_slug = self.scaler_class_url.split("/")[7]
371371

372-
def get_all_students_attendance_status(self):
373-
allClassAttendance = self.get_all_attendance()
374-
375-
json_attendance = []
376-
mail_set = set()
377-
for attendance in allClassAttendance:
378-
json_attendance.append((attendance.student, attendance.attendance_status))
379-
mail_set.add(attendance.student.mail)
380-
381-
all_students = Student.get_all_students()
382-
383-
for student in all_students:
384-
if student.mail not in mail_set:
385-
json_attendance.append((student, AttendanceStatus.Absent))
386-
387-
return json_attendance
388-
389372
@classmethod
390373
def get_current_class(cls):
391374
cache_key = "get_current_class"

attendance/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,10 @@ def fetchLatestAttendances(
251251
details["attendance_start_time"] = current_class.attendance_start_time
252252
details["attendance_end_time"] = current_class.attendance_end_time
253253

254-
all_attendance = current_class.get_all_attendance()
254+
students = current_class.get_all_attendance()
255255
json_attendance = []
256256

257-
for student in all_attendance:
257+
for student in students:
258258
attendance = student.attendance
259259
json_attendance.append(
260260
{

utils/push_to_google_sheet.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ def get_col_for_subject_class(sheet, subject_class):
6666

6767

6868
def get_attendance_mapping(mails, subject_class):
69-
attendances = subject_class.get_all_attendance()
69+
students = subject_class.get_all_attendance()
7070
status_map = {}
71-
for att in attendances:
72-
status_map[att.student.mail] = (
73-
1 if AttendanceStatus.Present == att.attendance_status else 0
71+
for student in students:
72+
status_map[student.mail] = (
73+
1
74+
if student.attendance
75+
and (AttendanceStatus.Present == student.attendance.attendance_status)
76+
else 0
7477
)
7578

7679
return_status = []

0 commit comments

Comments
 (0)