[PUI] Fix user detail save on PUI (#7906)

* fix API for user details

* fix allow_blank

* fix saving user details
This commit is contained in:
Matthias Mair 2024-08-18 23:57:40 +02:00 committed by GitHub
parent 8bf4ce573f
commit 8a0d22d15d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -402,17 +402,17 @@ class UserSerializer(InvenTreeModelSerializer):
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
)

View File

@ -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();