def sign_up(self, session, tournament_id, attendee_id, cellphone): from uber import model_checks as umc if umc._invalid_phone_number(cellphone): return {'error': 'That is not a valid phone number'} try: attendee = session.attendee(attendee_id) attendee.cellphone = cellphone session.add(TabletopEntrant(attendee_id=attendee_id, tournament_id=tournament_id)) session.commit() except: session.rollback() log.error('unable to add tournament entrant tournament={} attendee={}', tournament_id, attendee_id, exc_info=True) return {'error': 'That attendee is already signed up for that tournament'} else: return { 'message': 'Attendee signed up', 'state': _state(session) }
def sign_up(self, session, tournament_id, attendee_id, cellphone): from uber import model_checks as umc if umc._invalid_phone_number(cellphone): return {'error': 'That is not a valid phone number'} try: attendee = session.attendee(attendee_id) attendee.cellphone = cellphone session.add( TabletopEntrant(attendee_id=attendee_id, tournament_id=tournament_id)) session.commit() except Exception: session.rollback() log.error( 'unable to add tournament entrant tournament={} attendee={}', tournament_id, attendee_id, exc_info=True) return { 'error': 'That attendee is already signed up for that tournament' } else: return {'message': 'Attendee signed up', 'state': _state(session)}
def dev_cellphone(dev): from uber.model_checks import _invalid_phone_number if (dev.primary_contact or dev.cellphone) and _invalid_phone_number(dev.cellphone): return 'Please enter a valid phone number'
def test_invalid_number(selfself, number): assert True == _invalid_phone_number(number)
def test_valid_number(self, number): assert False == _invalid_phone_number(number)
def test_valid_number(self, number): assert not _invalid_phone_number(number)
def pa_phone(pa): from uber.model_checks import _invalid_phone_number if (pa.submitter or pa.cellphone) and _invalid_phone_number(pa.cellphone): return 'Please enter a valid phone number'
def cellphone(app): from uber.model_checks import _invalid_phone_number if app.cellphone and _invalid_phone_number(app.cellphone): return 'You did not enter a valid cellphone number'
def dev_cellphone(dev): from uber.model_checks import _invalid_phone_number if (dev.primary_contact or dev.cellphone) and _invalid_phone_number( dev.cellphone): return 'Please enter a valid phone number'
def test_invalid_number(selfself, number): assert _invalid_phone_number(number)