Added decision viewer with protected pdf server
This commit is contained in:
parent
2dec223f8b
commit
cc8f5750a8
@ -1,9 +1,10 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import include, url
|
from django.conf.urls import url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.shortcuts import Http404
|
||||||
from django.views.static import serve
|
from django.views.static import serve
|
||||||
|
|
||||||
import main.views
|
import main.views
|
||||||
@ -14,6 +15,8 @@ import newsletters.views
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def protected_serve(request, path, document_root=None, show_indexes=False):
|
def protected_serve(request, path, document_root=None, show_indexes=False):
|
||||||
|
if not request.user.has_perm('view_pdf'):
|
||||||
|
return Http404()
|
||||||
return serve(request, path, document_root, show_indexes)
|
return serve(request, path, document_root, show_indexes)
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,6 +9,12 @@ class Subtitle(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class Decision(models.Model):
|
class Decision(models.Model):
|
||||||
|
|
||||||
|
class Meta(object):
|
||||||
|
permissions = (
|
||||||
|
('view_pdf', 'Can view PDF'),
|
||||||
|
)
|
||||||
|
|
||||||
date = models.DateField()
|
date = models.DateField()
|
||||||
headers = models.ManyToManyField(Subtitle)
|
headers = models.ManyToManyField(Subtitle)
|
||||||
pdf = models.FileField(upload_to='secure')
|
pdf = models.FileField(upload_to='secure')
|
||||||
|
19
case_law/templates/decision.html
Normal file
19
case_law/templates/decision.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div class="container-fluid bg-light-blue py-3">
|
||||||
|
<div class="container">
|
||||||
|
<h1>Synopsis</h1>
|
||||||
|
<h6 class="text-muted">Date: {{ decision.date }}</h6>
|
||||||
|
<p>{{ decision.synopsis | linebreaks }}</p>
|
||||||
|
{% if perms.case_law.view_pdf %}
|
||||||
|
<a href="/media/{{ decision.pdf }}">View PDF</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
@ -38,4 +38,5 @@ def browser(request):
|
|||||||
|
|
||||||
|
|
||||||
def case(request, id):
|
def case(request, id):
|
||||||
return render(request)
|
decision = Decision.objects.get(id=id)
|
||||||
|
return render(request, 'decision.html', {'decision': decision})
|
||||||
|
Loading…
Reference in New Issue
Block a user