Skip to content

Commit

Permalink
[PUI] Fix user detail save on PUI (#7906)
Browse files Browse the repository at this point in the history
* fix API for user details

* fix allow_blank

* fix saving user details
  • Loading branch information
matmair authored Aug 18, 2024
1 parent 8bf4ce5 commit 8a0d22d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/backend/InvenTree/InvenTree/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,17 @@ class Meta:
model = User
fields = ['pk', 'username', 'first_name', 'last_name', 'email']

read_only_fields = ['username']
read_only_fields = ['username', 'email']

username = serializers.CharField(label=_('Username'), help_text=_('Username'))
first_name = serializers.CharField(
label=_('First Name'), help_text=_('First name of the user')
label=_('First Name'), help_text=_('First name of the user'), allow_blank=True
)
last_name = serializers.CharField(
label=_('Last Name'), help_text=_('Last name of the user')
label=_('Last Name'), help_text=_('Last name of the user'), allow_blank=True
)
email = serializers.EmailField(
label=_('Email'), help_text=_('Email address of the user')
label=_('Email'), help_text=_('Email address of the user'), allow_blank=True
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ export function AccountDetailPanel() {
const form = useForm({ initialValues: user });
const [editing, setEditing] = useToggle([false, true] as const);
function SaveData(values: any) {
// copy values over to break form rendering link
const urlVals = { ...values };
urlVals.is_active = true;
// send
api
.put(apiUrl(ApiEndpoints.user_me), values)
.put(apiUrl(ApiEndpoints.user_me), urlVals)
.then((res) => {
if (res.status === 200) {
setEditing();
Expand Down

0 comments on commit 8a0d22d

Please sign in to comment.