def add_phone(request, phone): '''Adds a new phone to our list of users and sends a verification SMS. Args: phone: mobile phone number in the format - 00 area_code phone_number eg. 0061424387059 Returns: JSON status, either 'ok' or 'fail'. Raises: None ''' if request.method == 'GET': registration = Registration() registration.phone = phone registration.pin = generate_pin(4)[0] registration.save() if sendsms(phone, registration.pin): return HttpResponse(json.dumps('ok'), mimetype='application/json') else: return HttpResponse(json.dumps('fail'), mimetype='application/json') else: return HttpResponse(json.dumps('fail'), mimetype='application/json')