Added 'part tracking' page

- e.g. /part/<pk>/track
This commit is contained in:
Oliver 2018-04-14 00:46:18 +10:00
parent eec725d90f
commit 63f7fe640c
9 changed files with 38 additions and 6 deletions

View File

@ -49,8 +49,8 @@ INSTALLED_APPS = [
'bom.apps.BomConfig',
'supplier.apps.SupplierConfig',
'stock.apps.StockConfig',
'track.apps.TrackConfig',
#'project.apps.ProjectConfig',
#'track.apps.TrackConfig',
]
MIDDLEWARE = [

View File

@ -9,4 +9,10 @@ Used in {{ part.usedInCount }} other parts.<br>
<a href="{% url 'stock' part.id %}">There are {{ part.stock }} units in stock.</a>
<br><br>
{% if part.trackable %}
<a href="{% url 'track' part.id %}">Part tracking</a>
{% else %}
{{ part.name }} does not have part tracking enabled
{% endif %}
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "part/base.html" %}
{% extends "base.html" %}
{% block content %}

View File

@ -1,4 +1,4 @@
{% extends "part/base.html" %}
{% extends "base.html" %}
{% block content %}

View File

@ -0,0 +1,20 @@
{% extends "part/part_base.html" %}
{% block details %}
Part tracking for {{ part.name }}
<table>
<tr>
<th>Serial</th>
<th>Status</th>
</tr>
{% for track in part.serials.all %}
<tr>
<td>{{ track.serial }}</td>
<td>{{ track.status }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View File

@ -29,7 +29,7 @@ part_api_urls = [
]
part_detail_urls = [
url(r'^track/?', views.track, name='track'),
url(r'^bom/?', views.bom, name='bom'),
url(r'^stock/?', views.stock, name='stock'),
url('', views.detail, name='detail'),

View File

@ -74,6 +74,11 @@ def stock(request, pk):
return render(request, 'part/stock.html', {'part': part})
def track(request, pk):
part = get_object_or_404(Part, pk=pk)
return render(request, 'part/track.html', {'part': part})
#def results(request, question_id):
# response = "You're looking at the results of question %s."

View File

@ -32,11 +32,12 @@ class UniquePart(models.Model):
# Cannot have multiple parts with same serial number
unique_together = ('part', 'serial')
part = models.ForeignKey(Part, on_delete=models.CASCADE)
part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='serials')
creation_date = models.DateField(auto_now_add=True,
editable=False)
serial = models.IntegerField()
serial = models.PositiveIntegerField()
# createdBy = models.ForeignKey(User)