mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 04:26:44 +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
|
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):
|
def need_to_restock(self):
|
||||||
""" Return True if this part needs to be restocked
|
""" Return True if this part needs to be restocked
|
||||||
(either by purchasing or building).
|
(either by purchasing or building).
|
||||||
|
@ -28,7 +28,9 @@
|
|||||||
<p>
|
<p>
|
||||||
<div class='btn-group'>
|
<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='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>
|
</div>
|
||||||
</p>
|
</p>
|
||||||
<table class='table table-condensed'>
|
<table class='table table-condensed'>
|
||||||
|
@ -232,6 +232,10 @@ class PartDetail(DetailView):
|
|||||||
else:
|
else:
|
||||||
context['editing_enabled'] = 0
|
context['editing_enabled'] = 0
|
||||||
|
|
||||||
|
part = self.get_object()
|
||||||
|
|
||||||
|
context['starred'] = part.isStarredBy(self.request.user)
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user