Merge branch 'master' of git.clkl.de:agp8x/partdoc
commit
226ce8a772
|
|
@ -7,7 +7,7 @@ services:
|
|||
env_file: postgres.env
|
||||
volumes:
|
||||
- ./partdoc/:/app/
|
||||
- ./sketches/:/app/sketches/
|
||||
#- ./sketches/:/app/sketches/
|
||||
working_dir: /app
|
||||
command: python3 ./manage.py runserver 0.0.0.0:8000
|
||||
ports:
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ function addRow(){
|
|||
|
||||
clone.children[0].children[0].value = fignumber;
|
||||
document.getElementById("table").appendChild(clone);
|
||||
var tabables = $("input[tabindex|='-1']", clone);
|
||||
tabables.attr("tabindex", $('#table > tr').length);
|
||||
|
||||
var number = $("input[name|='partnumber']", clone);
|
||||
number.autocomplete({
|
||||
|
|
@ -19,8 +21,27 @@ function addRow(){
|
|||
change: function (event, ui){setPartDesc(number, ui);},
|
||||
delay: 50
|
||||
});
|
||||
|
||||
var fig = $("input[name|='fignumber']", clone);
|
||||
fig.focus(function() {
|
||||
var prev = fig.parent().parent().prev("tr");
|
||||
if (prev.length && parseInt(fig.val())) {
|
||||
var rawnumber = prev[0].children[0].children[0].value;
|
||||
var prevnumber = parseInt(rawnumber.split(" ").pop());
|
||||
if (prevnumber){
|
||||
var fignumber = prevnumber + 1;
|
||||
fig.val(fignumber);
|
||||
console.log(fignumber);
|
||||
}else{
|
||||
console.log("failed to parse int: " + rawnumber);
|
||||
}
|
||||
}else{
|
||||
console.log("failed to load prev");
|
||||
}
|
||||
});
|
||||
$("#addRowBtn")[0].innerHTML = $('#table > tr').length;
|
||||
}
|
||||
function setPartDesc(target, option){
|
||||
var part = $("input[name|='name']", event.target.parentNode.parentNode);
|
||||
part.attr("value", option.item.name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,10 @@
|
|||
<h1>add sketch to {{ product.name }}</h1>
|
||||
<form action="{{ form_action }}" method="post">
|
||||
{% csrf_token %}
|
||||
<button type="submit" disabled style="display: none" aria-hidden="true"></button>
|
||||
<input type="submit"/>
|
||||
<p><label for="sketch_name">Name:</label><input type="text" name="sketch_name" value="{{ sketch.name }}"/></p>
|
||||
<button type="button" onclick="addRow()">add row</button>
|
||||
<button type="button" onclick="addRow()" id="addRowBtn" >add row</button>
|
||||
<table id="table">
|
||||
<tr>
|
||||
<th>Bild-Nr.</th>
|
||||
|
|
@ -50,15 +51,15 @@
|
|||
</form>
|
||||
<table style="display:none;">
|
||||
<tr id="template">
|
||||
<td><input type="text" size="8" name="fignumber"/></td>
|
||||
<td><input type="text" size="13" name="partnumber"/></td>
|
||||
<td><input type="text" size="8" name="fignumber" tabindex="-1"/></td>
|
||||
<td><input type="text" size="13" name="partnumber" tabindex="-1"/></td>
|
||||
<td><input type="text" size="1" name="internal"/></td>
|
||||
<td><input type="text" size="32" name="name"/></td>
|
||||
<td><input type="number" size="4" name="quantity"/></td>
|
||||
<td><input type="text" size="32" name="name" tabindex="-1"/></td>
|
||||
<td><input type="number" size="4" name="quantity" tabindex="-1"/></td>
|
||||
<td><input type="text" size="16" name="last_version"/></td>
|
||||
<td><input type="text" size="16" name="first_version"/></td>
|
||||
<td><input type="text" size="13" name="replaced_by"/></td>
|
||||
<td><input type="text" size="16" name="notes"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<script type="text/javascript">addRow();</script>
|
||||
<script type="text/javascript">addRow();</script>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
<h1>parts</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Teil-Nr.</th>
|
||||
<th>Teilbezeichnung</th>
|
||||
{% for product in products %}
|
||||
<th>{{product.name}}</th>
|
||||
{% endfor %}
|
||||
<th>Summe</th>
|
||||
</tr>
|
||||
|
||||
{% for part in quantities %}
|
||||
<tr>
|
||||
<td>{{part.number}}</td>
|
||||
<td>{{part.name}}</td>
|
||||
{% for product in part.quantities %}
|
||||
<td>{{product}}</td>
|
||||
{% endfor %}
|
||||
<td>{{part.sum}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
<tr>
|
||||
<td>Summe:</td>
|
||||
<td>{{len}}</td>
|
||||
<td>Teile</td>
|
||||
</table>
|
||||
|
|
@ -7,6 +7,7 @@ urlpatterns = [
|
|||
path('', views.index, name="index"),
|
||||
path('product/<int:product_id>/', views.product, name="detail"),
|
||||
path('sketch/<int:sketch_id>/', views.sketch, name="sketch"),
|
||||
path('parts', views.parts, name="parts"),
|
||||
path('add/<int:product_id>/sketch/<int:sketch_id>', views.sketch_add, name="continue_sketch"),
|
||||
path('add/<int:product_id>/sketch', views.sketch_add, name="new_sketch"),
|
||||
path('search/part/', views.part_search, name="part_search"),
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from django.shortcuts import get_object_or_404, render
|
|||
from django.http import HttpResponseRedirect, HttpResponse
|
||||
from django.urls import reverse
|
||||
from django.db import transaction
|
||||
from django.db.models import Sum
|
||||
|
||||
from .models import *
|
||||
|
||||
|
|
@ -28,6 +29,32 @@ def sketch(request, sketch_id):
|
|||
return render(request, 'parts/sketch.html', context)
|
||||
|
||||
|
||||
def parts(request):
|
||||
products = Product.objects.order_by('name')
|
||||
parts = BrandedPart.objects.order_by('number')
|
||||
quantities = []
|
||||
for part in parts: # FIXME!
|
||||
qtys = part.usage_set.values('productusage__product__name').annotate(Sum('productusage__quantity')).order_by('productusage__product__name')
|
||||
#prod_qtys = {}
|
||||
prod_qtys = []
|
||||
for obj in qtys:
|
||||
# FIXME: make sure there are n(==products) entries
|
||||
#prod_qtys['productusage__product__name'] = obj['productusage__quantity__sum']
|
||||
qty = obj['productusage__quantity__sum']
|
||||
if not qty:
|
||||
qty = 0
|
||||
prod_qtys.append(qty)
|
||||
quantities.append({
|
||||
"name": part.get_name(),
|
||||
"number": part.number,
|
||||
"quantities": prod_qtys,
|
||||
"sum": sum(prod_qtys),
|
||||
})
|
||||
|
||||
context = {'products': products, 'parts': parts, 'quantities': quantities, 'len': len(quantities)}
|
||||
return render(request, 'parts/parts.html', context)
|
||||
|
||||
|
||||
def part_search(request):
|
||||
if "term" in request.GET:
|
||||
term = request.GET.get("term", '')
|
||||
|
|
|
|||
Loading…
Reference in New Issue