diff --git a/src/backend/InvenTree/InvenTree/api_version.py b/src/backend/InvenTree/InvenTree/api_version.py index 599fb56daf..5df3a8beb5 100644 --- a/src/backend/InvenTree/InvenTree/api_version.py +++ b/src/backend/InvenTree/InvenTree/api_version.py @@ -1,13 +1,16 @@ """InvenTree API version information.""" # InvenTree API version -INVENTREE_API_VERSION = 244 +INVENTREE_API_VERSION = 245 """Increment this API version number whenever there is a significant change to the API that any clients need to know about.""" INVENTREE_API_TEXT = """ +v245 - 2024-08-21 : https://github.com/inventree/InvenTree/pull/7520 + - Documented pagination fields (no functional changes) + v244 - 2024-08-21 : https://github.com/inventree/InvenTree/pull/7941 - Adds "create_child_builds" field to the Build API - Write-only field to create child builds from the API diff --git a/src/backend/InvenTree/InvenTree/test_api.py b/src/backend/InvenTree/InvenTree/test_api.py index e462af3b50..0ec1f169f2 100644 --- a/src/backend/InvenTree/InvenTree/test_api.py +++ b/src/backend/InvenTree/InvenTree/test_api.py @@ -92,9 +92,7 @@ class APITests(InvenTreeAPITestCase): """Test token resolve endpoint does not work without basic auth.""" # Test token endpoint without basic auth url = reverse('api-token') - response = self.client.get(url, format='json') - - self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) + self.get(url, expected_code=401) self.assertIsNone(self.token) def test_token_success(self): @@ -106,7 +104,7 @@ class APITests(InvenTreeAPITestCase): """Test that we can read the 'info-view' endpoint.""" url = reverse('api-inventree-info') - response = self.client.get(url, format='json') + response = self.get(url) data = response.json() self.assertIn('server', data) @@ -126,7 +124,7 @@ class APITests(InvenTreeAPITestCase): self.group.rule_sets.all().delete() update_group_roles(self.group) - response = self.client.get(url, format='json') + response = self.get(url, expected_code=401) # Not logged in, so cannot access user role data self.assertIn(response.status_code, [401, 403]) diff --git a/src/backend/InvenTree/InvenTree/test_api_version.py b/src/backend/InvenTree/InvenTree/test_api_version.py index 8bddb0c561..69a11e5026 100644 --- a/src/backend/InvenTree/InvenTree/test_api_version.py +++ b/src/backend/InvenTree/InvenTree/test_api_version.py @@ -13,12 +13,12 @@ class ApiVersionTests(InvenTreeAPITestCase): def test_api(self): """Test that the API text is correct.""" url = reverse('api-version-text') - response = self.client.get(url, format='json') + response = self.get(url, format='json') data = response.json() self.assertEqual(len(data), 10) - response = self.client.get(reverse('api-version'), format='json').json() + response = self.get(reverse('api-version')).json() self.assertIn('version', response) self.assertIn('dev', response) self.assertIn('up_to_date', response) diff --git a/src/backend/InvenTree/company/serializers.py b/src/backend/InvenTree/company/serializers.py index 5123b3f1e8..ba6d845c0a 100644 --- a/src/backend/InvenTree/company/serializers.py +++ b/src/backend/InvenTree/company/serializers.py @@ -166,6 +166,10 @@ class CompanySerializer( image = InvenTreeImageSerializerField(required=False, allow_null=True) + email = serializers.EmailField( + required=False, default='', allow_blank=True, allow_null=True + ) + parts_supplied = serializers.IntegerField(read_only=True) parts_manufactured = serializers.IntegerField(read_only=True) address_count = serializers.IntegerField(read_only=True) diff --git a/src/backend/InvenTree/company/test_api.py b/src/backend/InvenTree/company/test_api.py index 78064a3bc5..4774c9d1a9 100644 --- a/src/backend/InvenTree/company/test_api.py +++ b/src/backend/InvenTree/company/test_api.py @@ -2,8 +2,6 @@ from django.urls import reverse -from rest_framework import status - from InvenTree.unit_test import InvenTreeAPITestCase from part.models import Part @@ -394,8 +392,7 @@ class ManufacturerTest(InvenTreeAPITestCase): # Create manufacturer part data = {'part': 1, 'manufacturer': 7, 'MPN': 'MPN_TEST'} - response = self.client.post(url, data, format='json') - self.assertEqual(response.status_code, status.HTTP_201_CREATED) + response = self.post(url, data, expected_code=201) self.assertEqual(response.data['MPN'], 'MPN_TEST') # Filter by manufacturer @@ -418,9 +415,7 @@ class ManufacturerTest(InvenTreeAPITestCase): # Change the MPN data = {'MPN': 'MPN-TEST-123'} - response = self.client.patch(url, data, format='json') - - self.assertEqual(response.status_code, status.HTTP_200_OK) + response = self.patch(url, data) self.assertEqual(response.data['MPN'], 'MPN-TEST-123') def test_manufacturer_part_search(self): @@ -457,8 +452,7 @@ class ManufacturerTest(InvenTreeAPITestCase): 'link': 'https://www.axel-larsson.se/Exego.aspx?p_id=341&ArtNr=0804020E', } - response = self.client.post(url, data, format='json') - self.assertEqual(response.status_code, status.HTTP_201_CREATED) + response = self.post(url, data) # Check link is not modified self.assertEqual( diff --git a/src/backend/InvenTree/part/serializers.py b/src/backend/InvenTree/part/serializers.py index bca2aa391a..fac5f7cc14 100644 --- a/src/backend/InvenTree/part/serializers.py +++ b/src/backend/InvenTree/part/serializers.py @@ -348,6 +348,19 @@ class PartBriefSerializer(InvenTree.serializers.InvenTreeModelSerializer): image = InvenTree.serializers.InvenTreeImageSerializerField(read_only=True) thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True) + IPN = serializers.CharField( + required=False, + allow_null=True, + help_text=_('Internal Part Number'), + max_length=100, + ) + revision = serializers.CharField( + required=False, + allow_null=True, + help_text=_('Part revision or version number'), + max_length=100, + ) + # Pricing fields pricing_min = InvenTree.serializers.InvenTreeMoneySerializer( source='pricing_data.overall_min', allow_null=True, read_only=True @@ -891,6 +904,14 @@ class PartSerializer( queryset=users.models.User.objects.all(), required=False, allow_null=True ) + IPN = serializers.CharField( + required=False, default='', allow_blank=True, label=_('IPN'), max_length=100 + ) + + revision = serializers.CharField( + required=False, default='', allow_blank=True, max_length=100 + ) + # Annotated fields allocated_to_build_orders = serializers.FloatField(read_only=True) allocated_to_sales_orders = serializers.FloatField(read_only=True)