def keys_change(request, pk): key = get_object_or_404(SshPublicKey, pk=pk, user=request.user) if request.method == "POST": form = SshPublicKeyForm(request.POST, instance=key) if form.is_valid(): key = form.save() messages.success(request, _("Key updated.")) return redirect("accounts_keys_list") else: form = SshPublicKeyForm(instance=key) return render(request, "accounts/keys_change.html", {"form": form, "key": key})
def keys_add(request): if request.method == "POST": form = SshPublicKeyForm(request.POST) if form.is_valid(): key = form.save(commit=False) key.user = request.user key.save() messages.success(request, _("Key added.")) return redirect("accounts_keys_list") else: form = SshPublicKeyForm() return render(request, "accounts/keys_change.html", {"form": form})
def keys_change(request, pk): key = get_object_or_404(SshPublicKey, pk=pk, user=request.user) if request.method == 'POST': form = SshPublicKeyForm(request.POST, instance=key) if form.is_valid(): key = form.save() register_repository_update(key.user, 'key_changed') messages.success(request, _('Key updated.')) return redirect('accounts_keys_list') else: form = SshPublicKeyForm(instance=key) return render(request, 'accounts/keys_change.html', {'form': form})
def keys_add(request): if request.method == 'POST': form = SshPublicKeyForm(request.POST) if form.is_valid(): key = form.save(commit=False) key.user = request.user key.save() register_repository_update(key.user, 'key_added') messages.success(request, _('Key added.')) return redirect('accounts_keys_list') else: form = SshPublicKeyForm() return render(request, 'accounts/keys_add.html', {'form': form})