Aggregated counts on front page; "Add items" page now saves pictures
All checks were successful
Build containers when image tags change / build-if-image-changed (., web, containers, main container, git.baumann.gr/adebaumann/labhelper) (push) Successful in 14s
Build containers when image tags change / build-if-image-changed (data-loader, loader, initContainers, init-container, git.baumann.gr/adebaumann/labhelper-data-loader) (push) Successful in 4s
All checks were successful
Build containers when image tags change / build-if-image-changed (., web, containers, main container, git.baumann.gr/adebaumann/labhelper) (push) Successful in 14s
Build containers when image tags change / build-if-image-changed (data-loader, loader, initContainers, init-container, git.baumann.gr/adebaumann/labhelper-data-loader) (push) Successful in 4s
This commit is contained in:
@@ -11,9 +11,17 @@ def index(request):
|
||||
"""Home page with boxes and thing types."""
|
||||
boxes = Box.objects.select_related('box_type').all().order_by('id')
|
||||
thing_types = ThingType.objects.all()
|
||||
|
||||
type_counts = {}
|
||||
for thing_type in thing_types:
|
||||
descendants = thing_type.get_descendants(include_self=True)
|
||||
count = Thing.objects.filter(thing_type__in=descendants).count()
|
||||
type_counts[thing_type.pk] = count
|
||||
|
||||
return render(request, 'boxes/index.html', {
|
||||
'boxes': boxes,
|
||||
'thing_types': thing_types,
|
||||
'type_counts': type_counts,
|
||||
})
|
||||
|
||||
|
||||
@@ -90,7 +98,7 @@ def add_things(request, box_id):
|
||||
success_message = None
|
||||
|
||||
if request.method == 'POST':
|
||||
formset = ThingFormSet(request.POST, queryset=Thing.objects.filter(box=box))
|
||||
formset = ThingFormSet(request.POST, request.FILES, queryset=Thing.objects.filter(box=box))
|
||||
|
||||
if formset.is_valid():
|
||||
things = formset.save(commit=False)
|
||||
|
||||
Reference in New Issue
Block a user