Updated case law browser
This commit is contained in:
parent
0f484d1d0b
commit
607857457b
@ -25,7 +25,6 @@ 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'^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'),
|
||||||
|
@ -2,93 +2,106 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="container-fluid bg-dark-primary p-3">
|
<style>
|
||||||
<div class="container">
|
.gradient {
|
||||||
<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">
|
top: 0;
|
||||||
Search
|
transition: all 0.15s ease-in;
|
||||||
<br>
|
opacity: 1;
|
||||||
<img class="mx-auto" src="{% static 'main/img/arrow.png' %}">
|
background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.7) 60%, rgba(255, 255, 255, 1) 100%);
|
||||||
</a>
|
position: absolute;
|
||||||
</div>
|
height: 100%;
|
||||||
</div>
|
width: 100%;
|
||||||
<div id="search-filters" class="container-fluid bg-dark-primary text-white collapse">
|
display: table-cell;
|
||||||
<div class="container">
|
vertical-align: bottom;
|
||||||
<div class="row py-3">
|
}
|
||||||
{% for heading in allHeadings %}
|
|
||||||
<div class="col-xs-12 col-sm-6 col-md-4">
|
.tc {
|
||||||
<input id="input-{{ heading.id }}" class="curs-pointer filters" name="filter" type="checkbox" value="{{ heading }}">
|
display: table-cell;
|
||||||
<label for="input-{{ heading.id }}" class="curs-pointer">{{ heading }}</label>
|
}
|
||||||
</div>
|
|
||||||
{% endfor %}
|
a.cases:hover {
|
||||||
<div class="col-12">
|
text-decoration: none;
|
||||||
<button id="search" class="btn btn-secondary d-block mx-auto"><i class="fa fa-search"></i> Search</button>
|
}
|
||||||
</div>
|
|
||||||
</div>
|
a.cases:hover .gradient {
|
||||||
</div>
|
opacity: 0;
|
||||||
</div>
|
}
|
||||||
<div class="container-fluid bg-light-blue">
|
</style>
|
||||||
<div class="container bg-white p-0">
|
<div class="container-fluid bg-dark-primary">
|
||||||
{% if url %}
|
<div class="row">
|
||||||
<ol class="breadcrumb">
|
<ol class="col-12 mb-0 breadcrumb">
|
||||||
<li class="breadcrumb-item">
|
<li class="breadcrumb-item">
|
||||||
<a href="{% url 'browser' %}"><i class="fa fa-home"></i></a>
|
<a href="{% url 'home' %}"><i class="fa fa-home"></i></a>
|
||||||
|
</li>
|
||||||
|
<li class="breadcrumb-item">
|
||||||
|
<a href="{% url 'browser' %}">Case Law</a>
|
||||||
</li>
|
</li>
|
||||||
{% for item in urls %}
|
{% for item in urls %}
|
||||||
<li class="breadcrumb-item{% if forloop.last %} active{% endif %}">
|
<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 %}>
|
<a {% if not forloop.last %}href="{% url 'browser' %}?path=
|
||||||
|
|
||||||
|
{% for item2 in urls %}{% if forloop.counter0 <= forloop.parentloop.counter0 %}{{ item }}{% endif %}{% endfor %}"{% endif %}>
|
||||||
{{ item }}
|
{{ item }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</ol>
|
||||||
|
<div class="col-md-3 text-white pt-5">
|
||||||
|
<h4>Headings
|
||||||
|
{% if headingCount > 1 and caseCount > 1 and not filter %}
|
||||||
|
<span class="text-muted">({{ headingCount }})</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if filter %}
|
</h4>
|
||||||
<div class="col-12 p-3" style="background-color: #e9ecef;">
|
<hr style="border-color:#ffffff !important">
|
||||||
Filters:
|
{% if headingCount > 1 and caseCount > 1 and not filter %}
|
||||||
{% for item in filter %}
|
|
||||||
<span class="badge badge-primary">{{ item }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
<span class="badge badge-danger"><a class="text-white" href="{% url 'browser' %}">× Clear Filters</a></span>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<div class="row p-3">
|
|
||||||
<div class="col-lg-12 ml-auto text-dark-primary">
|
|
||||||
{% if headingCount > 1 and headingCount > 1 and not filter %}
|
|
||||||
<h4>Headings</h4>
|
|
||||||
<hr>
|
|
||||||
{% for heading in headings %}
|
{% for heading in headings %}
|
||||||
<div>
|
<div>
|
||||||
<a href="{% url 'browser' %}?path={% if url %}{{ url }}/{% endif %}{{ heading }}">
|
<a href="{% url 'browser' %}?path={% if url %}{{ url }}/{% endif %}{{ heading }}">
|
||||||
<h4 class="d-inline-block"><i class="fa fa-folder-open-o"></i> {{ heading }}</h4>
|
<h4 class="d-inline-block" style="color:#D8D8D8"><i
|
||||||
|
class="fa fa-folder-open-o"></i> {{ heading }}
|
||||||
|
</h4>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<br>
|
<br>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<h4>Cases</h4>
|
|
||||||
<hr>
|
|
||||||
{% for case in cases %}
|
|
||||||
<div>
|
|
||||||
<a href="{% url 'case' case.id %}">
|
|
||||||
<h4 class="d-inline-block"><i class="fa fa-file-text-o"></i> {{ case.synopsis }}</h4>
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="{% if not filter %}col-md-9{% else %}col-12{% endif %} bg-light-blue pt-5">
|
||||||
|
<h4>Cases <span class="text-muted">({{ caseCount }})</span></h4>
|
||||||
|
<hr>
|
||||||
|
<div class="row">
|
||||||
|
{% for case in cases %}
|
||||||
|
<a class="col-md-4 col-lg-3 mb-3 cases" target="_blank"
|
||||||
|
{% if perms.case_law.view_pdf %}href="/media/{{ case.pdf }}"{% endif %}>
|
||||||
|
<div class="card" style="overflow:hidden;">
|
||||||
|
<div class="tc">
|
||||||
|
<div class="card-header">
|
||||||
|
<span class="text-muted">{{ case.published }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="card-body" style="position:relative; height:150px; overflow:hidden;">
|
||||||
|
<span class="card-text text-secondary">{{ case.synopsis | linebreaks }}</span>
|
||||||
|
<div class="gradient">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer p-1">
|
||||||
|
{% for heading in case.headings.all|dictsort:'name' %}
|
||||||
|
<span class="badge badge-primary">{{ heading.name }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="container-fluid bg-dark-primary p-2">
|
|
||||||
<div class="container text-white">
|
|
||||||
{% if headingCount %}{{ headingCount }} Headings, {% endif %}{{ caseCount }} Case{% if caseCount > 1 %}s{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$('#search').click(function() {
|
$('#search').click(function () {
|
||||||
var selected = $('input.filters').filter(function(i, e) {
|
var selected = $('input.filters').filter(function (i, e) {
|
||||||
return $(e).is(':checked')
|
return $(e).is(':checked')
|
||||||
}).map(function(i, e) {
|
}).map(function (i, e) {
|
||||||
return $(e).val()
|
return $(e).val()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% load static %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
<div class="container-fluid bg-light-blue py-3">
|
|
||||||
<div class="container">
|
|
||||||
<h3 class="text-dark-primary">Synopsis</h3>
|
|
||||||
{% for heading in headings %}
|
|
||||||
<span class="badge badge-primary">{{ heading }}</span>
|
|
||||||
{% endfor %}
|
|
||||||
<p>{{ case.synopsis | linebreaks }}</p>
|
|
||||||
<h6 class="text-muted">Published: {{ case.published }}</h6>
|
|
||||||
{% if perms.case_law.view_pdf %}
|
|
||||||
<a href="/media/{{ case.pdf }}">View PDF</a>
|
|
||||||
<br>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
@ -4,17 +4,9 @@ from .models import Case, Heading
|
|||||||
|
|
||||||
|
|
||||||
def browser(request):
|
def browser(request):
|
||||||
headings = {}
|
|
||||||
path = request.GET.get('path')
|
path = request.GET.get('path')
|
||||||
filter = request.GET.get('filter')
|
|
||||||
cases = Case.objects.all()
|
cases = Case.objects.all()
|
||||||
if filter:
|
if path:
|
||||||
filter = filter.split('/')
|
|
||||||
print(filter)
|
|
||||||
ids = Heading.objects.filter(name__in=filter).values_list('id')
|
|
||||||
for id in ids:
|
|
||||||
cases = cases.filter(headings__in=id)
|
|
||||||
elif path:
|
|
||||||
path = path.split('/')
|
path = path.split('/')
|
||||||
ids = Heading.objects.filter(name__in=path).values_list('id')
|
ids = Heading.objects.filter(name__in=path).values_list('id')
|
||||||
for id in ids:
|
for id in ids:
|
||||||
@ -22,21 +14,15 @@ def browser(request):
|
|||||||
|
|
||||||
headings = set()
|
headings = set()
|
||||||
for decision in cases:
|
for decision in cases:
|
||||||
headings = headings.union(decision.headings.all().values_list('name', flat=True))
|
headings = headings | set(decision.headings.all().values_list('name', flat=True))
|
||||||
if path: headings = headings.difference(path)
|
if path: headings = headings.difference(path)
|
||||||
|
|
||||||
return render(request, 'browser.html', {
|
return render(request, 'browser.html', {
|
||||||
'allHeadings': Heading.objects.all().order_by('name'),
|
'allHeadings': Heading.objects.all().order_by('name'),
|
||||||
'cases': cases.order_by('synopsis'),
|
'cases': cases.order_by('published'),
|
||||||
'caseCount': len(cases),
|
'caseCount': len(cases),
|
||||||
'filter': filter,
|
|
||||||
'headings': sorted(headings),
|
'headings': sorted(headings),
|
||||||
'headingCount': len(headings),
|
'headingCount': len(headings),
|
||||||
'url': request.GET.get('path'),
|
'url': request.GET.get('path'),
|
||||||
'urls': path
|
'urls': path
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def case(request, id):
|
|
||||||
case = Case.objects.get(id=id)
|
|
||||||
return render(request, 'case.html', {'case': case, 'headings': case.headings.all()})
|
|
||||||
|
@ -62,6 +62,10 @@ ul {
|
|||||||
color: #0F4C85 !important;
|
color: #0F4C85 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-light-blue {
|
||||||
|
color: #eaf4f6;
|
||||||
|
}
|
||||||
|
|
||||||
.bg-dark-primary {
|
.bg-dark-primary {
|
||||||
background-color: #00305b;
|
background-color: #00305b;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user