Added case law browser

This commit is contained in:
Zak Timson 2017-09-05 19:29:42 -04:00
parent 3948cb65b4
commit 0f91728ac2
5 changed files with 129 additions and 2 deletions

View File

@ -7,6 +7,7 @@ from django.contrib.auth.decorators import login_required
from django.views.static import serve from django.views.static import serve
import main.views import main.views
import case_law.views
import charter_members.views import charter_members.views
import newsletters.views import newsletters.views
@ -21,6 +22,8 @@ urlpatterns = [
url(r'^admin/logout', main.views.logout, name='logout'), url(r'^admin/logout', main.views.logout, name='logout'),
url(r'^admin/', admin.site.urls, name='admin'), url(r'^admin/', admin.site.urls, name='admin'),
url(r'^attorney/(?P<id>\d+)', charter_members.views.index, name='attorney'), url(r'^attorney/(?P<id>\d+)', charter_members.views.index, name='attorney'),
url(r'^caselaw/(?P<id>\d+)', case_law.views.case, name='case'),
url(r'^caselaw/', case_law.views.browser, name='browser'),
url(r'^media/secure/(?P<path>.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'), url(r'^media/secure/(?P<path>.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'),
url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media'), url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media'),
url(r'^newsletter/subscribe', newsletters.views.subscribe, name='subscribe'), url(r'^newsletter/subscribe', newsletters.views.subscribe, name='subscribe'),

View File

@ -0,0 +1,79 @@
{% extends 'base.html' %}
{% load static %}
{% block body %}
<div class="container-fluid bg-dark-primary p-3">
<div class="container">
<a class="text-white text-center d-block mx-auto curs-pointer" data-toggle="collapse" data-target="#search-filters" aria-expanded="false" aria-controls="search-filters">
Search
<br>
<img class="mx-auto" src="{% static 'main/img/arrow.png' %}">
</a>
</div>
</div>
<div id="search-filters" class="container-fluid bg-dark-primary text-white collapse">
<div class="container">
<div class="row py-3">
{% for header in allHeaders %}
<div class="col-4">
<input id="input-{{ header.id }}" class="curs-pointer" type="checkbox">
<label for="input-{{ header.id }}" class="curs-pointer">{{ header }}</label>
</div>
{% endfor %}
<div class="col-12">
<button class="btn btn-secondary d-block mx-auto"><i class="fa fa-search"></i> Search</button>
</div>
</div>
</div>
</div>
<div class="container-fluid bg-light-blue">
<div class="container bg-white p-0">
{% if url %}
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'browser' %}"><i class="fa fa-home"></i></a>
</li>
{% for item in urls %}
<li class="breadcrumb-item{% if forloop.last %} active{% endif %}">
<a {% if not forloop.last %}href="{% url 'browser' %}?path={% for item2 in urls %}{% if forloop.counter0 <= forloop.parentloop.counter0%}{{ item }}{% endif %}{% endfor %}"{% endif %}>
{{ item }}
</a>
</li>
{% endfor %}
</ol>
{% endif %}
<div class="row p-3">
<div class="col-lg-12 ml-auto text-dark-primary">
{% if headersCount > 1 %}
<h4>Headings</h4>
<hr>
{% for header in headers %}
<div>
<a href="{% url 'browser' %}?path={% if url %}{{ url }}/{% endif %}{{ header }}">
<i class="fa fa-folder-open-o fa-2x"></i>
<h4 class="d-inline-block"> {{ header }}</h4>
</a>
</div>
{% endfor %}
<br>
{% endif %}
<h4>Decisions</h4>
<hr>
{% for decision in decisions %}
<div>
<a href="{% url 'case' decision.id %}">
<i class="fa fa-file-text-o fa-2x"></i>
<h4 class="d-inline-block"> {{ decision.synopsis }}</h4>
</a>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
<div class="container-fluid bg-dark-primary p-2">
<div class="container text-white">
{% if headersCount %}{{ headersCount }} Headers, {% endif %}{{ decisionsCount }} Decision{% if decisionsCount > 1 %}s{% endif %}
</div>
</div>
{% endblock %}

View File

@ -1,3 +1,40 @@
from django.shortcuts import render 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)

View File

@ -73,3 +73,11 @@ ul {
.btn { .btn {
cursor: pointer; cursor: pointer;
} }
.curs-pointer {
cursor: pointer;
}
.breadcrumb {
border-radius: 0 !important;
}

View File

@ -47,7 +47,7 @@
<a class="nav-link" href="#">FORUM</a> <a class="nav-link" href="#">FORUM</a>
</li> </li>
<li class="nav-item text-dark-primary"> <li class="nav-item text-dark-primary">
<a class="nav-link" href="#">CASE LAW</a> <a class="nav-link" href="{% url 'browser' %}">CASE LAW</a>
</li> </li>
{% if request.user.is_staff %} {% if request.user.is_staff %}
<li class="nav-item text-dark-primary"> <li class="nav-item text-dark-primary">