mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-11-03 22:55:43 +00:00 
			
		
		
		
	Parameter ordering fix (#3704)
* Hard-code URL fforr loadPartParameterTable function * Improve API efficiency for including parameter data in Part query * Fix loading of part parameter data into table
This commit is contained in:
		@@ -1605,6 +1605,20 @@ class PartParameterList(ListCreateAPI):
 | 
			
		||||
    queryset = PartParameter.objects.all()
 | 
			
		||||
    serializer_class = part_serializers.PartParameterSerializer
 | 
			
		||||
 | 
			
		||||
    def get_serializer(self, *args, **kwargs):
 | 
			
		||||
        """Return the serializer instance for this API endpoint.
 | 
			
		||||
 | 
			
		||||
        If requested, extra detail fields are annotated to the queryset:
 | 
			
		||||
        - template_detail
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
        try:
 | 
			
		||||
            kwargs['template_detail'] = str2bool(self.request.GET.get('template_detail', True))
 | 
			
		||||
        except AttributeError:
 | 
			
		||||
            pass
 | 
			
		||||
 | 
			
		||||
        return self.serializer_class(*args, **kwargs)
 | 
			
		||||
 | 
			
		||||
    filter_backends = [
 | 
			
		||||
        DjangoFilterBackend
 | 
			
		||||
    ]
 | 
			
		||||
 
 | 
			
		||||
@@ -247,6 +247,19 @@ class PartParameterTemplateSerializer(InvenTreeModelSerializer):
 | 
			
		||||
class PartParameterSerializer(InvenTreeModelSerializer):
 | 
			
		||||
    """JSON serializers for the PartParameter model."""
 | 
			
		||||
 | 
			
		||||
    def __init__(self, *args, **kwargs):
 | 
			
		||||
        """Custom initialization method for the serializer.
 | 
			
		||||
 | 
			
		||||
        Allows us to optionally include or exclude particular information
 | 
			
		||||
        """
 | 
			
		||||
 | 
			
		||||
        template_detail = kwargs.pop('template_detail', False)
 | 
			
		||||
 | 
			
		||||
        super().__init__(*args, **kwargs)
 | 
			
		||||
 | 
			
		||||
        if not template_detail:
 | 
			
		||||
            self.fields.pop('template_detail')
 | 
			
		||||
 | 
			
		||||
    template_detail = PartParameterTemplateSerializer(source='template', many=False, read_only=True)
 | 
			
		||||
 | 
			
		||||
    class Meta:
 | 
			
		||||
 
 | 
			
		||||
@@ -813,7 +813,6 @@
 | 
			
		||||
    onPanelLoad("part-parameters", function() {
 | 
			
		||||
        loadPartParameterTable(
 | 
			
		||||
            '#parameter-table',
 | 
			
		||||
            '{% url "api-part-parameter-list" %}',
 | 
			
		||||
            {
 | 
			
		||||
                params: {
 | 
			
		||||
                    part: {{ part.pk }},
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user