def edit_token(request, object_id): token = get_object_or_404(AuthToken, pk=object_id, user=request.user) if request.method == "POST": form = AuthTokenForm(request.POST, instance=token) if form.is_valid(): form.save() return HttpResponseRedirect( reverse("linaro_django_xmlrpc_tokens")) else: form = AuthTokenForm(instance=token) return render(request, "linaro_django_xmlrpc/edit_token.html", {"token": token, "form": form})
def create_token(request): """ Create a token for the requesting user """ if request.method == "POST": form = AuthTokenForm(request.POST) if form.is_valid(): form.save(commit=False) form.instance.user = request.user form.instance.save() return HttpResponseRedirect(reverse("linaro_django_xmlrpc_tokens")) else: form = AuthTokenForm() return render(request, "linaro_django_xmlrpc/create_token.html", {"form": form})
def create_token(request): """ Create a token for the requesting user """ if request.method == "POST": form = AuthTokenForm(request.POST) if form.is_valid(): form.save(commit=False) form.instance.user = request.user form.instance.save() return HttpResponseRedirect( reverse("linaro_django_xmlrpc_tokens")) else: form = AuthTokenForm() return render(request, "linaro_django_xmlrpc/create_token.html", {"form": form})