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()) ))
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 = "******", 
            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
Beispiel #3
0
	def login_twitter(self, details):
		if not User.Query.filter(username=details['screen_name']):
			print "hello"
			User.signup(
				username=details['screen_name'], 
				password='******',
				NAME=details['name'],
				# cover=details['profile_background_image_url_https'],
				# image=details['profile_image_url']
			)
		else:
			pass
Beispiel #4
0
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}
Beispiel #5
0
    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)
Beispiel #6
0
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!')
Beispiel #7
0
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!')
Beispiel #8
0
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
Beispiel #9
0
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
Beispiel #10
0
 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]
Beispiel #11
0
    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)
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')
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
Beispiel #14
0
    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)
Beispiel #15
0
    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)
Beispiel #16
0
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'))
Beispiel #17
0
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))
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))
Beispiel #19
0
    def POST(self, request):
        username = request.values.get("email").lower()
        password = request.values.get("password")

        try:
            user = User.signup(username,
                               password,
                               email=username,
                               first_name=request.values.get("first_name"),
                               last_name=request.values.get("last_name"))
        except ResourceRequestBadRequest:
            user = User.login(username, password)

        response = flask.make_response(flask.redirect("/"))

        response.set_cookie("session", user.sessionToken)
        return response
Beispiel #20
0
    def do_login(self):
        print 'login'


        try:
            self.user = User.signup(self.login.nickname.text, "12345", nickname=self.login.nickname.text)
            self.remove_widget(self.login)

            self.main = Lobby()
            self.add_widget(self.main)

            print "Loged"

            self.getpartidas = PartidasThread(callback=self.actualizar_partidas)
            self.getpartidas.start()

        except:
            self.login.message.text = 'Nickname already in use'
            print "Algo salio mal"
Beispiel #21
0
	def signUp(self):
		"""Sends a HTTP request to verify email address and attemps to create a new user in the database if all of the credentials are valid"""
		self.response = json.loads(urllib.request.urlopen("https://api.kickbox.io/v2/verify?email="+self.signUpCredentials['email']+"&apikey="+self.emailKey).read().decode("utf-8"))
		if self.response['result'] != 'deliverable' and self.response['reason'] != 'accepted_email':
			self.emailVerfication = 'Invalid'
			print("\nInvalid Email.\n")
			time.sleep(1)
		else:
			self.emailVerfication = 'Valid'
		try:
			if self.emailVerfication == 'Valid':
				self.user = User.signup(self.signUpCredentials['userID'], self.signUpCredentials['password'], email=self.signUpCredentials['email'], full_name=self.signUpCredentials['full_name'])	  # creates a new user in the database (user, password, other records)
				self.signUpSuccessful = True
				self.full_name = self.signUpCredentials['full_name']
				print("\nSigned up successfully!\n")
		except:
		 	self.signUpSuccessful = False
		 	print("\nInvalid Email.\n")
		 	time.sleep(1)
		return self.signUpSuccessful
Beispiel #22
0
    def do_game(self):

        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

        self.dismiss()
        
        
        self.partida = Partidas()
        self.partida.Creator = app.root.user
        self.partida.Gametag = self.gametag.text
        self.partida.Status = "Ready"
        self.partida.save()

        WaitingGame().open()

        return

        '''
Beispiel #23
0
    def POST(self, request):
        username = request.values.get("email").lower()
        password = request.values.get("password")
        
        try:
            user = User.signup(
                username,
                password,
                email=username,
                first_name=request.values.get("first_name"),
                last_name=request.values.get("last_name")
            )
        except ResourceRequestBadRequest:
            user = User.login(
                username,
                password
            )

        response = flask.make_response(
            flask.redirect("/")
        )

        response.set_cookie("session", user.sessionToken)
        return response
Beispiel #24
0
 def testCanSignUp(self):
     self._destroy_user()
     user = User.signup(self.username, self.password)
     self.assertIsNotNone(user)
     self.assertEqual(user.username, self.username)
Beispiel #25
0
 def _get_user(self):
     try:
         user = User.signup(self.username, self.password)
     except:
         user = User.Query.get(username=self.username)
     return user
Beispiel #26
0
def signup(request):

	inputs = request.GET if request.GET else None

	# get referral code if exists
	form = ReferralForm(inputs)
	referred_by = None
	if (inputs) and form.is_valid():
		cd = form.cleaned_data 
		referred_by = cd['ref'] 
	
	
	inputs = request.POST if request.POST else None

	"""
	# get email if exists
	form = ResetForm(inputs)
	email = None
	if (inputs) and form.is_valid():
		cd = form.cleaned_data
		email = cd['email']
	"""

	form = SubscribeForm(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.")
			"""
			try:
				existing = get_parse_user_by_email(cd['email'])		
				raise Exception("Email already registered in system.")
			except:
				pass

				
			# get user count
			count = get_count()
			
			
			# create user
			ref = gen_alphanum_key()
			if LIVE:
				env_type = 'live'
				highrise_id = create_highrise_account(cd['email'], tag='signup')
			else:
				env_type = 'test'
				highrise_id = None

			email = cd['email'].lower()
			
			try:
				signup = ParseUser.signup(email, 
											cd['password'], 
											email=email, 
											full_name=cd['full_name'],
											ref=ref,
											count=count, 
											type=env_type, 
											highrise_id=highrise_id, 
											staff=False)
			except Exception as err:
				raise Exception(err)

			del cd['password']
			del cd['full_name']

			result = django_rq.enqueue(bg_cust_setup, cd, count, ref, referred_by)
			
			rev = str(reverse('confirmation', kwargs={'ref': ref}))
			return HttpResponseRedirect(rev)	
			
		else:
			raise Exception()

		
	except Exception as err:
		form.errors['__all__'] = form.error_class([err])
		return render_to_response('signup.html', {'form': form}, context_instance=RequestContext(request))
Beispiel #27
0
 def testCanSignUp(self):
     self._destroy_user()
     user = User.signup(self.username, self.password)
     self.assertIsNotNone(user)
     self.assertEqual(user.username, self.username)
Beispiel #28
0
 def _get_user(self):
     try:
         user = User.signup(self.username, self.password)
     except:
         user = User.Query.get(username=self.username)
     return user
Beispiel #29
0
 def setUpClass(cls):
   delete_sample_users()
   signup_sample_users()
   User.signup('redsox55', 'secure123', email='*****@*****.**')
   ParseBatcher().batch_delete(Task.Query.all())
Beispiel #30
0
def signup_sample_users():
  for username, pw, email in sample_users:
    User.signup(username, pw, email=email)
            #                   "userNum": userCounter,
            #                   "sex": sex,
            #                   "array_eventsRegistered": eventsRegistered_list
            #                 }
            # }

            # list_of_users_to_upload.append(new_user_object_dict)

            # The User.signup function is really slow.
            # It might be better to use a direct batch without ParsePy.
            # (Tried that...couldn't get it to work. At least this works.)
            user_upload_start_time = time.time()

            new_User = User.signup(name, "1234",
                userNum = userCounter,
                firstName = firstName_list[name_list.index(name)],
                sex = sex,
                array_eventsRegistered = eventsRegistered_list
            )
                
            print "User with userNum {} created and uploaded to _User in Parse in {} seconds.".format(userCounter, time.time() - user_upload_start_time)

        else:

            ghostCounter += 1

            new_Ghost = Ghost(
                username = "******",
                ghostNum = ghostCounter,
                firstName = "Ghost",
                sex = sex,
                array_eventsRegistered = []
Beispiel #32
0
def singup(user_name, password):
    return User.signup(user_name, password)