Added CVs to experts
This commit is contained in:
parent
1c1b56722c
commit
018d600f53
@ -16,12 +16,19 @@ import newsletters.views
|
||||
|
||||
|
||||
@login_required
|
||||
def protected_serve(request, path, document_root=None, show_indexes=False):
|
||||
def serve_case(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)
|
||||
|
||||
|
||||
@login_required
|
||||
def serve_cv(request, path, document_root=None, show_indexes=False):
|
||||
if not request.user.has_perm('view_cv'):
|
||||
return Http404()
|
||||
return serve(request, path, document_root, show_indexes)
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', main.views.index, name='home'),
|
||||
url(r'^admin/logout', main.views.logout, name='logout'),
|
||||
@ -35,7 +42,8 @@ urlpatterns = [
|
||||
url(r'^forum/(?P<thread>\d*)?', forum.views.view, name='forum'),
|
||||
url(r'^login/', main.views.login, name='login'),
|
||||
url(r'^logout/', main.views.logout, name='logout'),
|
||||
url(r'^media/secure/(?P<path>.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'),
|
||||
url(r'^media/case_law/(?P<path>.*)$', serve_case, {'document_root': os.path.join(settings.MEDIA_ROOT, 'case_law')}, name='media caselaw'),
|
||||
url(r'^media/cv/(?P<path>.*)$', serve_cv, {'document_root': os.path.join(settings.MEDIA_ROOT, 'cv')}, name='media cv'),
|
||||
url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media'),
|
||||
url(r'^members', charter_members.views.all, name='members'),
|
||||
url(r'^newsletter/unsubscribe', newsletters.views.unsubscribe, name='unsubscribe'),
|
||||
|
@ -22,7 +22,7 @@ class Case(models.Model):
|
||||
|
||||
published = models.DateField()
|
||||
headings = models.ManyToManyField(Heading)
|
||||
pdf = models.FileField('PDF', upload_to='secure', validators=[validate_file_extension])
|
||||
pdf = models.FileField('PDF', upload_to='case_law', validators=[validate_file_extension])
|
||||
synopsis = models.TextField()
|
||||
|
||||
def __str__(self):
|
||||
|
@ -8,5 +8,5 @@ admin.site.register(AreaOfExpertise)
|
||||
|
||||
@admin.register(Expert)
|
||||
class ExpertiseAdmin(admin.ModelAdmin):
|
||||
fields = ['name', 'institute', 'expertise', 'cases']
|
||||
fields = ['name', 'institute', 'CV', 'expertise', 'cases']
|
||||
filter_horizontal = ('expertise', 'cases')
|
||||
|
@ -1,3 +1,4 @@
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
|
||||
from case_law.models import Case
|
||||
@ -15,7 +16,18 @@ class AreaOfExpertise(models.Model):
|
||||
|
||||
|
||||
class Expert(models.Model):
|
||||
|
||||
class Meta(object):
|
||||
permissions = (
|
||||
('view_cv', 'Can view CV'),
|
||||
)
|
||||
|
||||
def validate_file_extension(value):
|
||||
if not value.name.endswith('.pdf'):
|
||||
raise ValidationError(u'File is not a PDF')
|
||||
|
||||
cases = models.ManyToManyField(Case, blank=True)
|
||||
CV = models.FileField('CV', upload_to='cv', validators=[validate_file_extension], blank=True, null=True)
|
||||
expertise = models.ManyToManyField(AreaOfExpertise)
|
||||
institute = models.CharField(max_length=255, null=True, blank=True)
|
||||
name = models.CharField(max_length=255)
|
||||
|
@ -17,12 +17,19 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-9 py-3">
|
||||
<div>
|
||||
<h3>{{ expert.name }}</h3>
|
||||
{% if expert.institute %}
|
||||
<i class="fa fa-institution"></i> {{ expert.institute }}
|
||||
{% else %}
|
||||
<span class="text-muted"><i class="fa fa-institution"></i> No Institute</span>
|
||||
<h3 class="mb-0">{{ expert.name }}</h3>
|
||||
{% if expert.CV and perms.expert_witnesses.view_cv %}
|
||||
<a href="/media/{{ expert.CV }}" target="_blank">
|
||||
<i class="fa fa-file-pdf-o" aria-hidden="true"></i> Download CV
|
||||
</a>
|
||||
{% endif %}
|
||||
<div>
|
||||
{% if expert.institute %}
|
||||
<i class="fa fa-institution"></i> {{ expert.institute }}
|
||||
{% else %}
|
||||
<span class="text-muted"><i class="fa fa-institution"></i> No Institute</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-md-none mt-5">
|
||||
<h5 class="ml-1">Expertise</h5>
|
||||
|
Loading…
Reference in New Issue
Block a user