def session(request): session = Session().session request.addfinalizer(session.close) check_ranges(session) for badge_type, badge_name in [(c.STAFF_BADGE, 'Staff'), (c.CONTRACTOR_BADGE, 'Contractor')]: for number in ['One', 'Two', 'Three', 'Four', 'Five']: setattr(session, '{}_{}'.format(badge_name, number).lower(), session.attendee(badge_type=badge_type, first_name=number)) setattr(session, 'regular_attendee', session.attendee(first_name='Regular', last_name='Attendee')) session.regular_attendee.paid = c.HAS_PAID session.regular_attendee.checked_in = datetime.now(UTC) session.regular_attendee.badge_num = 3000 session.commit() return session
def session(request): session = Session().session for num in ['One', 'Two', 'Three', 'Four', 'Five', 'Six']: setattr(session, 'job_' + num.lower(), session.job(name='Job ' + num)) for num in ['One', 'Two', 'Three', 'Four', 'Five']: setattr(session, 'staff_{}'.format(num).lower(), session.attendee(badge_type=c.STAFF_BADGE, first_name=num)) for name in ['Arcade', 'Console']: setattr(session, 'dept_' + name.lower(), session.department(name=name)) request.addfinalizer(session.close) return session