Skip to content

Commit 3b57e1f

Browse files
committed
Fix warnings
1 parent d9c49d6 commit 3b57e1f

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

fastapi_forge/frontend/panels/model_editor_panel.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,18 @@ def _on_select_field(self, selection: list[dict[str, Any]]) -> None:
448448
and name in ("password", "email")
449449
):
450450
ui.notify(
451-
f"Cannot edit {name} field in authentication model.", type="warning"
451+
f"Cannot edit {name} field in authentication model.",
452+
type="warning",
452453
)
453454
self._deselect_field()
454455
return
455456

456457
if name == "id":
457458
self._deselect_field()
459+
ui.notify(
460+
"Cannot edit the 'id' field, it is automatically generated.",
461+
type="warning",
462+
)
458463
return
459464

460465
state.selected_field = next(
@@ -488,22 +493,18 @@ def _handle_update_field(
488493
default_value: str | None = None,
489494
extra_kwargs: dict[str, Any] | None = None,
490495
) -> None:
496+
if not state.selected_model or not state.selected_field:
497+
return
498+
499+
exclude_set = {"id"}
491500
if (
492-
not state.selected_model
493-
or not state.selected_field
494-
or state.selected_field.name == "id"
501+
state.selected_model
502+
and state.selected_model.metadata.is_auth_model
503+
and state.use_builtin_auth
495504
):
496-
return
505+
exclude_set.update({"email", "password"})
497506

498-
if state.selected_model.metadata.is_auth_model and name == "password":
499-
ui.notify(
500-
"Cannot rename password field in authentication model.", type="negative"
501-
)
502-
return
503-
if state.selected_model.metadata.is_auth_model and name == "email":
504-
ui.notify(
505-
"Cannot rename email field in authentication model.", type="negative"
506-
)
507+
if name in exclude_set:
507508
return
508509

509510
if state.selected_field.name != name and self._field_name_exists(name):

0 commit comments

Comments
 (0)