def add_assignment(data): name = data['name'] assignment = Assignment(name=name) db.session.add(assignment) db.session.commit() emit_state(['assignments'], broadcast=True) db.session.refresh(assignment) return assignment_json(assignment)
def seed_data(): print('Seeding...') assignments = [ Assignment(name=name) for name in ['Hog', 'Maps', 'Ants', 'Scheme'] ] locations = [ Location(name=name) for name in ['109 Morgan', '241 Cory', '247 Cory'] ] questions = list(range(1, 16)) + ['Other', 'EC', 'Checkoff'] descriptions = ['', 'I\'m in the hallway', 'SyntaxError on Line 5'] for assignment in assignments: db.session.add(assignment) for location in locations: db.session.add(location) for i in range(50): real_name = names.get_full_name() first_name, last_name = real_name.lower().split(' ') email = '{0}{1}@{2}'.format( random.choice([first_name, first_name[0]]), random.choice([last_name, last_name[0]]), random.choice(['berkeley.edu', 'gmail.com']), ) student = User.query.filter_by(email=email).one_or_none() if not student: student = User(name=real_name, email=email) db.session.add(student) db.session.commit() delta = datetime.timedelta(minutes=random.randrange(0, 30)) ticket = Ticket( user=student, status=TicketStatus.pending, created=datetime.datetime.utcnow() - delta, assignment=random.choice(assignments), location=random.choice(locations), question=random.choice(questions), description=random.choice(descriptions), ) db.session.add(ticket) db.session.commit()
def seed_data(): print('Seeding...') assignments = [Assignment(name=name, course="ok", visible=True) for name in ['Hog', 'Maps', 'Ants', 'Scheme']] locations = [Location(name=name, course="ok", visible=True, online=True, link="") for name in ['109 Morgan', '241 Cory', '247 Cory']] questions = list(range(1, 16)) + ['Other', 'EC', 'Checkoff'] descriptions = ['', 'I\'m in the hallway', 'SyntaxError on Line 5'] students = [] for i in range(50): real_name = names.get_full_name() first_name, last_name = real_name.lower().split(' ') email = '{0}{1}@{2}'.format( random.choice([first_name, first_name[0]]), random.choice([last_name, last_name[0]]), random.choice(['berkeley.edu', 'gmail.com']), ) student = User.query.filter_by(email=email).one_or_none() if not student: student = User(name=real_name, email=email, course="ok") students.append(student) db.session.add(student) db.session.commit() delta = datetime.timedelta(minutes=random.randrange(0, 30)) ticket = Ticket( user=student, status=TicketStatus.pending, created=datetime.datetime.utcnow() - delta, assignment=random.choice(assignments), location=random.choice(locations), question=random.choice(questions), description=random.choice(descriptions), course="ok" ) db.session.add(ticket) appointments = [Appointment( start_time=datetime.datetime.now() + datetime.timedelta(hours=random.randrange(-8, 50)), duration=datetime.timedelta(minutes=random.randrange(30, 120, 30)), location=random.choice(locations), capacity=5, status=AppointmentStatus.pending, course="ok", helper=random.choice(students) ) for _ in range(70)] for assignment in assignments: db.session.add(assignment) for location in locations: db.session.add(location) for appointment in appointments: db.session.add(appointment) db.session.commit() signups = [AppointmentSignup( appointment=random.choice(appointments), user=random.choice(students), assignment=random.choice(assignments), question=random.choice(questions), description=random.choice(descriptions), course="ok", ) for _ in range(120)] for signup in signups: db.session.add(signup) db.session.commit() groups = [ Group( group_status=GroupStatus.active, question=random.choice(questions), assignment=random.choice(assignments), location=random.choice(locations), attendees=[GroupAttendance( user=student, group_attendance_status=GroupAttendanceStatus.present, course="ok" ) for student in random.sample(students, 5)], call_url="", doc_url="", course="ok", ) for _ in range(120)] for group in groups: db.session.add(group) db.session.commit()
def seed_data(): print("Seeding...") assignments = [ Assignment(name=name, course=get_course(), visible=True) for name in ["Hog", "Maps", "Ants", "Scheme"] ] locations = [ Location(name=name, course=get_course(), visible=True, online=False, link="") for name in ["109 Morgan", "241 Cory", "247 Cory"] ] questions = list(range(1, 16)) + ["Other", "EC", "Checkoff"] descriptions = ["", "I'm in the hallway", "SyntaxError on Line 5"] appointments = [ Appointment( start_time=datetime.datetime.now() + datetime.timedelta(hours=random.randrange(-8, 50)), duration=datetime.timedelta(minutes=random.randrange(30, 120, 30)), location=random.choice(locations), capacity=5, status=AppointmentStatus.pending, course=get_course(), ) for _ in range(70) ] for assignment in assignments: db.session.add(assignment) for location in locations: db.session.add(location) for appointment in appointments: db.session.add(appointment) db.session.commit() students = [] for i in range(50): real_name = names.get_full_name() first_name, last_name = real_name.lower().split(" ") email = "{0}{1}@{2}".format( random.choice([first_name, first_name[0]]), random.choice([last_name, last_name[0]]), random.choice(["berkeley.edu", "gmail.com"]), ) student = User.query.filter_by(email=email).one_or_none() if not student: student = User(name=real_name, email=email, course=get_course()) students.append(student) db.session.add(student) db.session.commit() delta = datetime.timedelta(minutes=random.randrange(0, 30)) ticket = Ticket( user=student, status=TicketStatus.pending, created=datetime.datetime.utcnow() - delta, assignment=random.choice(assignments), location=random.choice(locations), question=random.choice(questions), description=random.choice(descriptions), course=get_course(), ) db.session.add(ticket) signups = [ AppointmentSignup( appointment=random.choice(appointments), user=random.choice(students), assignment=random.choice(assignments), question=random.choice(questions), description=random.choice(descriptions), course=get_course(), ) for _ in range(120) ] for signup in signups: db.session.add(signup) db.session.commit()