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