Ejemplo n.º 1
0
    def handle(self, *args, **options):
        user = User()
        user.email = raw_input('Email Address: ')
        while len(user.email.split('@')) == 1:
            print ('Wrong email address format!')
            user.email = raw_input('Email address: ')
        user.username = user.email
        user.set_password(user.email.split('@')[0])
        if GenericProfile.objects.filter(user__email__iexact=user.email):
            print('Email address already exists!')
            exit()
        user.save()

        generic_profile = GenericProfile()
        generic_profile.user = user
        generic_profile.full_name = user.username
        generic_profile.save()
Ejemplo n.º 2
0
    def handle(self, *args, **options):
        user = User()
        user.email = raw_input('Email Address: ')
        while len(user.email.split('@')) == 1:
            print('Wrong email address format!')
            user.email = raw_input('Email address: ')
        user.username = user.email
        user.set_password(user.email.split('@')[0])
        if GenericProfile.objects.filter(user__email__iexact=user.email):
            print('Email address already exists!')
            exit()
        user.save()

        generic_profile = GenericProfile()
        generic_profile.user = user
        generic_profile.full_name = user.username
        generic_profile.save()
Ejemplo n.º 3
0
def create_account_view(request):
    user = request.user
    if user.is_authenticated():
        return (HttpResponseRedirect('/Home'))

    if request.method == 'POST':
        create_account_form = CreateAccountForm(request.POST)
        if not create_account_form.is_valid():
            return render_to_response(
                'create_account.html',
                {'create_account_form': create_account_form},
                context_instance=RequestContext(request))
        create_account_form_data = create_account_form.cleaned_data
        user = User()
        user.username = create_account_form_data['email']
        user.email = create_account_form_data['email']
        user.set_password(create_account_form_data['password'])
        user.save()

        generic_profile = GenericProfile()
        generic_profile.user = user
        generic_profile.full_name = create_account_form_data['full_name']
        generic_profile.logged = True
        generic_profile.save()

        # Auto Login
        user = authenticate(username=user.username,
                            password=create_account_form_data['password'])
        login(request, user)

        return HttpResponseRedirect('/Home')
    else:
        create_account_form = CreateAccountForm()
        return render_to_response('create_account.html',
                                  {'create_account_form': create_account_form},
                                  context_instance=RequestContext(request))
Ejemplo n.º 4
0
def create_account_view(request):
    user = request.user
    if user.is_authenticated():
        return HttpResponseRedirect("/Home")

    if request.method == "POST":
        create_account_form = CreateAccountForm(request.POST)
        if not create_account_form.is_valid():
            return render_to_response(
                "create_account.html",
                {"create_account_form": create_account_form},
                context_instance=RequestContext(request),
            )
        create_account_form_data = create_account_form.cleaned_data
        user = User()
        user.username = create_account_form_data["email"]
        user.email = create_account_form_data["email"]
        user.set_password(create_account_form_data["password"])
        user.save()

        generic_profile = GenericProfile()
        generic_profile.user = user
        generic_profile.full_name = create_account_form_data["full_name"]
        generic_profile.logged = True
        generic_profile.save()

        # Auto Login
        user = authenticate(username=user.username, password=create_account_form_data["password"])
        login(request, user)

        return HttpResponseRedirect("/Home")
    else:
        create_account_form = CreateAccountForm()
        return render_to_response(
            "create_account.html",
            {"create_account_form": create_account_form},
            context_instance=RequestContext(request),
        )