コード例 #1
0
ファイル: views.py プロジェクト: NamPNQ/vp.repo
def clientEditView(request, client_id):
    """ Dashboard view, for registering API Client """
    if request.method == 'POST':
        form = ClientRegForm(request.POST)
        if form.is_valid():
            cid = form['id'].value()
            client = APIClient.objects.get(id=cid)
            client.name = form['name'].value()
            client.client_id = form['client_id'].value()
            client.email = form['email'].value()
            client.organization = form['organization'].value()
            client.secret_key = form['secret_key'].value()
            client.save()
            return redirect('/dashboard/clients/')
        else:
            assert False

    # Open existing client object 
    client = APIClient.objects.get(id=client_id)
    form = ClientRegForm()
    form.fields['id'].initial = client.id
    form.fields['name'].initial = client.name
    form.fields['client_id'].initial = client.client_id 
    form.fields['organization'].initial = client.organization
    form.fields['email'].initial = client.email

    return render(request, 'client_reg.html', {'form': form,
                                               'client': client
                                               })
コード例 #2
0
ファイル: views.py プロジェクト: NamPNQ/vp.repo
def clientRegView(request):
    """ Dashboard view, for registering API Client """
    if request.method == 'POST':
        form = ClientRegForm(request.POST)
        if form.is_valid():
            client = APIClient()
            client.name = form['name'].value()
            client.client_id = form['client_id'].value()
            client.email = form['email'].value()
            client.organization = form['organization'].value()
            client.secret_key = generateClientKey(client.email)
            client.save()
            return redirect('/dashboard/clients/')
    else:
        form = ClientRegForm()
    return render(request, 'client_reg.html', {'form':form})