Skip to content

Commit

Permalink
src
Browse files Browse the repository at this point in the history
  • Loading branch information
carmen904c committed Feb 10, 2024
1 parent 7bfc460 commit e65cb0c
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 92 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
176 changes: 87 additions & 89 deletions vsvs_scheduler/main.py → src/main.py
Original file line number Diff line number Diff line change
@@ -1,89 +1,87 @@
import csv, os, logging
from scheduler import Scheduler
from globals import ASSIGNMENTS_DIRECTORY, MIN_TEAM_SIZE


def main():
logging.basicConfig(filename='vsvs_scheduler.log', filemode='w', format='%(levelname)s - %(message)s', level=logging.DEBUG)

vsvs_scheduler = Scheduler()
partner_errors = vsvs_scheduler.create_assignments()

if not os.path.isdir(ASSIGNMENTS_DIRECTORY):
os.mkdir(ASSIGNMENTS_DIRECTORY)

results_file_path = os.path.join(ASSIGNMENTS_DIRECTORY, 'assignments.csv')

with open(results_file_path, 'w', newline='') as assignments_csv:
csv_writer = csv.writer(assignments_csv, delimiter=',')
csv_writer.writerow(
['Group Number', 'First Name', 'Last Name', 'Email', 'Phone Number', 'Team Leader', 'Board Member',
'Teacher', 'Day', 'Start Time', 'End Time']
)

group_num = 1
for classroom in vsvs_scheduler.classrooms:
if len(classroom.volunteers) >= MIN_TEAM_SIZE:
for volunteer in classroom.volunteers:
csv_writer.writerow(
[
group_num,
volunteer.first,
volunteer.last,
volunteer.email,
volunteer.phone,
(lambda x: 'True' if x else '')(volunteer.assigned_leader),
(lambda x: 'True' if x else '')(volunteer.board),
classroom.teacher.name,
classroom.weekday,
classroom.start_time.strftime('%I:%M %p'),
classroom.end_time.strftime('%I:%M %p')
]
)
group_num += 1

unassigned_file_path = os.path.join(ASSIGNMENTS_DIRECTORY, 'unassigned.csv')
with open(unassigned_file_path, 'w', newline='') as unassigned_csv:
csv_writer = csv.writer(unassigned_csv, delimiter=',')
csv_writer.writerow(
[ 'Group', 'First Name', 'Last Name', 'Email', 'Phone Number', 'Team Leader', 'Board Member', 'Teacher',
'Availability', 'Start', 'End', 'Day']
)
for classroom in vsvs_scheduler.classrooms:
if len(classroom.volunteers) < MIN_TEAM_SIZE:
csv_writer.writerow(
[
'',
'',
classroom.teacher.name,
classroom.teacher.email,
classroom.teacher.phone,
'',
'',
'True',
'',
classroom.start_time.strftime('%I:%M %p'),
classroom.end_time.strftime('%I:%M %p'),
classroom.teacher.weekday
]
)
csv_writer.writerow(['']*6)

for volunteer in vsvs_scheduler.volunteers:
if volunteer.group_number == -1:
csv_writer.writerow(
[
0,
volunteer.first,
volunteer.last,
volunteer.email,
volunteer.phone,
(lambda x: 'True' if x else '')(volunteer.assigned_leader),
(lambda x: 'True' if x else '')(volunteer.board),
]
)


# runs main
if __name__ == '__main__':
main()
import csv, os, logging
from scheduler import Scheduler
from globals import ASSIGNMENTS_DIRECTORY, MIN_TEAM_SIZE


def main():
logging.basicConfig(filename='vsvs_scheduler.log', filemode='w', format='%(levelname)s - %(message)s', level=logging.DEBUG)

vsvs_scheduler = Scheduler()
partner_errors = vsvs_scheduler.create_assignments()

if not os.path.isdir(ASSIGNMENTS_DIRECTORY):
os.mkdir(ASSIGNMENTS_DIRECTORY)

results_file_path = os.path.join(ASSIGNMENTS_DIRECTORY, 'assignments.csv')

with open(results_file_path, 'w', newline='') as assignments_csv:
csv_writer = csv.writer(assignments_csv, delimiter=',')
csv_writer.writerow(
['Group Number', 'First Name', 'Last Name', 'Email', 'Phone Number', 'Team Leader', 'Board Member',
'Teacher', 'Day', 'Start Time', 'End Time']
)

group_num = 1
for classroom in vsvs_scheduler.classrooms:
if len(classroom.volunteers) >= MIN_TEAM_SIZE:
for volunteer in classroom.volunteers:
csv_writer.writerow(
[
group_num,
volunteer.first,
volunteer.last,
volunteer.email,
volunteer.phone,
(lambda x: 'True' if x else '')(volunteer.assigned_leader),
(lambda x: 'True' if x else '')(volunteer.board),
classroom.teacher.name,
classroom.weekday,
classroom.start_time.strftime('%I:%M %p'),
classroom.end_time.strftime('%I:%M %p')
]
)
group_num += 1

unassigned_file_path = os.path.join(ASSIGNMENTS_DIRECTORY, 'unassigned.csv')
with open(unassigned_file_path, 'w', newline='') as unassigned_csv:
csv_writer = csv.writer(unassigned_csv, delimiter=',')
csv_writer.writerow(
[ 'Group', 'First Name', 'Last Name', 'Email', 'Phone Number', 'Team Leader', 'Board Member', 'Teacher',
'Availability', 'Start', 'End', 'Day']
)
for classroom in vsvs_scheduler.classrooms:
if len(classroom.volunteers) < MIN_TEAM_SIZE:
csv_writer.writerow(
[
'',
'',
classroom.teacher.name,
classroom.teacher.email,
classroom.teacher.phone,
'',
'',
'True',
'',
classroom.start_time.strftime('%I:%M %p'),
classroom.end_time.strftime('%I:%M %p'),
classroom.teacher.weekday
]
)
csv_writer.writerow(['']*6)

for volunteer in vsvs_scheduler.volunteers:
if volunteer.group_number == -1:
csv_writer.writerow(
[
0,
volunteer.first,
volunteer.last,
volunteer.email,
volunteer.phone,
(lambda x: 'True' if x else '')(volunteer.assigned_leader),
(lambda x: 'True' if x else '')(volunteer.board),
]
)

if __name__ == '__main__':
main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from vsvs_scheduler.globals import TEACHER_COLUMNS, VOLUNTEER_COLUMNS, PARTNER_COLUMNS
from src.globals import TEACHER_COLUMNS, VOLUNTEER_COLUMNS, PARTNER_COLUMNS

@pytest.fixture
def classroom_data():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_data_uploader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from vsvs_scheduler.data_uploader import DataUploader
from vsvs_scheduler.globals import TEACHER_COLUMNS, VOLUNTEER_COLUMNS, PARTNER_COLUMNS
from src.data_uploader import DataUploader
from src.globals import TEACHER_COLUMNS, VOLUNTEER_COLUMNS, PARTNER_COLUMNS

@pytest.fixture
def data_uploader():
Expand Down

0 comments on commit e65cb0c

Please sign in to comment.