mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-24 08:52:15 +00:00
Started work on Person modeling
This commit is contained in:
@@ -2,6 +2,7 @@ from django.db import models
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.conf import settings
|
||||
import hashlib
|
||||
import reversion
|
||||
|
||||
# Create your models here.
|
||||
class Profile(AbstractUser):
|
||||
@@ -13,4 +14,26 @@ class Profile(AbstractUser):
|
||||
url = ""
|
||||
if settings.USE_GRAVATAR or settings.USE_GRAVATAR is None:
|
||||
url = "https://www.gravatar.com/avatar/" + hashlib.md5(self.email).hexdigest() + "?d=identicon&s=500"
|
||||
return url
|
||||
return url
|
||||
|
||||
class ModelComment(models.Model):
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL)
|
||||
postedAt = models.DateTimeField(auto_now=True)
|
||||
|
||||
message = models.TextField()
|
||||
|
||||
@reversion.register
|
||||
class Person(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
phone = models.CharField(max_length=15, blank=True, null=True)
|
||||
email = models.EmailField(blank=True, null=True)
|
||||
|
||||
address = models.TextField(blank=True, null=True)
|
||||
|
||||
comments = models.ManyToManyField('ModelComment')
|
||||
|
||||
def __unicode__(self):
|
||||
string = self.name
|
||||
if self.comments:
|
||||
string += "*"
|
||||
return string
|
||||
Reference in New Issue
Block a user