1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
from django.db import models
from django.template.defaultfilters import slugify
from locations.models import Location
from utils.util import markdown_to_html
class Person(models.Model):
first_name = models.CharField(max_length=200)
last_name = models.CharField(max_length=200, null=True, blank=True)
email = models.EmailField(max_length=120, null=True, blank=True)
address = models.TextField(null=True, blank=True)
street = models.CharField(max_length=355, null=True, blank=True)
city = models.CharField(max_length=200, null=True, blank=True)
state = models.CharField(max_length=200, null=True, blank=True)
postal_code = models.CharField(max_length=20, null=True, blank=True)
country = models.CharField(max_length=200, null=True)
phone = models.CharField(max_length=22, blank=True, null=True)
notes = models.TextField(null=True, blank=True)
location_met = models.ForeignKey(Location, on_delete=models.CASCADE, null=True, blank=True)
contact_frequency = models.BigIntegerField(help_text="In days")
next_contact_date = models.DateField(null=True, blank=True)
date_added = models.DateField(auto_now_add=True)
class Meta:
ordering = ('-last_name',)
def __str__(self):
return "%s %s" %(self.first_name, self.last_name)
def get_absolute_url(self):
return reverse("people:detail", kwargs={"pk": self.pk})
@property
def get_previous_admin_url(self):
n = self.get_previous_by_pub_date()
return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[n.id] )
@property
def get_next_admin_url(self):
model = apps.get_model(app_label=self._meta.app_label, model_name=self._meta.model_name)
try:
return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[self.get_next_by_pub_date().pk] )
except model.DoesNotExist:
return ''
def save(self, *args, **kwargs):
super(Person, self).save()
|