mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Display 'starred' status on the Part information page
This commit is contained in:
parent
b2e935382b
commit
bbd164407f
@ -247,6 +247,15 @@ class Part(models.Model):
|
||||
|
||||
return total
|
||||
|
||||
def isStarredBy(self, user):
|
||||
""" Return True if this part has been starred by a particular user """
|
||||
|
||||
try:
|
||||
PartStar.objects.get(part=self, user=user)
|
||||
return True
|
||||
except PartStar.DoesNotExist:
|
||||
return False
|
||||
|
||||
def need_to_restock(self):
|
||||
""" Return True if this part needs to be restocked
|
||||
(either by purchasing or building).
|
||||
|
@ -28,7 +28,9 @@
|
||||
<p>
|
||||
<div class='btn-group'>
|
||||
<button type='button' class='btn btn-default btn-glyph' id='show-qr-code' title='Show QR code'><span class='glyphicon glyphicon-qrcode'></span></button>
|
||||
<button type='button' class='btn btn-default btn-glyph' id='toggle-starred' title='Star this part'><span id='part-star-icon' class='glyphicon glyphicon-star-empty'/></button>
|
||||
<button type='button' class='btn btn-default btn-glyph' id='toggle-starred' title='Star this part'>
|
||||
<span id='part-star-icon' class='glyphicon {% if starred %}glyphicon-star{% else %}glyphicon-star-empty{% endif %}'/>
|
||||
</button>
|
||||
</div>
|
||||
</p>
|
||||
<table class='table table-condensed'>
|
||||
|
@ -232,6 +232,10 @@ class PartDetail(DetailView):
|
||||
else:
|
||||
context['editing_enabled'] = 0
|
||||
|
||||
part = self.get_object()
|
||||
|
||||
context['starred'] = part.isStarredBy(self.request.user)
|
||||
|
||||
return context
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user