|
15 | 15 | from app.models.eventCohort import EventCohort |
16 | 16 | from app.models.term import Term |
17 | 17 | from app.logic.createLogs import createRsvpLog |
18 | | - |
| 18 | +from app.models.certification import Certification |
19 | 19 | def makeBonnerXls(selectedYear, noOfYears=1): |
20 | 20 | """ |
21 | 21 | Create and save a BonnerStudents.xlsx file with all of the current and former bonner students. |
@@ -44,10 +44,8 @@ def makeBonnerXls(selectedYear, noOfYears=1): |
44 | 44 | worksheet.set_column('D:D', 20) |
45 | 45 |
|
46 | 46 | # bonner event titles |
47 | | - bonnerEventsId = 1 |
48 | | - bonnerEvents = CertificationRequirement.select().where(CertificationRequirement.certification==bonnerEventsId).order_by(CertificationRequirement.order.asc()) |
| 47 | + bonnerEvents = CertificationRequirement.select().where(CertificationRequirement.certification==Certification.BONNER).order_by(CertificationRequirement.order.asc()) |
49 | 48 | bonnerEventInfo = {bonnerEvent.id:(bonnerEvent.name, index + 4) for index, bonnerEvent in enumerate(bonnerEvents)} |
50 | | - allBonnerSpreadsheetPosition = 7 |
51 | 49 | currentLetter = "E" # next column |
52 | 50 | for bonnerEvent in bonnerEvents: |
53 | 51 | worksheet.write(f"{currentLetter}1", bonnerEvent.name, bold) |
@@ -84,21 +82,19 @@ def makeBonnerXls(selectedYear, noOfYears=1): |
84 | 82 | .join(EventParticipant, on=(RequirementMatch.event == EventParticipant.event)) |
85 | 83 | .join(CertificationRequirement, on=(RequirementMatch.requirement == CertificationRequirement.id)) |
86 | 84 | .join(User, on=(EventParticipant.user == User.username)) |
87 | | - .where((CertificationRequirement.certification_id == bonnerEventsId) & (User.username == student.user.username)) |
| 85 | + .where((CertificationRequirement.certification_id == Certification.BONNER) & (User.username == student.user.username)) |
88 | 86 | ) |
89 | 87 |
|
90 | | - allBonnerMeetingDates = [] |
| 88 | + certRequirementDates = {} |
91 | 89 | for attendedEvent in bonnerEventsAttended: |
92 | 90 | if bonnerEventInfo.get(attendedEvent.requirement.id): |
93 | 91 | completedEvent = bonnerEventInfo[attendedEvent.requirement.id] |
94 | | - worksheet.write(row, completedEvent[1], attendedEvent.event.startDate.strftime('%m/%d/%Y')) |
95 | | - if completedEvent[0] == "All Bonner Meeting": |
96 | | - allBonnerMeetingDates.append(attendedEvent.event.startDate.strftime('%m/%d/%Y')) |
97 | | - else: |
98 | | - raise Exception("Untracked requirements found in attended events. Debug required.") |
99 | | - |
100 | | - worksheet.write(row, allBonnerSpreadsheetPosition, ", ".join(sorted(allBonnerMeetingDates))) |
| 92 | + if completedEvent[1] not in certRequirementDates: |
| 93 | + certRequirementDates[completedEvent[1]] = [] |
| 94 | + certRequirementDates[completedEvent[1]].append(attendedEvent.event.startDate.strftime('%m/%d/%Y')) |
101 | 95 |
|
| 96 | + for tableIndex, dates in certRequirementDates.items(): |
| 97 | + worksheet.write(row, tableIndex, ", ".join(sorted(dates))) |
102 | 98 | row += 1 |
103 | 99 |
|
104 | 100 | workbook.close() |
|
0 commit comments