Esempio n. 1
0
def signup(request):
    if request.method == 'POST':
        user_form = RegistrationForm(request.POST)
        if user_form.is_valid():
            user_form.save()
            return render(request, 'accounts/signup_finish.html',
                          {'form': user_form})
    else:
        user_form = RegistrationForm()
    return render(request, 'accounts/signup.html', {'form': user_form})
Esempio n. 2
0
def test_registration_form_creates_user():
    form = RegistrationForm({
        'email': '*****@*****.**',
        'first_name': 'Dan',
        'last_name': 'Sackett',
        'username': '******',
        'password': '******',
        'confirm_password': '******',
    })
    assert form.is_valid()
    form.save()
    assert len(User.objects.all()) == 1
Esempio n. 3
0
def register(request, form_id, email, password,  **kwargs):
    dajax = Dajax()
    clear_form_errors(dajax, form_id)
    
    form = RegistrationForm(data={'email' : email, 'password' : password})
    if form.is_valid():
        form.save(request = request)
        dajax.script("$('#modal').load('%s')" % reverse('auth_confirmation_sent')) 
    else:
        set_form_errors(dajax, form_id, form.errors)
        
    return dajax.json()
Esempio n. 4
0
File: views.py Progetto: chinspp/42
def signin(request):
    args = {}
    args.update(csrf(request))
    if (request.method == 'POST'):
        form = RegistrationForm(request.POST)
        args['form'] = form
        if form.is_valid():
            form.save()
            return (HttpResponseRedirect("/"))
    else:
        args['form'] = RegistrationForm()
    return (render_to_response('signin.html', args, context_instance=RequestContext(request)))
Esempio n. 5
0
def register(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('/accounts/login/')
        else:
            return render(request, 'registration/reg_form.html',
                          {'form': form})
    else:
        form = RegistrationForm()

        return render(request, 'registration/reg_form.html', {'form': form})
Esempio n. 6
0
def signin(request):
    args = {}
    args.update(csrf(request))
    if (request.method == 'POST'):
        form = RegistrationForm(request.POST)
        args['form'] = form
        if form.is_valid():
            form.save()
            return (HttpResponseRedirect("/"))
    else:
        args['form'] = RegistrationForm()
    return (render_to_response('signin.html',
                               args,
                               context_instance=RequestContext(request)))
Esempio n. 7
0
File: views.py Progetto: chinspp/42
def signin(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect("/", {"user": request.user})
    args = {}
    args.update(csrf(request))
    args["title"] = "Sign In"
    if request.method == "POST":
        form = RegistrationForm(request.POST)
        args["form"] = form
        if form.is_valid():
            form.save()
            return HttpResponseRedirect("/")
    else:
        args["form"] = RegistrationForm()
    return render_to_response("form.html", args, context_instance=RequestContext(request))
Esempio n. 8
0
def signup(request):
    username = None

    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data['username']
            form = None
    else:
        form = RegistrationForm()

    context = {'form': form, 'username': username}

    return render(request, 'signup.html', context)
Esempio n. 9
0
def login(request):
    if request.user['is_authenticated']:
	return HttpResponseRedirect('/')
    login_form = LoginForm()
    register_form = RegistrationForm()
    next = request.REQUEST.get('next')
    if 'kind' in request.POST:
        if request.POST['kind'] == 'login':
            login_form = LoginForm(request.POST)
            if login_form.is_valid():
                username = login_form.get_username()
                request.session['username'] = username
                if next:
                    return HttpResponseRedirect(next)
                return HttpResponseRedirect('/user')
        elif request.POST['kind'] == 'register':
            register_form = RegistrationForm(request.POST)
            if register_form.is_valid():
                username = register_form.save()
                request.session['username'] = username
                if next:
                    return HttpResponseRedirect(next)
                return HttpResponseRedirect('/user/welcome')
    context = {
        'login_form': login_form,
        'register_form': register_form,
        'next': next,
    }
    return render_to_response(
        'auth/login.html', context, context_instance=RequestContext(request))
Esempio n. 10
0
File: views.py Progetto: ryanrdk/42
def signin(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/', {"user": request.user})
    args = {}
    args.update(csrf(request))
    args['title'] = "Sign In"
    if (request.method == 'POST'):
        form = RegistrationForm(request.POST)
        args['form'] = form
        if form.is_valid():
            form.save()
            return (HttpResponseRedirect("/"))
    else:
        args['form'] = RegistrationForm()
    return (render_to_response('form.html',
                               args,
                               context_instance=RequestContext(request)))
Esempio n. 11
0
def register(request):
    """Allow a user to register for the site"""
    form = RegistrationForm(request.POST or None)

    if request.method == 'POST' and form.is_valid():
        form.save()
        username = form.cleaned_data.get('username')
        password = form.cleaned_data.get('password')
        user = auth.authenticate(username=username, password=password)

        if user:
            auth.login(request, user)
            return redirect('user-home')

        return redirect('login')

    context = {
        'form': form,
    }
    return render(request, 'auth/register.html', context)
Esempio n. 12
0
    def POST(self):
        f = RegistrationForm()
        if not f.validates():
            render = web.template.render('templates')
            return render.register()
        else:
            domain_override = web.ctx.host
            new_user = f.save(domain_override)
#             render = web.template.render('templates')
#             web.header('Content-Type', 'text/html')
#             return render.register_success()
            web.header('Content-Type', 'application/json')
            return json.dumps({'success':True})
Esempio n. 13
0
def register(request):
    auth_form = AuthenticationForm() 
    if request.POST:
        form = RegistrationForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            d_login(request, new_user)
            return HttpResponseRedirect('/')
    else:
         form = RegistrationForm()
    return render_to_response('registration_form.html',
                              { 'form': form, 'auth_form': auth_form },
                              context_instance=RequestContext(request))
Esempio n. 14
0
def register(request):
    """ Registers a member """
    form = RegistrationForm()

    if request.method == 'POST':
        data = request.POST
        form = RegistrationForm(data)

        if form.is_valid():
            user = form.save(request) #profile_callback=Member.objects.profile_callback)
            return HttpResponseRedirect(reverse('register_success'))

    return render_to_response('auth/register.html', {
        'form': form,
    }, RequestContext(request))
Esempio n. 15
0
    def post(self, request, user, feed):
        register_form = None
        register_user = None
        subscribe_form = PaymentForm(request.POST)

        if self.request.user.is_anonymous():
            register_form = RegistrationForm(request.POST)

        if ((register_form and register_form.is_valid()) or register_form == None) and subscribe_form.is_valid():
            if register_form:
                register_user = register_form.save(request)
                register_user.profile.status = 'REG'
                register_user.profile.save()

                registed_user = authenticate(
                    username=request.POST.get('username'),
                    password=request.POST.get('password')
                )

            FeedSubscriber.objects.get_or_create(feed=feed, user=register_user or request.user)


        if request.is_ajax():
            response = {
                'error': subscribe_form.errors,
                'success_url': reverse('feed_detail', args=[
                    feed.publisher.username,
                    feed.slug
                ])
            }

            if register_form:
                response['error'].update(register_form.errors)

            status = 200
            if response['error']:
                status = 400

            return HttpResponse(json.dumps(response), status=status, mimetype="application/json")

        return self.render(user, feed, register_form, subscribe_form)