From 0f91728ac248972222b9a86eea55e43564093682 Mon Sep 17 00:00:00 2001 From: Zak Timson Date: Tue, 5 Sep 2017 19:29:42 -0400 Subject: [PATCH] Added case law browser --- OACPL/urls.py | 3 ++ case_law/templates/browser.html | 79 +++++++++++++++++++++++++++++++++ case_law/views.py | 39 +++++++++++++++- static/main/css/index.css | 8 ++++ templates/base.html | 2 +- 5 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 case_law/templates/browser.html diff --git a/OACPL/urls.py b/OACPL/urls.py index b15c0d9..4d71a4f 100644 --- a/OACPL/urls.py +++ b/OACPL/urls.py @@ -7,6 +7,7 @@ from django.contrib.auth.decorators import login_required from django.views.static import serve import main.views +import case_law.views import charter_members.views import newsletters.views @@ -21,6 +22,8 @@ urlpatterns = [ url(r'^admin/logout', main.views.logout, name='logout'), url(r'^admin/', admin.site.urls, name='admin'), url(r'^attorney/(?P\d+)', charter_members.views.index, name='attorney'), + url(r'^caselaw/(?P\d+)', case_law.views.case, name='case'), + url(r'^caselaw/', case_law.views.browser, name='browser'), url(r'^media/secure/(?P.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'), url(r'^media/(?P.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media'), url(r'^newsletter/subscribe', newsletters.views.subscribe, name='subscribe'), diff --git a/case_law/templates/browser.html b/case_law/templates/browser.html new file mode 100644 index 0000000..4365214 --- /dev/null +++ b/case_law/templates/browser.html @@ -0,0 +1,79 @@ +{% extends 'base.html' %} +{% load static %} + +{% block body %} + +
+
+
+ {% for header in allHeaders %} +
+ + +
+ {% endfor %} +
+ +
+
+
+
+
+
+ {% if url %} + + {% endif %} +
+
+ {% if headersCount > 1 %} +

Headings

+
+ {% for header in headers %} + + {% endfor %} +
+ {% endif %} +

Decisions

+
+ {% for decision in decisions %} + + {% endfor %} +
+
+
+
+
+
+ {% 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 91ea44a..46348c4 100644 --- a/case_law/views.py +++ b/case_law/views.py @@ -1,3 +1,40 @@ from django.shortcuts import render -# Create your views here. +from .models import Decision, Subtitle + + +def browser(request): + filter = request.GET.get('filter') + decisions = Decision.objects.all() + if filter: + headers = {} + filter = filter.split('/') + ids = Subtitle.objects.filter(name__in=filter) + 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) + + return render(request, 'browser.html', { + 'allHeaders': Subtitle.objects.all().order_by('name'), + 'decisions': decisions.order_by('synopsis'), + 'decisionsCount': len(decisions), + 'headers': sorted(headers), + 'headersCount': len(headers), + 'url': request.GET.get('path'), + 'urls': path + }) + + +def case(request, id): + return render(request) diff --git a/static/main/css/index.css b/static/main/css/index.css index a902bb7..653be85 100644 --- a/static/main/css/index.css +++ b/static/main/css/index.css @@ -73,3 +73,11 @@ ul { .btn { cursor: pointer; } + +.curs-pointer { + cursor: pointer; +} + +.breadcrumb { + border-radius: 0 !important; +} diff --git a/templates/base.html b/templates/base.html index f2a535a..2110595 100644 --- a/templates/base.html +++ b/templates/base.html @@ -47,7 +47,7 @@ FORUM {% if request.user.is_staff %}