Exemple #1
0
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
                                               })
Exemple #2
0
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})