2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 04:25:42 +00:00

Simplify process for marking a part as "starred"

This commit is contained in:
Oliver Walters
2021-02-25 23:27:27 +11:00
parent 35b9b17167
commit f2da1c990b
5 changed files with 59 additions and 44 deletions

View File

@ -1056,6 +1056,23 @@ class Part(MPTTModel):
except PartStar.DoesNotExist:
return False
def setStarred(self, user, starred):
"""
Set the "starred" status of this Part for the given user
"""
if not user:
return
# Do not duplicate efforts
if self.isStarredBy(user) == starred:
return
if starred:
PartStar.objects.create(part=self, user=user)
else:
PartStar.objects.filter(part=self, user=user).delete()
def need_to_restock(self):
""" Return True if this part needs to be restocked
(either by purchasing or building).