def edit(request, user_id): user = get_object_or_404(User, id=user_id) if request.POST: form = UserEditForm(request.POST, instance=user) if form.is_valid(): user = form.save() messages.success(request, _("User '{0}' updated.").format(user)) return redirect('wagtailusers_index') else: messages.error(request, _("The user could not be saved due to errors.")) else: form = UserEditForm(instance=user) return render(request, 'wagtailusers/edit.html', { 'user': user, 'form': form, })
def edit(request, user_id): user = get_object_or_404(User, pk=user_id) if request.method == 'POST': form = UserEditForm(request.POST, instance=user) if form.is_valid(): user = form.save() messages.success(request, _("User '{0}' updated.").format(user), buttons=[ messages.button(reverse('wagtailusers_users:edit', args=(user.pk,)), _('Edit')) ]) return redirect('wagtailusers_users:index') else: messages.error(request, _("The user could not be saved due to errors.")) else: form = UserEditForm(instance=user) return render(request, 'wagtailusers/users/edit.html', { 'user': user, 'form': form, })
def edit(request, user_id): user = get_object_or_404(User, pk=user_id) if request.method == 'POST': form = UserEditForm(request.POST, instance=user) if form.is_valid(): user = form.save() messages.success(request, _("User '{0}' updated.").format(user), buttons=[ messages.button( reverse('wagtailusers_users:edit', args=(user.pk, )), _('Edit')) ]) return redirect('wagtailusers_users:index') else: messages.error(request, _("The user could not be saved due to errors.")) else: form = UserEditForm(instance=user) return render( request, 'wagtailusers/users/edit.html', { 'user': user, 'form': form, 'user_can_delete': permission_policy.user_has_permission_for_instance( request.user, 'delete', user) and not user.is_superuser, })
def edit(request, user_id): user = get_object_or_404(User, id=user_id) if request.POST: form = UserEditForm(request.POST, instance=user) if form.is_valid(): user = form.save() messages.success(request, "User '%s' updated." % user) return redirect('wagtailusers_index') else: messages.error(request, "The user could not be saved due to errors.") else: form = UserEditForm(instance=user) return render(request, 'wagtailusers/edit.html', { 'user': user, 'form': form, })
def edit(request, user_id): user = get_object_or_404(User, id=user_id) if request.POST: form = UserEditForm(request.POST, instance=user) if form.is_valid(): user = form.save() messages.success(request, _("User '{0}' updated.").format(user), buttons=[ messages.button(reverse('wagtailusers_users:edit', args=(user.id,)), _('Edit')) ]) return redirect('wagtailusers_users:index') else: messages.error(request, _("The user could not be saved due to errors.")) else: form = UserEditForm(instance=user) return render(request, 'wagtailusers/users/edit.html', { 'user': user, 'form': form, })