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

Remove 'url' field from serializers (#9150)

* Remove 'url' field from serializers

- Not used in any official client
- Inconsistent use across models

* Bump API version

* Adjust unit tests

* Fix API version
This commit is contained in:
Oliver 2025-02-23 21:07:34 +11:00 committed by GitHub
parent 9d1d0fa66b
commit c9666ff8ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 16 additions and 30 deletions

View File

@ -1,13 +1,16 @@
"""InvenTree API version information.""" """InvenTree API version information."""
# InvenTree API version # InvenTree API version
INVENTREE_API_VERSION = 314 INVENTREE_API_VERSION = 315
"""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 = """
v315 - 2025-02-22 : https://github.com/inventree/InvenTree/pull/9150
- Remove outdated 'url' field from some API endpoints
v314 - 2025-02-17 : https://github.com/inventree/InvenTree/pull/6293 v314 - 2025-02-17 : https://github.com/inventree/InvenTree/pull/6293
- Removes a considerable amount of old auth endpoints - Removes a considerable amount of old auth endpoints
- Introduces allauth-provided auth endpoints - Introduces allauth-provided auth endpoints
@ -74,7 +77,7 @@ v297 - 2024-12-29 : https://github.com/inventree/InvenTree/pull/8438
- Adjustments to the CustomUserState API endpoints and serializers - Adjustments to the CustomUserState API endpoints and serializers
v296 - 2024-12-25 : https://github.com/inventree/InvenTree/pull/8732 v296 - 2024-12-25 : https://github.com/inventree/InvenTree/pull/8732
- Adjust default "part_detail" behaviour for StockItem API endpoints - Adjust default "part_detail" behavior for StockItem API endpoints
v295 - 2024-12-23 : https://github.com/inventree/InvenTree/pull/8746 v295 - 2024-12-23 : https://github.com/inventree/InvenTree/pull/8746
- Improve API documentation for build APIs - Improve API documentation for build APIs
@ -226,7 +229,7 @@ v252 - 2024-09-13 : https://github.com/inventree/InvenTree/pull/8040
- Add endpoint for listing all known units - Add endpoint for listing all known units
v251 - 2024-09-06 : https://github.com/inventree/InvenTree/pull/8018 v251 - 2024-09-06 : https://github.com/inventree/InvenTree/pull/8018
- Adds "attach_to_model" field to the ReporTemplate model - Adds "attach_to_model" field to the ReportTemplate model
v250 - 2024-09-04 : https://github.com/inventree/InvenTree/pull/8069 v250 - 2024-09-04 : https://github.com/inventree/InvenTree/pull/8069
- Fixes 'revision' field definition in Part serializer - Fixes 'revision' field definition in Part serializer
@ -367,7 +370,7 @@ v211 - 2024-06-26 : https://github.com/inventree/InvenTree/pull/6911
- Adds API endpoints for managing data import and export - Adds API endpoints for managing data import and export
v210 - 2024-06-26 : https://github.com/inventree/InvenTree/pull/7518 v210 - 2024-06-26 : https://github.com/inventree/InvenTree/pull/7518
- Adds translateable text to User API fields - Adds translatable text to User API fields
v209 - 2024-06-26 : https://github.com/inventree/InvenTree/pull/7514 v209 - 2024-06-26 : https://github.com/inventree/InvenTree/pull/7514
- Add "top_level" filter to PartCategory API endpoint - Add "top_level" filter to PartCategory API endpoint
@ -489,7 +492,7 @@ v178 - 2024-02-29 : https://github.com/inventree/InvenTree/pull/6604
- Stock quantities represented in the BuildLine API endpoint are now filtered by Build.source_location - Stock quantities represented in the BuildLine API endpoint are now filtered by Build.source_location
v177 - 2024-02-27 : https://github.com/inventree/InvenTree/pull/6581 v177 - 2024-02-27 : https://github.com/inventree/InvenTree/pull/6581
- Adds "subcategoies" count to PartCategoryTree serializer - Adds "subcategories" count to PartCategoryTree serializer
- Adds "sublocations" count to StockLocationTree serializer - Adds "sublocations" count to StockLocationTree serializer
v176 - 2024-02-26 : https://github.com/inventree/InvenTree/pull/6535 v176 - 2024-02-26 : https://github.com/inventree/InvenTree/pull/6535
@ -579,7 +582,7 @@ v153 -> 2023-11-21 : https://github.com/inventree/InvenTree/pull/5956
- Adds override_min and override_max fields to part pricing API - Adds override_min and override_max fields to part pricing API
v152 -> 2023-11-20 : https://github.com/inventree/InvenTree/pull/5949 v152 -> 2023-11-20 : https://github.com/inventree/InvenTree/pull/5949
- Adds barcode support for manufacturerpart model - Adds barcode support for ManufacturerPart model
- Adds API endpoint for adding parts to purchase order using barcode scan - Adds API endpoint for adding parts to purchase order using barcode scan
v151 -> 2023-11-13 : https://github.com/inventree/InvenTree/pull/5906 v151 -> 2023-11-13 : https://github.com/inventree/InvenTree/pull/5906
@ -1094,7 +1097,7 @@ v8 -> 2021-07-19
v7 -> 2021-07-03 v7 -> 2021-07-03
- Introduced the concept of "API forms" in https://github.com/inventree/InvenTree/pull/1716 - Introduced the concept of "API forms" in https://github.com/inventree/InvenTree/pull/1716
- API OPTIONS endpoints provide comprehensive field metedata - API OPTIONS endpoints provide comprehensive field metadata
- Multiple new API endpoints added for database models - Multiple new API endpoints added for database models
v6 -> 2021-06-23 v6 -> 2021-06-23

View File

@ -62,7 +62,6 @@ class BuildSerializer(
model = Build model = Build
fields = [ fields = [
'pk', 'pk',
'url',
'title', 'title',
'barcode_hash', 'barcode_hash',
'batch', 'batch',
@ -112,8 +111,6 @@ class BuildSerializer(
level = serializers.IntegerField(label=_('Build Level'), read_only=True) level = serializers.IntegerField(label=_('Build Level'), read_only=True)
url = serializers.CharField(source='get_absolute_url', read_only=True)
status_text = serializers.CharField(source='get_status_display', read_only=True) status_text = serializers.CharField(source='get_status_display', read_only=True)
part_detail = part_serializers.PartBriefSerializer( part_detail = part_serializers.PartBriefSerializer(
@ -424,7 +421,7 @@ class BuildOutputCreateSerializer(serializers.Serializer):
except DjangoValidationError as e: except DjangoValidationError as e:
raise ValidationError({'serial_numbers': e.messages}) raise ValidationError({'serial_numbers': e.messages})
# Check for conflicting serial numbesr # Check for conflicting serial numbers
existing = part.find_conflicting_serial_numbers(self.serials) existing = part.find_conflicting_serial_numbers(self.serials)
if len(existing) > 0: if len(existing) > 0:

View File

@ -113,7 +113,7 @@ class CompanySerializer(
): ):
"""Serializer for Company object (full detail).""" """Serializer for Company object (full detail)."""
export_exclude_fields = ['url', 'primary_address'] export_exclude_fields = ['primary_address']
import_exclude_fields = ['image'] import_exclude_fields = ['image']
@ -123,7 +123,6 @@ class CompanySerializer(
model = Company model = Company
fields = [ fields = [
'pk', 'pk',
'url',
'name', 'name',
'description', 'description',
'website', 'website',
@ -163,8 +162,6 @@ class CompanySerializer(
primary_address = AddressSerializer(required=False, allow_null=True, read_only=True) primary_address = AddressSerializer(required=False, allow_null=True, read_only=True)
url = serializers.CharField(source='get_absolute_url', read_only=True)
image = InvenTreeImageSerializerField(required=False, allow_null=True) image = InvenTreeImageSerializerField(required=False, allow_null=True)
email = serializers.EmailField( email = serializers.EmailField(
@ -353,7 +350,6 @@ class SupplierPartSerializer(
'SKU', 'SKU',
'supplier', 'supplier',
'supplier_detail', 'supplier_detail',
'url',
'updated', 'updated',
'notes', 'notes',
'tags', 'tags',
@ -445,8 +441,6 @@ class SupplierPartSerializer(
source='manufacturer_part.MPN', read_only=True, label=_('MPN') source='manufacturer_part.MPN', read_only=True, label=_('MPN')
) )
url = serializers.CharField(source='get_absolute_url', read_only=True)
# Date fields # Date fields
updated = serializers.DateTimeField(allow_null=True, read_only=True) updated = serializers.DateTimeField(allow_null=True, read_only=True)

View File

@ -81,7 +81,6 @@ class CategorySerializer(
'pathstring', 'pathstring',
'path', 'path',
'starred', 'starred',
'url',
'structural', 'structural',
'icon', 'icon',
'parent_default_location', 'parent_default_location',
@ -124,8 +123,6 @@ class CategorySerializer(
help_text=_('Parent part category'), help_text=_('Parent part category'),
) )
url = serializers.CharField(source='get_absolute_url', read_only=True)
part_count = serializers.IntegerField(read_only=True, label=_('Parts')) part_count = serializers.IntegerField(read_only=True, label=_('Parts'))
subcategories = serializers.IntegerField(read_only=True, label=_('Subcategories')) subcategories = serializers.IntegerField(read_only=True, label=_('Subcategories'))
@ -1134,11 +1131,11 @@ class PartSerializer(
mpn = initial_supplier.get('mpn', '') mpn = initial_supplier.get('mpn', '')
if manufacturer and mpn: if manufacturer and mpn:
manu_part = company.models.ManufacturerPart.objects.create( manufacturer_part = company.models.ManufacturerPart.objects.create(
part=instance, manufacturer=manufacturer, MPN=mpn part=instance, manufacturer=manufacturer, MPN=mpn
) )
else: else:
manu_part = None manufacturer_part = None
supplier = initial_supplier.get('supplier', None) supplier = initial_supplier.get('supplier', None)
sku = initial_supplier.get('sku', '') sku = initial_supplier.get('sku', '')
@ -1148,7 +1145,7 @@ class PartSerializer(
part=instance, part=instance,
supplier=supplier, supplier=supplier,
SKU=sku, SKU=sku,
manufacturer_part=manu_part, manufacturer_part=manufacturer_part,
) )
return instance return instance

View File

@ -178,7 +178,6 @@ class PartCategoryAPITest(InvenTreeAPITestCase):
'parent', 'parent',
'part_count', 'part_count',
'pathstring', 'pathstring',
'url',
] ]
response = self.get(url, expected_code=200) response = self.get(url, expected_code=200)

View File

@ -32,7 +32,7 @@ class MetadataSerializer(serializers.ModelSerializer):
- Else, if it is a PUT update, overwrite any existing metadata - Else, if it is a PUT update, overwrite any existing metadata
""" """
if self.partial: if self.partial:
# Default behaviour is to "merge" new data in # Default behavior is to "merge" new data in
metadata = instance.metadata.copy() if instance.metadata else {} metadata = instance.metadata.copy() if instance.metadata else {}
metadata.update(data['metadata']) metadata.update(data['metadata'])
data['metadata'] = metadata data['metadata'] = metadata

View File

@ -1153,7 +1153,6 @@ class LocationSerializer(
fields = [ fields = [
'pk', 'pk',
'barcode_hash', 'barcode_hash',
'url',
'name', 'name',
'level', 'level',
'description', 'description',
@ -1206,8 +1205,6 @@ class LocationSerializer(
help_text=_('Parent stock location'), help_text=_('Parent stock location'),
) )
url = serializers.CharField(source='get_absolute_url', read_only=True)
items = serializers.IntegerField(read_only=True, label=_('Stock Items')) items = serializers.IntegerField(read_only=True, label=_('Stock Items'))
sublocations = serializers.IntegerField(read_only=True, label=_('Sublocations')) sublocations = serializers.IntegerField(read_only=True, label=_('Sublocations'))

View File

@ -114,7 +114,6 @@ class StockLocationTest(StockAPITestCase):
'items', 'items',
'pathstring', 'pathstring',
'owner', 'owner',
'url',
'icon', 'icon',
'location_type', 'location_type',
'location_type_detail', 'location_type_detail',