コード例 #1
0
def profile(request):
	errors = { }
	
	if request.method == "POST":
		email = None
		if request.POST.get("email", "").strip() != request.user.email:
			try:
				email = validate_email(request.POST.get("email", ""))
			except Exception, e:
				errors["email"] = validation_error_message(e)
	
		password = None
		if request.POST.get("password", "").strip() != "":
			try:
				password = validate_password(request.POST.get("password", ""))
			except Exception, e:
				errors["email"] = validation_error_message(e)
コード例 #2
0
def profile(request):
    errors = {}
    success = []

    if request.method == "POST":
        email = None
        if request.POST.get("email", "").strip() != request.user.email:
            try:
                email = validate_email(request.POST.get("email", ""))
            except Exception, e:
                errors["email"] = validation_error_message(e)

        password = None
        if request.POST.get("password", "").strip() != "":
            try:
                password = validate_password(request.POST.get("password", ""))
            except Exception, e:
                errors["password"] = validation_error_message(e)
コード例 #3
0
def registration_utility(request, provider, profile, axn):
    username = None
    if "username" in request.POST:
        username = request.POST["username"]
    else:
        # Guess a username.
        if "screen_name" in profile:
            username = profile["screen_name"]
        elif "email" in profile and "@" in profile["email"]:
            username = profile["email"][0:profile["email"].index("@")]
        elif "email" in request.POST and "@" in request.POST["email"]:
            username = request.POST["email"][0:request.POST["email"].index("@"
                                                                           )]

    email = None
    if "email" in request.POST:
        email = request.POST["email"]
    elif "email" in profile and len(profile["email"]) <= 64:
        # Pre-populate an email address.
        email = profile["email"]

    # Validation

    errors = {}

    if username:
        try:
            username = validate_username(username)
        except Exception, e:
            if REGISTRATION_ASK_USERNAME:
                errors["username"] = validation_error_message(e)
            else:
                # make up a username that validates (i.e. not already taken)
                c = User.objects.count() + 100
                while True:
                    try:
                        username = validate_username(
                            "Anonymous" + str(random.randint(c, c * 5)))
                        break
                    except:
                        continue
コード例 #4
0
def registration_utility(request, provider, profile, axn):
	username = None
	if "username" in request.POST:
		username = request.POST["username"]
	else:
		# Guess a username.
		if "screen_name" in profile:
			username = profile["screen_name"]
		elif "email" in profile and "@" in profile["email"]:
			username = profile["email"][0:profile["email"].index("@")]
		elif "email" in request.POST and "@" in request.POST["email"]:
			username = request.POST["email"][0:request.POST["email"].index("@")]

	email = None
	if "email" in request.POST:
		email = request.POST["email"]
	elif "email" in profile and len(profile["email"]) <= 64:
		# Pre-populate an email address.
		email = profile["email"]

	# Validation
		
	errors = { }
	
	if username:
		try:
			username = validate_username(username)
		except Exception, e:
			if settings.REGISTRATION_ASK_USERNAME:
				errors["username"] = validation_error_message(e)
			else:
				# make up a username that validates (i.e. not already taken)
				c = User.objects.count() + 100
				while True:
					try:
						username = validate_username("Anonymous" + str(random.randint(c, c*5)))
						break
					except:
						continue
コード例 #5
0
				# make up a username that validates (i.e. not already taken)
				c = User.objects.count() + 100
				while True:
					try:
						username = validate_username("Anonymous" + str(random.randint(c, c*5)))
						break
					except:
						continue
	elif request.method == "POST" and settings.REGISTRATION_ASK_USERNAME:
		errors["username"] = "******"
	
	if email:
		try:
			email = validate_email(email)
		except Exception, e:
			errors["email"] = validation_error_message(e)
	elif request.method == "POST":
		errors["email"] = "Provide an email address."

	password = None
	if not provider:
		if request.method == "POST":
			try:
				password = validate_password(request.POST.get("password", ""))
			except Exception, e:
				errors["password"] = validation_error_message(e)

	if len(errors) > 0 or request.method != "POST":
		# Show the form again with the last entered field values and the
		# validation error message.
		return render_to_response('registration/register.html',
コード例 #6
0
                c = User.objects.count() + 100
                while True:
                    try:
                        username = validate_username(
                            "Anonymous" + str(random.randint(c, c * 5)))
                        break
                    except:
                        continue
    elif request.method == "POST" and REGISTRATION_ASK_USERNAME:
        errors["username"] = "******"

    if email:
        try:
            email = validate_email(email)
        except Exception, e:
            errors["email"] = validation_error_message(e)
    elif request.method == "POST":
        errors["email"] = "Provide an email address."

    password = None
    if not provider:
        if request.method == "POST":
            try:
                password = validate_password(request.POST.get("password", ""))
            except Exception, e:
                errors["password"] = validation_error_message(e)

    if len(errors) > 0 or request.method != "POST":
        # Show the form again with the last entered field values and the
        # validation error message.
        return render_to_response('registration/register.html', {