diff --git a/bt/views.py b/bt/views.py index 8df7f1239f579c837006ffda3362d021dcd5cf45..c56628ab2b16e47ec99b336fe95b3c9e4ff7edae 100644 --- a/bt/views.py +++ b/bt/views.py @@ -221,12 +221,19 @@ class ViolationsList(ListView): def get_queryset(self): queryset = Violation.objects.filter(activationid='') - if 'all' not in self.request.GET: - queryset = queryset.exclude(state__in=['duplicate', 'closed']) - if 'country' in self.kwargs: - queryset = queryset.filter(country=self.kwargs['country']) if 'operator' in self.kwargs: - queryset = queryset.filter(operator_ref__name=self.kwargs['operator']) + # If i Have operator I have a country + queryset = Violation.objects.filter(activationid='', + country=self.kwargs['country'], + operator_ref__name=self.kwargs['operator']) + elif 'country' in self.kwargs: + queryset = Violation.objects.filter(activationid='', + country=self.kwargs['country']) + if not queryset.count(): + queryset = queryset.filter(activationid='', + operator_ref__name=self.kwargs['country']) + if 'all' not in self.request.GET: + queryset = queryset.objects.filter(activationid='').exclude(state__in=['duplicate', 'closed']) return queryset def get_context_data(self, **kwargs): @@ -234,13 +241,13 @@ class ViolationsList(ListView): if 'country' in self.kwargs: context['country'] = self.kwargs['country'] - - countries = sorted([(i['total'], i['country']) - 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]) - context['countries'] = countries - context['countryweights'] = countryweights + else: + countries = sorted([(i['total'], i['country']) + 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]) + context['countries'] = countries + context['countryweights'] = countryweights return context class ViolationView(DetailView): diff --git a/nnmon/templates/list.html b/nnmon/templates/list.html index a71f5eefda319e88aeec907f2689f5ec18e32520..dc854badbe2d93a8a6b0958bf6c7a44c9f3f8e24 100644 --- a/nnmon/templates/list.html +++ b/nnmon/templates/list.html @@ -122,5 +122,4 @@ {% endfor %} - {%endblock%}