2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

Use int PK instead of regex string in API endpoints (#9399)

* Convert company api endpoints to use int PK instead of regex string

* Convert additional path PK strings to ints
This commit is contained in:
Joe Rogers 2025-03-30 06:54:19 +02:00 committed by GitHub
parent 7f5a447769
commit 2457dfee70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 22 deletions

View File

@ -1,13 +1,16 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 328
INVENTREE_API_VERSION = 329
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v329 - 2025-03-30 : https://github.com/inventree/InvenTree/pull/9399
- Convert url path regex-specified PKs to int
v228 - 2025-03-29 : https://github.com/inventree/InvenTree/pull/9407
- Updates schema to include paging arguments

View File

@ -1,7 +1,7 @@
"""Provides a JSON API for the Company app."""
from django.db.models import Q
from django.urls import include, path, re_path
from django.urls import include, path
from django.utils.translation import gettext_lazy as _
from django_filters import rest_framework as rest_filters
@ -511,8 +511,8 @@ manufacturer_part_api_urls = [
),
]),
),
re_path(
r'^(?P<pk>\d+)/?',
path(
'<int:pk>/',
include([
path(
'metadata/',
@ -533,8 +533,8 @@ manufacturer_part_api_urls = [
supplier_part_api_urls = [
re_path(
r'^(?P<pk>\d+)/?',
path(
'<int:pk>/',
include([
path(
'metadata/',
@ -557,8 +557,8 @@ company_api_urls = [
path(
'price-break/',
include([
re_path(
r'^(?P<pk>\d+)/?',
path(
'<int:pk>/',
SupplierPriceBreakDetail.as_view(),
name='api-part-supplier-price-detail',
),
@ -569,8 +569,8 @@ company_api_urls = [
),
]),
),
re_path(
r'^(?P<pk>\d+)/?',
path(
'<int:pk>/',
include([
path(
'metadata/',
@ -584,8 +584,8 @@ company_api_urls = [
path(
'contact/',
include([
re_path(
r'^(?P<pk>\d+)/?',
path(
'<int:pk>/',
include([
path(
'metadata/',

View File

@ -4,7 +4,7 @@ import functools
import re
from django.db.models import Count, F, Q
from django.urls import include, path, re_path
from django.urls import include, path
from django.utils.translation import gettext_lazy as _
from django_filters import rest_framework as rest_filters
@ -2180,10 +2180,8 @@ part_api_urls = [
'thumbs/',
include([
path('', PartThumbs.as_view(), name='api-part-thumbs'),
re_path(
r'^(?P<pk>\d+)/?',
PartThumbsUpdate.as_view(),
name='api-part-thumbs-update',
path(
'<int:pk>/', PartThumbsUpdate.as_view(), name='api-part-thumbs-update'
),
]),
),

View File

@ -4,7 +4,7 @@ import datetime
from django.contrib.auth import get_user, login
from django.contrib.auth.models import Group, User
from django.urls import include, path, re_path
from django.urls import include, path
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.generic.base import RedirectView
@ -395,12 +395,10 @@ user_urls = [
path(
'group/',
include([
re_path(
r'^(?P<pk>[0-9]+)/?$', GroupDetail.as_view(), name='api-group-detail'
),
path('<int:pk>/', GroupDetail.as_view(), name='api-group-detail'),
path('', GroupList.as_view(), name='api-group-list'),
]),
),
re_path(r'^(?P<pk>[0-9]+)/?$', UserDetail.as_view(), name='api-user-detail'),
path('<int:pk>/', UserDetail.as_view(), name='api-user-detail'),
path('', UserList.as_view(), name='api-user-list'),
]