aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/users/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack/users/models.py')
-rw-r--r--ctrack/users/models.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/ctrack/users/models.py b/ctrack/users/models.py
index 8f07b15..052efd6 100644
--- a/ctrack/users/models.py
+++ b/ctrack/users/models.py
@@ -1,14 +1,28 @@
from django.contrib.auth.models import AbstractUser
-from django.db.models import CharField
+from django.db import models
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
+from ctrack.organisations.models import Stakeholder
+
class User(AbstractUser):
- # First Name and Last Name do not cover name patterns
- # around the globe.
- name = CharField(_("Name of User"), blank=True, max_length=255)
+ name = models.CharField(_("Name of User"), blank=True, max_length=255)
+ stakeholder = models.OneToOneField(
+ Stakeholder, on_delete=models.CASCADE, null=True, blank=True
+ )
def get_absolute_url(self):
return reverse("users:detail", kwargs={"username": self.username})
+
+ @property
+ def is_stakeholder(self):
+ if self.stakeholder is not None:
+ return True
+ else:
+ return False
+
+ def get_organisation_name(self):
+ if self.is_stakeholder:
+ return self.stakeholder.person.organisation.name