diff --git a/case_law/templates/browser.html b/case_law/templates/browser.html index 4365214..6a237fd 100644 --- a/case_law/templates/browser.html +++ b/case_law/templates/browser.html @@ -15,13 +15,13 @@
{% for header in allHeaders %} -
- +
+
{% endfor %}
- +
@@ -42,16 +42,24 @@ {% endfor %} {% endif %} + {% if filter %} +
+ Filters: + {% for item in filter %} + {{ item }} + {% endfor %} + × Clear Filters +
+ {% endif %}
- {% if headersCount > 1 %} + {% if headersCount > 1 and decisionsCount > 1 and not filter %}

Headings


{% for header in headers %}
- -

{{ header }}

+

{{ header }}

{% endfor %} @@ -62,8 +70,7 @@ {% for decision in decisions %}
- -

{{ decision.synopsis }}

+

{{ decision.synopsis }}

{% endfor %} @@ -76,4 +83,16 @@ {% if headersCount %}{{ headersCount }} Headers, {% endif %}{{ decisionsCount }} Decision{% if decisionsCount > 1 %}s{% endif %}
+ + {% endblock %} diff --git a/case_law/views.py b/case_law/views.py index 46348c4..f382e01 100644 --- a/case_law/views.py +++ b/case_law/views.py @@ -4,31 +4,32 @@ from .models import Decision, Subtitle def browser(request): + headers = {} + path = request.GET.get('path') filter = request.GET.get('filter') decisions = Decision.objects.all() if filter: - headers = {} filter = filter.split('/') - ids = Subtitle.objects.filter(name__in=filter) + print(filter) + ids = Subtitle.objects.filter(name__in=filter).values_list('id') + for id in ids: + decisions = decisions.filter(headers__in=id) + elif path: + path = path.split('/') + ids = Subtitle.objects.filter(name__in=path).values_list('id') for id in ids: decisions = decisions.filter(headers__in=id) - else: - path = request.GET.get('path') - if path: - path = path.split('/') - ids = Subtitle.objects.filter(name__in=path).values_list('id') - for id in ids: - decisions = decisions.filter(headers__in=id) - headers = set() - for decision in decisions: - headers = headers.union(decision.headers.all().values_list('name', flat=True)) - if path: headers = headers.difference(path) + headers = set() + for decision in decisions: + headers = headers.union(decision.headers.all().values_list('name', flat=True)) + if path: headers = headers.difference(path) return render(request, 'browser.html', { 'allHeaders': Subtitle.objects.all().order_by('name'), 'decisions': decisions.order_by('synopsis'), 'decisionsCount': len(decisions), + 'filter': filter, 'headers': sorted(headers), 'headersCount': len(headers), 'url': request.GET.get('path'),