]> git.0d.be Git - django-panik-nonstop.git/commitdiff
display french quota during settings
authorFrédéric Péters <fpeters@0d.be>
Mon, 10 Aug 2020 16:56:16 +0000 (18:56 +0200)
committerFrédéric Péters <fpeters@0d.be>
Mon, 10 Aug 2020 16:56:16 +0000 (18:56 +0200)
nonstop/templates/nonstop/zone_settings.html
nonstop/views.py

index e55cbcbbd8e997c9eab9a99e0c33346bbc49accf..8bf7d4f43c33afe74ea71f4eccacaac60fcd3ee2 100644 (file)
@@ -25,6 +25,8 @@
 <script>
 $(function() {
   var xhr = null;
+  var $french_quota = $('<span id="computed-french-quota"></span>');
+  $french_quota.insertAfter($('#computed-percent-weight_lang_fr'));
   $('[type=range]').on('change', function() {
     var params = $('[type=range]').serialize();
     if (xhr !== null ) xhr.abort();
@@ -34,6 +36,7 @@ $(function() {
       success: function(data, status, xhr) {
         for (var key of Object.keys(data)) {
            $('#computed-percent-weight_' + key).text((parseInt(data[key] * 100)) + '%');
+           $french_quota.text(' (' + parseInt(data['french_quota'] * 100) + '% hors instru)');
         }
       }
     });
index fc3ceea793d8ba2df0e61aae4a6b1f5e77a052b4..3a733c1320ad1a3d951257eb1a83652965550754 100644 (file)
@@ -680,4 +680,7 @@ class ZoneTracklistPercents(DetailView):
         for weight in weights:
             data[weight] = counts[weight] / 1000
 
+        # second percentage for French tracks quota
+        data['french_quota'] = counts['lang_fr'] / (1000 - counts['instru'])
+
         return JsonResponse(data)