diff --git a/ippisite/ippidb/templates/compound_list.html b/ippisite/ippidb/templates/compound_list.html index 92cec141dc5deee1bc98f556dad7eae55839c60a..51d88c8b3fe796bea97048c0fb70cd5f73df14af 100644 --- a/ippisite/ippidb/templates/compound_list.html +++ b/ippisite/ippidb/templates/compound_list.html @@ -12,6 +12,14 @@ <form> <fieldset class="form-group row border border-info m-2"> <div class="bg-info col-12"><legend>PPI</legend></div> + {% for ppi in selected_ppis|slice:":5" %} + <div class="form-check col-12"> + <label class="form-check-label"> + <input class="form-check-input text-right" type="checkbox" checked value="{{ ppi.id }}" onchange="this.form.submit()" name="ppi" style="width: auto; margin-right: inherit!;"> + {{ ppi.name }} + </label> + </div> + {% endfor %} {% for ppi in ppis|slice:":5" %} <div class="form-check col-12"> <label class="form-check-label"> diff --git a/ippisite/ippidb/views.py b/ippisite/ippidb/views.py index bc416a80a5d21f24cb3eff70ff9aabcd89443598..1a088a281164d11ab1509cab33a3b5239fead227 100644 --- a/ippisite/ippidb/views.py +++ b/ippisite/ippidb/views.py @@ -182,9 +182,17 @@ def biblio_card(request, source, id_source): 'tad_ppis': tad_ppis}) def compound_list(request): + """ + Display the list of compounds + """ compounds = Compound.objects.all() + # if filtering on "action on PPI" + if request.GET.get('ppi'): + compounds = compounds.filter(compoundaction__ppi__id__in=request.GET.getlist('ppi')) + selected_ppis = Ppi.objects.filter(id__in=request.GET.getlist('ppi')) + ppis = Ppi.objects.exclude(id__in=request.GET.getlist('ppi')) + # handle pagination in compounds list paginator = Paginator(compounds, 5) - ppis = Ppi.objects.all() page = request.GET.get('page') try: compounds = paginator.page(page) @@ -194,4 +202,4 @@ def compound_list(request): except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. compounds = paginator.page(paginator.num_pages) - return render(request, 'compound_list.html', {'compounds': compounds, 'ppis': ppis}) + return render(request, 'compound_list.html', {'compounds': compounds, 'selected_ppis': selected_ppis, 'ppis': ppis})