mirror of
https://github.com/TronoSfera/Law.git
synced 2026-05-18 10:03:45 +03:00
test new design 05
This commit is contained in:
parent
1c908ade7b
commit
9a53d92377
3 changed files with 21 additions and 6 deletions
|
|
@ -232,9 +232,12 @@ def _apply_admin_user_topics_fields(db: Session, payload: dict[str, Any]) -> dic
|
|||
data = dict(payload)
|
||||
if "admin_user_id" in data:
|
||||
user_id = _parse_uuid_or_400(data.get("admin_user_id"), "admin_user_id")
|
||||
user = db.get(AdminUser, user_id)
|
||||
user = db.query(AdminUser).filter(AdminUser.id == user_id).first()
|
||||
if user is None:
|
||||
raise HTTPException(status_code=400, detail="Пользователь не найден")
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="Юрист не найден в базе данных. Возможно, учётная запись была удалена — обновите страницу и попробуйте снова.",
|
||||
)
|
||||
if str(user.role or "").upper() != "LAWYER":
|
||||
raise HTTPException(status_code=400, detail="Дополнительные темы доступны только для юриста")
|
||||
data["admin_user_id"] = user_id
|
||||
|
|
|
|||
|
|
@ -448,6 +448,15 @@ def update_row_service(table_name: str, row_id: str, payload: dict[str, Any], db
|
|||
is_update=True,
|
||||
allow_protected_fields={"password_hash"} if normalized == "admin_users" else None,
|
||||
)
|
||||
if normalized == "admin_users" and "email" in clean_payload:
|
||||
new_email = str(clean_payload.get("email") or "").strip().lower()
|
||||
if new_email:
|
||||
duplicate = db.query(AdminUser).filter(
|
||||
AdminUser.email == new_email,
|
||||
AdminUser.id != row.id,
|
||||
).first()
|
||||
if duplicate:
|
||||
raise HTTPException(status_code=400, detail="Этот email уже используется другим пользователем")
|
||||
if normalized == "admin_user_topics":
|
||||
clean_payload = _apply_admin_user_topics_fields(db, clean_payload)
|
||||
if normalized == "topic_required_fields":
|
||||
|
|
|
|||
|
|
@ -81,10 +81,13 @@ export function useTableActions({ api, setStatus, resolveTableConfig, tablesRef,
|
|||
}
|
||||
|
||||
if (tableKey === "topics") {
|
||||
setDictionaries((prev) => ({
|
||||
...prev,
|
||||
topics: sortByName((next.rows || []).map((row) => ({ code: row.code, name: row.name || row.code }))),
|
||||
}));
|
||||
setDictionaries((prev) => {
|
||||
const map = new Map((prev.topics || []).map((t) => [t.code, t]));
|
||||
(next.rows || []).forEach((row) => {
|
||||
if (row.code) map.set(row.code, { code: row.code, name: row.name || row.code });
|
||||
});
|
||||
return { ...prev, topics: sortByName(Array.from(map.values())) };
|
||||
});
|
||||
}
|
||||
|
||||
if (tableKey === "statuses") {
|
||||
|
|
|
|||
Loading…
Reference in a new issue