mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
[PUI] Tweaks (#6516)
* Enable editing "part" in PartTestTemplate * Hide part if user is not staff * API: allow filtering of templates by key * Update API docs
This commit is contained in:
parent
3b11a01966
commit
3a52a1631d
@ -1,11 +1,14 @@
|
|||||||
"""InvenTree API version information."""
|
"""InvenTree API version information."""
|
||||||
|
|
||||||
# InvenTree API version
|
# InvenTree API version
|
||||||
INVENTREE_API_VERSION = 170
|
INVENTREE_API_VERSION = 171
|
||||||
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
|
||||||
|
|
||||||
INVENTREE_API_TEXT = """
|
INVENTREE_API_TEXT = """
|
||||||
|
|
||||||
|
v171 - 2024-02-19 : https://github.com/inventree/InvenTree/pull/6516
|
||||||
|
- Adds "key" as a filterable parameter to PartTestTemplate list endpoint
|
||||||
|
|
||||||
v170 -> 2024-02-19 : https://github.com/inventree/InvenTree/pull/6514
|
v170 -> 2024-02-19 : https://github.com/inventree/InvenTree/pull/6514
|
||||||
- Adds "has_results" filter to the PartTestTemplate list endpoint
|
- Adds "has_results" filter to the PartTestTemplate list endpoint
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ class PartTestTemplateFilter(rest_filters.FilterSet):
|
|||||||
"""Metaclass options for this filterset."""
|
"""Metaclass options for this filterset."""
|
||||||
|
|
||||||
model = PartTestTemplate
|
model = PartTestTemplate
|
||||||
fields = ['required', 'requires_value', 'requires_attachment']
|
fields = ['required', 'requires_value', 'requires_attachment', 'key']
|
||||||
|
|
||||||
part = rest_filters.ModelChoiceFilter(
|
part = rest_filters.ModelChoiceFilter(
|
||||||
queryset=Part.objects.filter(trackable=True),
|
queryset=Part.objects.filter(trackable=True),
|
||||||
|
@ -17,6 +17,8 @@ interface UserStateProps {
|
|||||||
hasChangeRole: (role: UserRoles) => boolean;
|
hasChangeRole: (role: UserRoles) => boolean;
|
||||||
hasAddRole: (role: UserRoles) => boolean;
|
hasAddRole: (role: UserRoles) => boolean;
|
||||||
hasViewRole: (role: UserRoles) => boolean;
|
hasViewRole: (role: UserRoles) => boolean;
|
||||||
|
isStaff: () => boolean;
|
||||||
|
isSuperuser: () => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,6 +93,14 @@ export const useUserState = create<UserStateProps>((set, get) => ({
|
|||||||
|
|
||||||
return user?.roles[role]?.includes(permission) ?? false;
|
return user?.roles[role]?.includes(permission) ?? false;
|
||||||
},
|
},
|
||||||
|
isStaff: () => {
|
||||||
|
const user: UserProps = get().user as UserProps;
|
||||||
|
return user?.is_staff ?? false;
|
||||||
|
},
|
||||||
|
isSuperuser: () => {
|
||||||
|
const user: UserProps = get().user as UserProps;
|
||||||
|
return user?.is_superuser ?? false;
|
||||||
|
},
|
||||||
hasDeleteRole: (role: UserRoles) => {
|
hasDeleteRole: (role: UserRoles) => {
|
||||||
return get().checkUserRole(role, UserPermissions.delete);
|
return get().checkUserRole(role, UserPermissions.delete);
|
||||||
},
|
},
|
||||||
|
@ -94,7 +94,7 @@ export default function PartTestTemplateTable({ partId }: { partId: number }) {
|
|||||||
const partTestTemplateFields: ApiFormFieldSet = useMemo(() => {
|
const partTestTemplateFields: ApiFormFieldSet = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
part: {
|
part: {
|
||||||
hidden: true
|
hidden: !user.isStaff()
|
||||||
},
|
},
|
||||||
test_name: {},
|
test_name: {},
|
||||||
description: {},
|
description: {},
|
||||||
@ -102,7 +102,7 @@ export default function PartTestTemplateTable({ partId }: { partId: number }) {
|
|||||||
requires_value: {},
|
requires_value: {},
|
||||||
requires_attachment: {}
|
requires_attachment: {}
|
||||||
};
|
};
|
||||||
}, []);
|
}, [user]);
|
||||||
|
|
||||||
const newTestTemplate = useCreateApiFormModal({
|
const newTestTemplate = useCreateApiFormModal({
|
||||||
url: ApiEndpoints.part_test_template_list,
|
url: ApiEndpoints.part_test_template_list,
|
||||||
|
Loading…
Reference in New Issue
Block a user