예제 #1
0
def insert_admin():
    Session.initialize_db(initialize=True)
    with Session() as session:
        if session.insert_test_admin_account():
            print("Test admin account created successfully")
        else:
            print("Not allowed to create admin account at this time")
예제 #2
0
def notify_admins_of_pending_emails():
    from uber.tasks.email import notify_admins_of_pending_emails as notify_admins
    Session.initialize_db(initialize=True)
    results = timed(notify_admins)()
    if results:
        print('Notification emails sent to:\n{}'.format(
            dumps(results, indent=2, sort_keys=True)))
예제 #3
0
def send_automated_emails():
    from uber.tasks.email import send_automated_emails as send_emails
    Session.initialize_db(initialize=True)
    timed(AutomatedEmail.reconcile_fixtures)()
    results = timed(send_emails)()
    if results:
        print('Unapproved email counts:\n{}'.format(dumps(results, indent=2, sort_keys=True)))
예제 #4
0
def insert_admin():
    Session.initialize_db(initialize=True)
    with Session() as session:
        if session.insert_test_admin_account():
            print("Test admin account created successfully")
        else:
            print("Not allowed to create admin account at this time")
예제 #5
0
def resave_all_attendees_and_groups():
    """
    Re-save all valid attendees and groups in the database. this is useful to re-run all validation code
    and allow re-calculation of automatically calculated values.  This is sometimes needed when
    doing database changes and we need to re-save everything.

    SAFETY: This -should- be safe to run at any time, but, for safety sake, recommend turning off
    any running sideboard servers before running this command.
    """
    Session.initialize_db(modify_tables=False, drop=False, initialize=True)
    with Session() as session:
        print("Re-saving all attendees....")
        for a in session.valid_attendees():
            try:
                a.presave_adjustments()
                session.add(a)
                session.commit()
            except Exception:
                pass
        print("Re-saving all groups....")
        for g in session.query(Group).all():
            try:
                g.presave_adjustments()
                session.add(g)
                session.commit()
            except Exception:
                pass
    print("Done!")
예제 #6
0
def send_automated_emails():
    from uber.tasks.email import send_automated_emails as send_emails
    Session.initialize_db(initialize=True)
    timed(AutomatedEmail.reconcile_fixtures)()
    results = timed(send_emails)()
    if results:
        print('Unapproved email counts:\n{}'.format(dumps(results, indent=2, sort_keys=True)))
예제 #7
0
def resave_all_staffers():
    """
    Re-save all staffers in the database, and re-assign all badge numbers.

    SAFETY: This -should- be safe to run at any time, but, for safety sake,
    recommend turning off any running sideboard servers before running this
    command.
    """
    assert c.BEFORE_PRINTED_BADGE_DEADLINE, \
        'resave_all_staffers is only available before badge numbers have been sent to the printer'
    Session.initialize_db(modify_tables=False, drop=False, initialize=True)
    with Session() as session:
        staffers = session.query(Attendee).filter_by(
            badge_type=c.STAFF_BADGE).all()

        first_staff_badge_num = c.BADGE_RANGES[c.STAFF_BADGE][0]
        last_staff_badge_num = c.BADGE_RANGES[c.STAFF_BADGE][1]
        assert len(staffers) < last_staff_badge_num - first_staff_badge_num + 1, \
            'not enough free staff badges, please increase limit'

        badge_num = first_staff_badge_num

        print("Re-saving all staffers....")
        for a in staffers:
            a.presave_adjustments()
            a.badge_num = badge_num
            badge_num += 1
            assert badge_num <= last_staff_badge_num
        print(
            "Saving resulting changes to database (can take a few minutes)...")
    print("Done!")
예제 #8
0
def has_admin():
    Session.initialize_db(initialize=True)
    with Session() as session:
        if session.query(AdminAccount).first() is None:
            print('Could not find any admin accounts', file=sys.stderr)
            sys.exit(1)
        else:
            print('At least one admin account exists', file=sys.stderr)
            sys.exit(0)
예제 #9
0
def has_admin():
    Session.initialize_db(initialize=True)
    with Session() as session:
        if session.query(AdminAccount).first() is None:
            print('Could not find any admin accounts', file=sys.stderr)
            sys.exit(1)
        else:
            print('At least one admin account exists', file=sys.stderr)
            sys.exit(0)
예제 #10
0
def import_uber_test_data(test_data_file):
    with open(test_data_file) as f:
        global dump
        dump = json.load(f)

    Session.initialize_db(initialize=True)
    with Session() as session:
        import_groups(session)
        import_attendees(session)
        import_events(session)
        import_jobs(session)
예제 #11
0
def decline_and_convert_dealer_groups():
    from uber.site_sections.groups import _decline_and_convert_dealer_group
    Session.initialize_db(initialize=True)
    with Session() as session:
        groups = session.query(Group) \
            .filter(Group.tables > 0, Group.status == c.WAITLISTED) \
            .options(
                subqueryload(Group.attendees).subqueryload(Attendee.admin_account),
                subqueryload(Group.attendees).subqueryload(Attendee.shifts)) \
            .order_by(Group.name, Group.id).all()

        for group in groups:
            print('{}: {}'.format(
                group.name, _decline_and_convert_dealer_group(session, group)))
예제 #12
0
def decline_and_convert_dealer_groups():
    from uber.site_sections.groups import _decline_and_convert_dealer_group
    Session.initialize_db(initialize=True)
    with Session() as session:
        groups = session.query(Group) \
            .filter(Group.tables > 0, Group.status == c.WAITLISTED) \
            .options(
                subqueryload(Group.attendees).subqueryload(Attendee.admin_account),
                subqueryload(Group.attendees).subqueryload(Attendee.shifts)) \
            .order_by(Group.name, Group.id).all()

        for group in groups:
            print('{}: {}'.format(
                group.name,
                _decline_and_convert_dealer_group(session, group)))
def import_uber_test_data(test_data_file):
    if not c.JOB_LOCATION_OPTS:
        print("JOB_LOCATION_OPTS is empty! "
        "Try copying the [[job_location]] section from test-defaults.ini to your development.ini.")
        exit(1)

    with open(test_data_file) as f:
        global dump
        dump = json.load(f)

    Session.initialize_db(initialize=True)
    with Session() as session:
        import_groups(session)
        import_attendees(session)
        import_events(session)
        import_jobs(session)
예제 #14
0
def resave_all_attendees_and_groups():
    """
    Re-save all attendees and groups in the database. this is useful to re-run all validation code
    and allow re-calculation of automatically calculated values.  This is sometimes needed when
    doing database changes and we need to re-save everything.

    SAFETY: This -should- be safe to run at any time, but, for safety sake, recommend turning off
    any running sideboard servers before running this command.
    """
    Session.initialize_db(modify_tables=False, drop=False, initialize=True)
    with Session() as session:
        print("Re-saving all attendees....")
        [a.presave_adjustments() for a in session.query(Attendee).all()]
        print("Re-saving all groups....")
        [g.presave_adjustments() for g in session.query(Group).all()]
        print("Saving resulting changes to database (can take a few minutes)...")
    print("Done!")
예제 #15
0
def init_worker_process(*args, **kwargs):
    Session.initialize_db(initialize=True)
예제 #16
0
def drop_uber_db():
    assert c.DEV_BOX, 'drop_uber_db is only available on development boxes'
    Session.initialize_db(modify_tables=False, drop=True)
예제 #17
0
def notify_admins_of_pending_emails():
    from uber.tasks.email import notify_admins_of_pending_emails as notify_admins
    Session.initialize_db(initialize=True)
    results = timed(notify_admins)()
    if results:
        print('Notification emails sent to:\n{}'.format(dumps(results, indent=2, sort_keys=True)))
예제 #18
0
def reset_uber_db():
    assert c.DEV_BOX, 'reset_uber_db is only available on development boxes'
    Session.initialize_db(modify_tables=True, drop=True)
    insert_admin()
예제 #19
0
def drop_uber_db():
    assert c.DEV_BOX, 'drop_uber_db is only available on development boxes'
    Session.initialize_db(modify_tables=False, drop=True)
예제 #20
0
def reset_uber_db():
    assert c.DEV_BOX, 'reset_uber_db is only available on development boxes'
    Session.initialize_db(modify_tables=True, drop=True)
    insert_admin()
예제 #21
0
def init_worker_process(*args, **kwargs):
    Session.initialize_db(initialize=True)