From b4dcbb02d448a2ffd5c9bda69676e4a6cba8e540 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20=20MENAGER?= <herve.menager@pasteur.fr>
Date: Wed, 16 May 2018 16:12:55 +0200
Subject: [PATCH] set steps for compounds list filter as requested by @osperand

closes #59


Former-commit-id: 6b6ad6df387da8a10932c6de58bd40aa6db7fb2d
---
 ippisite/ippidb/templates/compound_list.html | 4 ++--
 ippisite/ippidb/views.py                     | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/ippisite/ippidb/templates/compound_list.html b/ippisite/ippidb/templates/compound_list.html
index c81ec2af..103350e6 100644
--- a/ippisite/ippidb/templates/compound_list.html
+++ b/ippisite/ippidb/templates/compound_list.html
@@ -146,8 +146,8 @@
   {% include "multiselection_modal.html" with label="Disease" selected_list=selected_diseases unselected_list=diseases param_name="disease" all_param_name="diseases_all" all_param_value=diseases_all %}
   {% include "multiselection_modal.html" with label="Organism" selected_list=selected_taxonomies unselected_list=taxonomies param_name="taxonomy" all_param_name="taxonomies_all" all_param_value=taxonomies_all %}
   {% include "multiselection_modal.html" with label="Bound complex" selected_list=selected_boundcomplexes unselected_list=boundcomplexes param_name="boundcomplex" all_param_name="boundcomplexes_all" all_param_value=boundcomplexes_all %}
-  {% include "slider_modal.html" with label="Molecular Weight" param_name="molecular_weight" param_min=molecular_weight_min param_max=molecular_weight_max param_value=molecular_weight step='0.01' param_label='Select a cutoff value for the molecular weight of the compounds to be selected'%}
-  {% include "slider_modal.html" with label="AlogP" param_name="a_log_p" param_min=a_log_p_min param_max=a_log_p_max param_value=a_log_p step='0.01' param_label='Select a cutoff value for the AlogP of the compounds to be selected'%}
+  {% include "slider_modal.html" with label="Molecular Weight" param_name="molecular_weight" param_min=molecular_weight_min param_max=molecular_weight_max param_value=molecular_weight step='50' param_label='Select a cutoff value for the molecular weight of the compounds to be selected'%}
+  {% include "slider_modal.html" with label="AlogP" param_name="a_log_p" param_min=a_log_p_min param_max=a_log_p_max param_value=a_log_p step='1' param_label='Select a cutoff value for the AlogP of the compounds to be selected'%}
   {% include "slider_modal.html" with label="H donors" param_name="nb_donor_h" param_min=nb_donor_h_min param_max=nb_donor_h_max param_value=nb_donor_h step='1' param_label='Select a cutoff value for the number of H donors in the compounds to be selected'%}
 
 {% endblock %}
diff --git a/ippisite/ippidb/views.py b/ippisite/ippidb/views.py
index 703c850b..d152175e 100644
--- a/ippisite/ippidb/views.py
+++ b/ippisite/ippidb/views.py
@@ -1,4 +1,5 @@
 import json
+import math
 
 from django.db.models import Max, Min
 from django.shortcuts import render
@@ -175,8 +176,8 @@ def biblio_card(request, source, id_source):
                                                 'tad_ppis': tad_ppis}) 
 
 def process_cutoff_value(name, context, request):
-    context[name+'_max'] = str(Compound.objects.all().aggregate(Max(name))[name + '__max']) #.to_eng_string()
-    context[name+'_min'] = str(Compound.objects.all().aggregate(Min(name))[name + '__min']) #.to_eng_string()
+    context[name+'_max'] = str(int(math.ceil(float(Compound.objects.all().aggregate(Max(name))[name + '__max']))))
+    context[name+'_min'] = str(int(math.floor(float(Compound.objects.all().aggregate(Min(name))[name + '__min']))))
     if request.GET.get(name):
         context[name] = request.GET.get(name)
         filter_dict = {name + '__lte': context[name]}
-- 
GitLab