oacpl/expert_witnesses/models.py

37 lines
1013 B
Python
Raw Normal View History

2018-01-14 18:34:28 -05:00
from django.core.exceptions import ValidationError
2017-09-05 02:24:39 -04:00
from django.db import models
2017-09-06 00:28:39 -04:00
from case_law.models import Case
2017-09-05 02:24:39 -04:00
class AreaOfExpertise(models.Model):
class Meta:
verbose_name = 'Area of Expertise'
2017-09-13 22:16:45 -04:00
verbose_name_plural = 'Areas of Expertise'
2017-09-05 02:24:39 -04:00
field = models.CharField(max_length=255)
def __str__(self):
return self.field
class Expert(models.Model):
2018-01-14 18:34:28 -05:00
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')
2017-09-16 18:45:21 -04:00
cases = models.ManyToManyField(Case, blank=True)
2018-01-14 18:34:28 -05:00
CV = models.FileField('CV', upload_to='cv', validators=[validate_file_extension], blank=True, null=True)
2017-09-05 02:24:39 -04:00
expertise = models.ManyToManyField(AreaOfExpertise)
institute = models.CharField(max_length=255, null=True, blank=True)
name = models.CharField(max_length=255)
def __str__(self):
return self.name