diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 4f1e172e5a..bbd42b957c 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -101,7 +101,7 @@ INSTALLED_APPS = [ 'crispy_forms', # Improved form rendering 'import_export', # Import / export tables to file 'django_cleanup', # Automatically delete orphaned MEDIA files - #'qr_code', # Generate QR codes + # 'qr_code', # Generate QR codes 'mptt', # Modified Preorder Tree Traversal 'markdownx', # Markdown editing 'markdownify', # Markdown template rendering diff --git a/InvenTree/InvenTree/urls.py b/InvenTree/InvenTree/urls.py index 76ab422e7d..53d2d07544 100644 --- a/InvenTree/InvenTree/urls.py +++ b/InvenTree/InvenTree/urls.py @@ -8,7 +8,8 @@ Passes URL lookup downstream to each app as required. from django.conf.urls import url, include from django.contrib import admin from django.contrib.auth import views as auth_views -#from qr_code import urls as qr_code_urls +# TODO - Remove this line once a new QR solution has been implemented +# from qr_code import urls as qr_code_urls from company.urls import company_urls from company.urls import supplier_part_urls @@ -99,7 +100,8 @@ urlpatterns = [ url(r'^admin/', admin.site.urls, name='inventree-admin'), - #url(r'^qr_code/', include(qr_code_urls, namespace='qr_code')), + # TODO - Remove this line! + # url(r'^qr_code/', include(qr_code_urls, namespace='qr_code')), url(r'^index/', IndexView.as_view(), name='index'), url(r'^search/', SearchView.as_view(), name='search'), diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index c65e3c673c..6eda5539dd 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -6,10 +6,8 @@ Provides a JSON API for the Part app from __future__ import unicode_literals from django_filters.rest_framework import DjangoFilterBackend -from django.conf import settings -from django.db.models import Q, F, Sum, Count -from django.db.models.functions import Coalesce +from django.db.models import Q, F, Count from rest_framework import status from rest_framework.response import Response @@ -19,15 +17,11 @@ from rest_framework import generics, permissions from django.conf.urls import url, include from django.urls import reverse -import os -from decimal import Decimal - from .models import Part, PartCategory, BomItem, PartStar from .models import PartParameter, PartParameterTemplate from . import serializers as part_serializers -from InvenTree.status_codes import OrderStatus, StockStatus, BuildStatus from InvenTree.views import TreeSerializer from InvenTree.helpers import str2bool, isNull @@ -125,6 +119,8 @@ class PartThumbs(generics.ListAPIView): # Get all Parts which have an associated image queryset = Part.objects.all().exclude(image='') + # TODO - We should return the thumbnails here, not the full image! + # Return the most popular parts first data = queryset.values( 'image', @@ -209,7 +205,6 @@ class PartList(generics.ListCreateAPIView): headers = self.get_success_headers(serializer.data) return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers) - def filter_queryset(self, queryset): """ Perform custom filtering of the queryset diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py index 1b60be121f..23e85df1a4 100644 --- a/InvenTree/part/serializers.py +++ b/InvenTree/part/serializers.py @@ -12,7 +12,7 @@ from .models import PartParameter, PartParameterTemplate from decimal import Decimal -from django.db.models import Q, F, Sum, Count +from django.db.models import Q, Sum from django.db.models.functions import Coalesce from InvenTree.status_codes import StockStatus, OrderStatus, BuildStatus @@ -99,7 +99,6 @@ class PartSerializer(InvenTreeModelSerializer): if category_detail is not True: self.fields.pop('category_detail') - @staticmethod def prefetch_queryset(queryset): """ @@ -123,7 +122,7 @@ class PartSerializer(InvenTreeModelSerializer): @staticmethod def annotate_queryset(queryset): """ - Add some extra annotations to the queryset, + Add some extra annotations to the queryset, performing database queries as efficiently as possible, to reduce database trips. """