Commit 066d1d85 authored by Okhin's avatar Okhin

Soem work done on the ListViews #22

parent 33b7d8ce
......@@ -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,7 +241,7 @@ class ViolationsList(ListView):
if 'country' in self.kwargs:
context['country'] = self.kwargs['country']
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)
......
......@@ -122,5 +122,4 @@
{% endfor %}
</tbody>
</table>
</div>
{%endblock%}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment