예제 #1
0
def get_online_location():
    online_location = Location.query.filter_by(course=get_course(), name="Online").one_or_none()
    online_visible = ConfigEntry.query.filter_by(key="online_active", course=get_course()).one().value == "true"
    if online_location is None:
        online_location = Location(name="Online", visible=online_visible, course=get_course())
        db.session.add(online_location)
        db.session.commit()
    else:
        online_location.visible = online_visible
        db.session.commit()
    return online_location
예제 #2
0
파일: views.py 프로젝트: aleggs/oh-queue
def add_location(data):
    name = data['name']
    location = Location(name=name)
    db.session.add(location)
    db.session.commit()

    emit_state(['locations'], broadcast=True)
    db.session.refresh(location)
    return location_json(location)
예제 #3
0
def add_location(data):
    name = data['name']
    if name == "Online":
        return
    location = Location(name=name, course=get_course())
    db.session.add(location)
    db.session.commit()

    emit_state(['locations'], broadcast=True)
    db.session.refresh(location)
    return location_json(location)
예제 #4
0
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()
예제 #5
0
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()
예제 #6
0
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()