mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
[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:
parent
8bf4ce573f
commit
8a0d22d15d
@ -402,17 +402,17 @@ class UserSerializer(InvenTreeModelSerializer):
|
|||||||
model = User
|
model = User
|
||||||
fields = ['pk', 'username', 'first_name', 'last_name', 'email']
|
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'))
|
username = serializers.CharField(label=_('Username'), help_text=_('Username'))
|
||||||
first_name = serializers.CharField(
|
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(
|
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(
|
email = serializers.EmailField(
|
||||||
label=_('Email'), help_text=_('Email address of the user')
|
label=_('Email'), help_text=_('Email address of the user'), allow_blank=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,8 +17,12 @@ export function AccountDetailPanel() {
|
|||||||
const form = useForm({ initialValues: user });
|
const form = useForm({ initialValues: user });
|
||||||
const [editing, setEditing] = useToggle([false, true] as const);
|
const [editing, setEditing] = useToggle([false, true] as const);
|
||||||
function SaveData(values: any) {
|
function SaveData(values: any) {
|
||||||
|
// copy values over to break form rendering link
|
||||||
|
const urlVals = { ...values };
|
||||||
|
urlVals.is_active = true;
|
||||||
|
// send
|
||||||
api
|
api
|
||||||
.put(apiUrl(ApiEndpoints.user_me), values)
|
.put(apiUrl(ApiEndpoints.user_me), urlVals)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
setEditing();
|
setEditing();
|
||||||
|
Loading…
Reference in New Issue
Block a user