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_ROOT = 'static/'
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = '/app/media/'
|
||||
|
||||
DATA_UPLOAD_MAX_NUMBER_FIELDS = 10000
|
||||
|
||||
LOGGING = {
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ from django.conf.urls.static import static
|
|||
urlpatterns = [
|
||||
url(r'^parts/', include('parts.urls'), name="parts"),
|
||||
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):
|
||||
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):
|
||||
product = models.ForeignKey(Product, on_delete=models.CASCADE)
|
||||
name = models.CharField(max_length=256)
|
||||
|
|
@ -54,9 +30,6 @@ class Version(PartModel):
|
|||
start = 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):
|
||||
return "Version: " + self.name + " (" + str(self.product) + ")"
|
||||
|
||||
|
|
@ -78,6 +51,33 @@ class Version(PartModel):
|
|||
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):
|
||||
name = models.CharField(max_length=256, db_index=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@
|
|||
{% endfor %}
|
||||
|
||||
<tr>
|
||||
<td>Summe:</td>
|
||||
<td>Summe Teile:</td>
|
||||
<td>{{len}}</td>
|
||||
{% for product in product_sums %}
|
||||
<td>{{product}}</td>
|
||||
{% endfor %}
|
||||
<td>Teile</td>
|
||||
<td>{{total_sum}}</td>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<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>
|
||||
<ul>
|
||||
{% for usage in sketch.usage_set.all %}
|
||||
|
|
|
|||
|
|
@ -64,12 +64,14 @@ def parts(request):
|
|||
"id": part.id,
|
||||
})
|
||||
|
||||
product_sum = [product_sums[prod.name] for prod in products]
|
||||
context = {
|
||||
'products': products,
|
||||
'parts': parts,
|
||||
'quantities': 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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue