Compare commits
2 Commits
1d91c5da38
...
f0cf85f3fa
| Author | SHA1 | Date |
|---|---|---|
|
|
f0cf85f3fa | |
|
|
eea3d117bc |
|
|
@ -0,0 +1 @@
|
||||||
|
*
|
||||||
|
|
@ -120,6 +120,9 @@ USE_TZ = True
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
STATIC_ROOT = 'static/'
|
STATIC_ROOT = 'static/'
|
||||||
|
|
||||||
|
MEDIA_URL = '/media/'
|
||||||
|
MEDIA_ROOT = '/app/media/'
|
||||||
|
|
||||||
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000
|
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,4 @@ from django.conf.urls.static import static
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^parts/', include('parts.urls'), name="parts"),
|
url(r'^parts/', include('parts.urls'), name="parts"),
|
||||||
url(r'^admin/', admin.site.urls),
|
url(r'^admin/', admin.site.urls),
|
||||||
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
|
||||||
|
|
@ -23,30 +23,6 @@ class Product(PartModel):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name + " (" + self.brand.name + ")"
|
return self.name + " (" + self.brand.name + ")"
|
||||||
|
|
||||||
|
|
||||||
class Sketch(PartModel):
|
|
||||||
class Meta:
|
|
||||||
verbose_name_plural = "sketches"
|
|
||||||
|
|
||||||
name = models.CharField(max_length=256)
|
|
||||||
brand = models.ForeignKey(Brand, blank=True, null=True, on_delete=models.CASCADE, db_index=True)
|
|
||||||
product = models.ForeignKey(Product, blank=True, null=True, on_delete=models.CASCADE)
|
|
||||||
image = models.FileField(upload_to="sketches/", blank=True, null=True)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return "Sketch: " + self.name + " (" + str(self.brand) + ")"
|
|
||||||
|
|
||||||
def get_product(self):
|
|
||||||
if self.product:
|
|
||||||
return [self.product] + list(self.usage_set.values('productusage__product').distinct())
|
|
||||||
return self.usage_set.values('productusage__product').distinct()
|
|
||||||
|
|
||||||
def get_brand(self):
|
|
||||||
if self.brand:
|
|
||||||
return [self.brand] + list(self.usage_set.values('productusage__product__brand').distinct())
|
|
||||||
return self.usage_set.values('productusage__product__brand').distinct()
|
|
||||||
|
|
||||||
|
|
||||||
class Version(PartModel):
|
class Version(PartModel):
|
||||||
product = models.ForeignKey(Product, on_delete=models.CASCADE)
|
product = models.ForeignKey(Product, on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=256)
|
name = models.CharField(max_length=256)
|
||||||
|
|
@ -54,9 +30,6 @@ class Version(PartModel):
|
||||||
start = models.DateField(blank=True, null=True)
|
start = models.DateField(blank=True, null=True)
|
||||||
end = models.DateField(blank=True, null=True)
|
end = models.DateField(blank=True, null=True)
|
||||||
|
|
||||||
additional_sketch = models.ManyToManyField(Sketch, blank=True, related_name='added')
|
|
||||||
unused_sketch = models.ManyToManyField(Sketch, blank=True, related_name='replaced')
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Version: " + self.name + " (" + str(self.product) + ")"
|
return "Version: " + self.name + " (" + str(self.product) + ")"
|
||||||
|
|
||||||
|
|
@ -78,6 +51,33 @@ class Version(PartModel):
|
||||||
other.delete()
|
other.delete()
|
||||||
|
|
||||||
|
|
||||||
|
class Sketch(PartModel):
|
||||||
|
class Meta:
|
||||||
|
verbose_name_plural = "sketches"
|
||||||
|
|
||||||
|
name = models.CharField(max_length=256)
|
||||||
|
brand = models.ForeignKey(Brand, blank=True, null=True, on_delete=models.CASCADE, db_index=True)
|
||||||
|
product = models.ForeignKey(Product, blank=True, null=True, on_delete=models.CASCADE)
|
||||||
|
image = models.FileField(upload_to="sketches/", blank=True, null=True)
|
||||||
|
used_until = models.ForeignKey(Version, null=True, blank=True, related_name='dismisses_sketch', on_delete=models.SET_NULL)
|
||||||
|
used_since = models.ForeignKey(Version, null=True, blank=True, related_name='introduces_sketch', on_delete=models.SET_NULL)
|
||||||
|
option = models.CharField(max_length=1024, null=True, blank=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Sketch: " + self.name + " (" + str(self.product) + ")"
|
||||||
|
|
||||||
|
def get_product(self):
|
||||||
|
if self.product:
|
||||||
|
return [self.product] + list(self.usage_set.values('productusage__product').distinct())
|
||||||
|
return self.usage_set.values('productusage__product').distinct()
|
||||||
|
|
||||||
|
def get_brand(self):
|
||||||
|
if self.brand:
|
||||||
|
return [self.brand] + list(self.usage_set.values('productusage__product__brand').distinct())
|
||||||
|
return self.usage_set.values('productusage__product__brand').distinct()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Part(PartModel):
|
class Part(PartModel):
|
||||||
name = models.CharField(max_length=256, db_index=True)
|
name = models.CharField(max_length=256, db_index=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,10 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Summe:</td>
|
<td>Summe Teile:</td>
|
||||||
<td>{{len}}</td>
|
<td>{{len}}</td>
|
||||||
{% for product in product_sums %}
|
{% for product in product_sums %}
|
||||||
<td>{{product}}</td>
|
<td>{{product}}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<td>Teile</td>
|
<td>{{total_sum}}</td>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<h1>{{sketch.name}}</h1>
|
<h1>{{sketch.name}}</h1>
|
||||||
|
<a href="{{sketch.image.url}}"><img src="{{sketch.image.url}}" /></a>
|
||||||
<h2>{% for brand in sketch.get_brand %}{{brand.name}},{% endfor%} - {% for product in sketch.get_product %}{{product.name}},{% endfor%}</h2>
|
<h2>{% for brand in sketch.get_brand %}{{brand.name}},{% endfor%} - {% for product in sketch.get_product %}{{product.name}},{% endfor%}</h2>
|
||||||
<ul>
|
<ul>
|
||||||
{% for usage in sketch.usage_set.all %}
|
{% for usage in sketch.usage_set.all %}
|
||||||
|
|
|
||||||
|
|
@ -63,13 +63,15 @@ def parts(request):
|
||||||
"sum": sum(prod_qtys),
|
"sum": sum(prod_qtys),
|
||||||
"id": part.id,
|
"id": part.id,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
product_sum = [product_sums[prod.name] for prod in products]
|
||||||
context = {
|
context = {
|
||||||
'products': products,
|
'products': products,
|
||||||
'parts': parts,
|
'parts': parts,
|
||||||
'quantities': quantities,
|
'quantities': quantities,
|
||||||
'len': len(quantities),
|
'len': len(quantities),
|
||||||
'product_sums': [product_sums[prod.name] for prod in products]
|
'product_sums': product_sum,
|
||||||
|
'total_sum': sum(product_sum),
|
||||||
}
|
}
|
||||||
return render(request, 'parts/parts.html', context)
|
return render(request, 'parts/parts.html', context)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue