本文整理汇总了Python中parse_rest.user.User.signup方法的典型用法代码示例。如果您正苦于以下问题:Python User.signup方法的具体用法?Python User.signup怎么用?Python User.signup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类parse_rest.user.User
的用法示例。
在下文中一共展示了User.signup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_1000_users_in_Parse
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def create_1000_users_in_Parse():
li_u = []
for i in range(1000):
u = _User()
li_u.append(u)
register_for_events(li_u)
for u in li_u:
User.signup( username = u.username, password = "1234",
u_num = u.u_num,
sex = u.sex,
age = u.age,
eyes = u.eyes,
dob = u.dob,
full_name = u.full_name,
first_name = u.first_name,
last_name = u.last_name,
college = u.college,
email_address = u.email_address,
li_events_registered = u.li_events_registered)
print "User {} signed up.".format(u.u_num)
# batcher = ParseBatcher()
# batcher.batch_save(li_u)
pass
示例2: signUp
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def signUp(names, classNames):
global username
username = usernameEntry.get()
password = passwordEntry.get()
username = username.lower()
value = classBox.curselection()
strip = str(value).strip(',')
value = int(strip[1])
group = classNames[value]
if username in str(names):
currentUserLabel.config(text = 'That username is already taken')
print('That username is already taken')
else:
teacher = teacherVar.get()
if teacher == 0:
u = User.signup(username, password, teacher = False, group = group)
currentUserLabel.config(text = 'Logged in as '+username)
addUsertoResults()
outputUserResults()
newWordButton.config(state = DISABLED)
quizSelectButton.config(state = NORMAL)
print('Account Created')
else:
u = User.signup(username, password, teacher = True, group = group)
currentUserLabel.config(text = 'Logged in as '+username)
newWordButton.config(state = NORMAL)
quizSelectButton.config(state = DISABLED)
resultsList.delete(0, END)
print('Account Created')
print('FUNCTION: signUp COMPLETE')
print(time.asctime( time.localtime(time.time()) ))
示例3: login_twitter
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def login_twitter(self, details):
if not User.Query.filter(username=details['screen_name']):
print "hello"
User.signup(
username=details['screen_name'],
password='123456',
NAME=details['name'],
# cover=details['profile_background_image_url_https'],
# image=details['profile_image_url']
)
else:
pass
示例4: create_parse_user
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def create_parse_user(email, referred_by=None):
email = email.lower()
try:
if LIVE:
user_type = "live"
else:
user_type = "test"
ref = gen_alphanum_key()
user = User.signup(email, "pass", email=email, type=user_type, ref=ref, welcomed=False)
except Exception as err:
return {'error': ast.literal_eval(err[0])['error']}
if LIVE:
try:
highrise_id = create_highrise_account(email, 'user')
user.highrise_id = highrise_id
user.save()
except:
pass
if referred_by:
try:
referral = Referrals(email=email, code=referred_by, verified=False)
referral.save()
except Exception as err:
return {'error': ast.literal_eval(err[0])['error']}
return {'created': True, 'ref': ref}
示例5: on_jugar
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def on_jugar(self):
print "ON_JUGAR"
if app.root.user == None:
nick = "nobody" + str(len(User.Query.all())).zfill(4)
app.root.user = User.signup(nick, "012345679", nickname=nick)
else:
nick = app.root.user.nickname
app.root.remove_widget(app.root.lobby)
#crear selector de juego
app.root.games = GameSelector()
app.root.add_widget(app.root.games)
app.root.gamelist = Partidas.Query.all().order_by("-createdAt")
#games list
for i in app.root.gamelist:
game = GameItem()
game.by.text = i.Creator.nickname
game.gametag.text = i.Gametag
if i.Creator.nickname == nick:
game.btn_action.text = "Cancel game"
app.root.games.gamelist.add_widget(game)
示例6: user_register
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def user_register():
if request.method == 'POST':
user_name = request.form['user']
password = request.form['password']
phone = request.form['phone']
weight = request.form['weight']
u = User.signup(user_name, password, phone=phone, weight=weight)
return jsonify(result='Registered!')
示例7: signup_button
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def signup_button(self):
try:
u = User.signup(self.username.text, self.password.text)
u.displayName = u.username
u.save()
self.error.text = "User created successfully. Please Login."
self.error.color = [0,1,0,1]
except ParseError:
self.error.text = "Signup Failed. Choose another username."
self.error.color = [1,0,0,1]
示例8: signup
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def signup(username, password):
try:
u = User.signup(username, password)
sc = ShoppingCart(cartItems=[])
sc.save()
u.shoppingCart = sc
u.save()
except:
return "User Already Exists"
return u
示例9: index
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def index():
settings_local.initParse()
if request.method == 'POST' and request.form["what"]== 'Login':
try:
print request.form["password"]
u = User.login(request.form["username"],request.form["password"])
session['session_token'] = u.sessionToken
resp = make_response(render_template("index.html"))
return resp
except:
return render_template('login.html',error="Invalid username or password")
elif request.method == 'POST' and request.form["what"]=='SignUp':
email = request.form["email"]
password = request.form["password"]
ninja = request.form["ninja"]
birthdate = request.form["birthdate"]
u = User.signup(email,password)
u.email=email
u.save()
# proPic.save(os.path.join(app.config['UPLOAD_FOLDER']),"userdp.png")
# connection = httplib.HTTPSConnection('api.parse.com', 443)
# connection.connect()
# connection.request('POST', '/1/files/profilePic.png', open('userdp.png', 'rb').read(), {
# "X-Parse-Application-Id": "${Y4Txek5e5lKnGzkArbcNMVKqMHyaTk3XR6COOpg4}",
# "X-Parse-REST-API-Key": "${nJOJNtVr1EvNiyjo6F6M8zfiUdzv8lPx31FBHiwO}",
# "Content-Type": "image/png"
# })
# result = json.loads(connection.getresponse().read())
# print result
# connection.request('POST', '/1/classes/_User', json.dumps({
# "username": email,
# "picture": {
# "name": "profilePic.png",
# "__type": "File"
# }
# }), {
# "X-Parse-Application-Id": "${Y4Txek5e5lKnGzkArbcNMVKqMHyaTk3XR6COOpg4}",
# "X-Parse-REST-API-Key": "${nJOJNtVr1EvNiyjo6F6M8zfiUdzv8lPx31FBHiwO}",
# "Content-Type": "application/json"
# })
# result = json.loads(connection.getresponse().read())
# print result
session['session_token'] = u.sessionToken
resp = make_response(render_template("index.html"))
return u.sessionToken
else:
if session.get('session_token') is None:
print "nohhh"
return render_template('login.html')
else:
print "yes"
return render_template('index.html')
示例10: testCanGetCurrentUser
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def testCanGetCurrentUser(self):
user = User.signup(self.username, self.password)
self.assertIsNotNone(user.sessionToken)
register(
getattr(settings_local, 'APPLICATION_ID'),
getattr(settings_local, 'REST_API_KEY'),
session_token=user.sessionToken
)
current_user = User.current_user()
self.assertIsNotNone(current_user)
self.assertEqual(current_user.sessionToken, user.sessionToken)
self.assertEqual(current_user.username, user.username)
示例11: sign_up
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def sign_up():
while True:
try:
sign_up_dict = get_data()
current_user = User.signup(sign_up_dict["username"], sign_up_dict["password"], email=sign_up_dict["email"],
Experience=sign_up_dict["exp"], Name=sign_up_dict["name"],
Profession=sign_up_dict["profession"])
break
except ResourceRequestBadRequest:
print("E-mail or username already exist")
except ValueError:
print("Invalid exp value")
current_user = User.login(sign_up_dict["username"], sign_up_dict["password"])
return current_user
示例12: do_game
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def do_game(self):
nick = "nobody" + str(len(User.Query.all())).zfill(4)
app.root.user = User.signup(nick, "012345679", nickname=nick)
self.dismiss()
self.partida = Partidas()
self.partida.Creator = app.root.user
self.partida.Gametag = self.gametag.text
self.partida.Status = "Ready"
self.partida.save()
'''
#remove old timeoff games waiting
now = datetime.now()
lastmins = now - timedelta(minutes=3)
print "Now: ", now
print "Mins: ", lastmins
partidas = Partidas.Query.filter(createdAt__lte=lastmins)
print partidas
batcher = ParseBatcher()
batcher.batch_delete(partidas)
'''
#crear selector de juego
app.root.games = GameSelector()
app.root.add_widget(app.root.games)
app.root.gamelist = Partidas.Query.all().order_by("-createdAt")
#games list
for i in app.root.gamelist:
game = GameItem()
game.by.text = i.Creator.nickname
game.gametag.text = i.Gametag
if i.Creator.nickname == nick:
game.btn_action.text = "Cancel game"
app.root.games.gamelist.add_widget(game)
示例13: register
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def register():
username = request.form['username']
password = request.form['password']
email = request.form['email']
u = User.signup(username, password, email=email)
circle = Circle(name="all", owner=u, users=[u])
circle.save()
u.circles = [circle]
u.postingTo = ['all']
u.save()
session['username'] = username
session['password'] = password
u = User.login(username, password)
u.save()
return redirect(url_for('index'))
示例14: setup_users
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def setup_users(u, m = 50, f = 50):
"""
"""
if m == f == 50:
m = u/2
f = u - u/2
# Start a function timer.
function_start_time = time.time()
m_names_dict = get_m_male_names_in_2_lists(m)
f_names_dict = get_f_female_names_in_2_lists(f)
full_names_dict = m_names_dict["m_full_names"] + f_names_dict["f_full_names"]
first_names_dict = m_names_dict["m_first_names"] + f_names_dict["f_first_names"]
user_upload_start_time = time.time()
print ("\nSigning up {} users -- {} males and {} females.".format(u, m, f))
for user_number in range(1, u + 1, 1):
gender = "M" if (user_number <= m) else "F"
array_events_registered = [1] if (user_number % 2 == 1) else [2]
new_User_object = User.signup(
full_names_dict[user_number - 1],
"1234",
userNum = user_number,
firstName = first_names_dict[user_number - 1],
sex = gender,
array_eventsRegistered = array_events_registered
)
sys.stdout.write("\r{} of {} new users uploaded ({}{})".format(
user_number, u, int(round((user_number*100.0)/u, 0)), "%"
))
sys.stdout.flush()
sys.stdout.write("\n") # move the cursor to the next line
# Print results.
function_total_time = round(time.time() - function_start_time, 3)
print("\nFunction \"setup_users({},{},{})\" ran in {} seconds."
.format(u, m, f, function_total_time))
示例15: createStaff
# 需要导入模块: from parse_rest.user import User [as 别名]
# 或者: from parse_rest.user.User import signup [as 别名]
def createStaff(request):
inputs = request.POST if request.POST else None
form = LoginForm(inputs)
try:
if (inputs) and form.is_valid():
cd = form.cleaned_data
# check if email already exists
existing = ParseUser.Query.all().filter(email=cd['email'])
existing = [e for e in existing]
if existing:
raise Exception("Email already registered in system.")
if LIVE:
env_type = 'live'
highrise_id = create_highrise_account(cd['email'], tag='staff')
else:
env_type = 'test'
highrise_id = None
email = cd['email'].lower()
signup = ParseUser.signup(email,
cd['password'],
email=email,
type=env_type,
highrise_id=highrise_id,
chargify_active=False,
staff=True)
user = get_parse_user_by_email(email)
acct = AccountDetails(user_id=user.objectId, user=user, active=False)
acct.save()
return HttpResponseRedirect(reverse('splash'))
else:
raise Exception()
except Exception as err:
form.errors['__all__'] = form.error_class([err])
return render_to_response('create-staff.html', {'form': form}, context_instance=RequestContext(request))