fix media setup to deliver content

master
agp8x 2019-12-08 12:20:30 +01:00
parent 1d91c5da38
commit eea3d117bc
7 changed files with 13 additions and 6 deletions

1
partdoc/media/sketches/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*

View File

@ -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 = {

View File

@ -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)

View File

@ -34,7 +34,7 @@ class Sketch(PartModel):
image = models.FileField(upload_to="sketches/", blank=True, null=True) image = models.FileField(upload_to="sketches/", blank=True, null=True)
def __str__(self): def __str__(self):
return "Sketch: " + self.name + " (" + str(self.brand) + ")" return "Sketch: " + self.name + " (" + str(self.product) + ")"
def get_product(self): def get_product(self):
if self.product: if self.product:

View File

@ -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>

View File

@ -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 %}

View File

@ -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)