diff --git a/InvenTree/InvenTree/static/script/inventree/part.js b/InvenTree/InvenTree/static/script/inventree/part.js index 927afca2e6..05328dbbd8 100644 --- a/InvenTree/InvenTree/static/script/inventree/part.js +++ b/InvenTree/InvenTree/static/script/inventree/part.js @@ -147,6 +147,10 @@ function loadPartTable(table, url, options={}) { display += ``; } + if (row.starred) { + display += ``; + } + /* if (row.component) { display = display + ``; diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 629136af05..6615b4df43 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -258,12 +258,18 @@ class PartList(generics.ListCreateAPIView): # Filter items which have an 'in_stock' level higher than 'minimum_stock' data = data.filter(Q(in_stock__gte=F('minimum_stock'))) + # Get a list of the parts that this user has starred + starred_parts = [star.part.pk for star in self.request.user.starred_parts.all()] + # Reduce the number of lookups we need to do for the part categories categories = {} for item in data: if item['image']: + # Is this part 'starred' for the current user? + item['starred'] = item['pk'] in starred_parts + img = item['image'] # Use the 'thumbnail' image here instead of the full-size image