2017-08-17 13:20:57 -04:00
|
|
|
from django.conf import settings
|
|
|
|
from django.db import models
|
|
|
|
|
2018-01-12 01:54:50 -05:00
|
|
|
from tinymce import HTMLField
|
|
|
|
|
2017-08-17 13:20:57 -04:00
|
|
|
|
2018-01-14 17:24:58 -05:00
|
|
|
class Chapter(models.Model):
|
|
|
|
name = models.CharField(max_length=50)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
2017-08-17 13:20:57 -04:00
|
|
|
class Position(models.Model):
|
|
|
|
position_name = models.CharField(max_length=50)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.position_name
|
|
|
|
|
|
|
|
|
|
|
|
class Attorney(models.Model):
|
2018-01-12 01:54:50 -05:00
|
|
|
biography = HTMLField(blank=True, null=True)
|
2018-01-14 17:24:58 -05:00
|
|
|
chapter = models.ForeignKey(Chapter, blank=True, null=True)
|
2017-08-17 13:20:57 -04:00
|
|
|
email = models.CharField(max_length=255, blank=True, null=True)
|
|
|
|
front_page = models.BooleanField(default=False)
|
2017-08-17 14:46:44 -04:00
|
|
|
image = models.ImageField(upload_to='portraits', default='portraits/silhouette.png')
|
2017-08-17 13:20:57 -04:00
|
|
|
joined = models.DateField(blank=True, null=True)
|
|
|
|
name = models.CharField(max_length=100)
|
2018-01-14 21:10:47 -05:00
|
|
|
order = models.IntegerField(blank=True, null=True, verbose_name='Order On Front Page')
|
2017-08-17 13:20:57 -04:00
|
|
|
phone = models.CharField(max_length=10, blank=True, null=True)
|
|
|
|
position = models.ForeignKey(Position)
|
|
|
|
website = models.CharField(max_length=255, blank=True, null=True)
|
|
|
|
|
|
|
|
def phone_formatted(self):
|
2017-08-17 14:46:44 -04:00
|
|
|
if self.phone is None or self.phone == '': return ''
|
2017-09-04 01:31:38 -04:00
|
|
|
return '({}) {}-{}'.format(self.phone[:3], self.phone[3:6], self.phone[6:])
|
2017-08-17 13:20:57 -04:00
|
|
|
phone_formatted.short_description = 'Phone'
|
|
|
|
|
|
|
|
def thumbnail(self):
|
2017-09-04 01:31:38 -04:00
|
|
|
return '<img src="{}{}" height="50"/>'.format(settings.MEDIA_URL, str(self.image))
|
2017-08-17 13:20:57 -04:00
|
|
|
thumbnail.short_description = 'Image'
|
|
|
|
thumbnail.allow_tags = True
|
|
|
|
|
|
|
|
def image_preview(self):
|
2017-09-04 01:31:38 -04:00
|
|
|
return '<img src="{}{}"/>'.format(settings.MEDIA_URL, str(self.image))
|
2017-08-17 13:20:57 -04:00
|
|
|
image_preview.short_description = 'Image'
|
|
|
|
image_preview.allow_tags = True
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|