From dccf375b6d00e9843ab77b3465ec61e3c163911e Mon Sep 17 00:00:00 2001 From: Okhin Date: Mon, 15 Feb 2016 13:37:49 +0100 Subject: [PATCH] Nice colour for the map, and removing unnecessary code in bt/views.py, fix #21 --- bt/views.py | 11 +---------- nnmon/media/js/map.js | 8 +------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/bt/views.py b/bt/views.py index 8c544f4..9503920 100644 --- a/bt/views.py +++ b/bt/views.py @@ -234,13 +234,9 @@ def filter_violations(request, country, operator=None): violations = Violation.objects.filter(activationid='', country=country, operator_ref__name=operator) if not request.GET.get('all'): violations = violations.exclude(state__in=['duplicate', 'closed']) - countries=sorted([(i['total'],i['country']) - for i in Violation.objects.values('country').filter(activationid='',country=country).exclude(state__in=['duplicate', 'closed']).annotate(total=Count('country'))], - reverse=True) - countryweights=json.dumps([{'iso2': y, 'w': x} for x, y in countries]) return render_to_response('list.html', { "violations": violations, - "country": country, + "country": country, "status": STATUS }, context_instance=RequestContext(request)) @@ -252,11 +248,6 @@ def list_violations(request): for i in Violation.objects.values('country').filter(activationid='').exclude(state__in=['duplicate', 'closed']).annotate(total=Count('country'))], reverse=True) countryweights=json.dumps([{'iso2': y, 'w': x} for x, y in countries]) - #countrycolors=json.dumps(dict([(c.lower(),"#ff%02x00" % (w*768/(countries[0][0]+1)%256)) for w,c in countries])) - #confirms=sorted([(i['total'],i['country']) - # for i in Violation.objects.values('country').filter(activationid='').annotate(total=Count('confirmation')) - # if i['total']>1], - # reverse=True) return render_to_response('list.html', {"violations": violations, "countries": dict([(y,x) for x,y in countries]), diff --git a/nnmon/media/js/map.js b/nnmon/media/js/map.js index aebab15..96f8941 100644 --- a/nnmon/media/js/map.js +++ b/nnmon/media/js/map.js @@ -17,13 +17,7 @@ $(document).ready(function() { dataset[iso] = { numberOfCases: value, fillColor: paletteScale(value)}; }); - /* We want to highlight a country if we've selected one */ - var url_segments = window.location.pathname.split('/'); - url_segments.pop(); //This one is empty - var country = url_segments.pop(), - page = url_segments.pop(); - - if (page === 'list') { + if (country) { dataset[country] = {fillColor: '#02386F'}; } -- GitLab