示例#1
0
def reg_client2(request):
    if request.method == 'GET':
        form = ClientForm()
        return render_to_response('regclient2.html', {"form": form}, context_instance=RequestContext(request))
    elif request.method == 'POST':
        form = ClientForm(request.POST)
        if form.is_valid(): 
            client = form.save(commit=False)
            client.user = request.user
            client.save()
            d = {"name":client.name,"app_id":client.client_id, "secret":client.client_secret, "info_message": "Your Client Credentials"}
            return render_to_response('reg_success.html', d, context_instance=RequestContext(request))
        else:
            return render_to_response('regclient2.html', {"form": form}, context_instance=RequestContext(request))
示例#2
0
    def test_client_form(self):
        form = ClientForm({
            'name': 'TestName',
            'url': 'http://127.0.0.1:8000',
            'redirect_uri': 'http://localhost:8000/'
        })

        self.assertFalse(form.is_valid())

        form = ClientForm({
            'name': 'TestName',
            'url': 'http://127.0.0.1:8000',
            'redirect_uri': 'http://localhost:8000/',
            'client_type': constants.CLIENT_TYPES[0][0]
        })
        self.assertTrue(form.is_valid())
        form.save()
示例#3
0
    def test_client_form(self):
        form = ClientForm({'name': 'TestName', 'url': 'http://127.0.0.1:8000',
            'redirect_uri': 'http://localhost:8000/'})

        self.assertFalse(form.is_valid())

        form = ClientForm({
            'name': 'TestName',
            'url': 'http://127.0.0.1:8000',
            'redirect_uri': 'http://localhost:8000/',
            'client_type': constants.CLIENT_TYPES[0][0]})
        self.assertTrue(form.is_valid())
        form.save()
示例#4
0
def reg_client2(request):
    if request.method == 'GET':
        form = ClientForm()
        return render_to_response('regclient2.html', {"form": form},
                                  context_instance=RequestContext(request))
    elif request.method == 'POST':
        form = ClientForm(request.POST)
        if form.is_valid():
            client = form.save(commit=False)
            client.user = request.user
            client.save()
            d = {
                "name": client.name,
                "app_id": client.client_id,
                "secret": client.client_secret,
                "info_message": "Your Client Credentials"
            }
            return render_to_response('reg_success.html',
                                      d,
                                      context_instance=RequestContext(request))
        else:
            return render_to_response('regclient2.html', {"form": form},
                                      context_instance=RequestContext(request))