def test_self_assignment(self, session): assert 'Attendee is already Staff with badge 1' == reset_badge_if_unchanged( session.staff_one, c.STAFF_BADGE, 1) assert 'Attendee is already Staff with badge 3' == reset_badge_if_unchanged( session.staff_three, c.STAFF_BADGE, 3) assert 'Attendee is already Staff with badge 5' == reset_badge_if_unchanged( session.staff_five, c.STAFF_BADGE, 5)
def change_badge(session, attendee, new_type, new_num=None, expected_num=None): old_type, old_num = attendee.badge_type, attendee.badge_num attendee.badge_type, attendee.badge_num = new_type, new_num reset_badge_if_unchanged(attendee, old_type, old_num) session.commit() session.refresh(attendee) assert new_type == attendee.badge_type assert (new_num if expected_num is None else expected_num) == attendee.badge_num
def change_badge(self, session, id, message='', **params): attendee = session.attendee(id, allow_invalid=True) if 'badge_type' in params: from uber.badge_funcs import reset_badge_if_unchanged old_badge_type, old_badge_num = attendee.badge_type, attendee.badge_num attendee.badge_type = int(params['badge_type']) try: attendee.badge_num = int(params['badge_num']) except ValueError: attendee.badge_num = None message = check(attendee) if not message: message = reset_badge_if_unchanged( attendee, old_badge_type, old_badge_num) or "Badge updated." raise HTTPRedirect('form?id={}&message={}', attendee.id, message or '') return {'message': message, 'attendee': attendee}
def change_badge(self, session, id, message='', **params): attendee = session.attendee(id, allow_invalid=True) if 'badge_type' in params: from uber.badge_funcs import reset_badge_if_unchanged old_badge_type, old_badge_num = attendee.badge_type, attendee.badge_num attendee.badge_type = int(params['badge_type']) try: attendee.badge_num = int(params['badge_num']) except ValueError: attendee.badge_num = None message = check(attendee) if not message: message = reset_badge_if_unchanged(attendee, old_badge_type, old_badge_num) or "Badge updated." raise HTTPRedirect('form?id={}&message={}', attendee.id, message or '') return { 'message': message, 'attendee': attendee }