Example #1
0
def mobile_register(request):
    if request.method == 'POST':
        user_form = BlocklogicUserBaseForm(request.POST)
        user_form.is_mobile = True
        user_form.set_request(request)
        # user_profile_form = UserProfileForm(request.POST)

        if user_form.is_valid(): # and user_profile_form.is_valid():
            email = user_form.cleaned_data['email']

            if User.exists(email):

                if User.type(email) == "google":
                    return JsonError('error', _("You are already registered on one of Blocklogic sites with Google account. Please use the Google login button below."))
                elif User.type(email) == "normal":
                    return JsonError('error', _("You are already registered on one of Blocklogic sites. Try using that username."))

                return JsonError('user-exists', )
            # common function with web
            try_register(user_form) #), user_profile_form)

            return JsonResponse({'status': "created"})
        else:
            return JsonError(message='register failed')

    return JsonResponse({'error': "should not happen"})
Example #2
0
        print "Will try create new user with email [email protected]..."

        my_dict = {
            u'email': u'*****@*****.**',
            u'first_name': u'Rok TEST',
            u'last_name': u'Jaklic TEST',
            u'password1': u'rok123',
            u'password2': u'rok123',
            u'country': u'SI',
            u'sex': u'male'
        }

        query_string = urllib.urlencode(my_dict)
        query_dict = QueryDict(query_string)

        user_form = BlocklogicUserBaseForm(query_dict)

        if user_form.is_valid():
            email = user_form.cleaned_data['email']

            if User.exists(email):
                print "User exists, something wrong, check it out..."
                raise Exception

            new_user = user_form.save()
            new_user.set_password(user_form.cleaned_data['password1'])

            key = ""
            while key == "":
                key = get_random_string(15, string.lowercase + string.digits)
                user = BlocklogicUser.objects.filter(password_reset_key=key)