Release Nouri 1.3.0 with improved food states and quick entry flow
This commit is contained in:
+16
-1
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from flask import Blueprint, flash, g, redirect, render_template, request, url_for
|
||||
from werkzeug.security import generate_password_hash
|
||||
|
||||
from .auth import admin_required, can_remove_last_admin, validate_admin_user_form
|
||||
from .auth import admin_required, can_remove_last_admin, url_with_scroll_position, validate_admin_user_form, wants_to_stay_on_form
|
||||
from .constants import BUILDER_DESCRIPTIONS, BUILDER_OPTIONS, DEFAULT_CATEGORIES, DEFAULT_CATEGORY_BUILDERS, ROLE_LABELS
|
||||
from .db import get_db
|
||||
|
||||
@@ -104,6 +104,19 @@ def user_create():
|
||||
)
|
||||
database.commit()
|
||||
flash("Der Nutzer wurde angelegt.", "success")
|
||||
if wants_to_stay_on_form():
|
||||
new_user = database.execute(
|
||||
"""
|
||||
SELECT id
|
||||
FROM users
|
||||
WHERE household_id = ? AND username = ?
|
||||
ORDER BY id DESC
|
||||
LIMIT 1
|
||||
""",
|
||||
(g.user["household_id"], form_data["username"]),
|
||||
).fetchone()
|
||||
if new_user is not None:
|
||||
return redirect(url_with_scroll_position(url_for("admin.user_edit", user_id=int(new_user["id"]))))
|
||||
return redirect(url_for("admin.user_list"))
|
||||
|
||||
flash(error, "error")
|
||||
@@ -185,6 +198,8 @@ def user_edit(user_id: int):
|
||||
)
|
||||
database.commit()
|
||||
flash("Der Nutzer wurde aktualisiert.", "success")
|
||||
if wants_to_stay_on_form():
|
||||
return redirect(url_with_scroll_position(url_for("admin.user_edit", user_id=user_id)))
|
||||
return redirect(url_for("admin.user_list"))
|
||||
|
||||
flash(error, "error")
|
||||
|
||||
Reference in New Issue
Block a user