aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack/users
diff options
context:
space:
mode:
Diffstat (limited to 'ctrack/users')
-rw-r--r--ctrack/users/migrations/0002_user_is_person.py18
-rw-r--r--ctrack/users/models.py3
-rw-r--r--ctrack/users/tests/factories.py1
-rw-r--r--ctrack/users/tests/test_models.py13
4 files changed, 34 insertions, 1 deletions
diff --git a/ctrack/users/migrations/0002_user_is_person.py b/ctrack/users/migrations/0002_user_is_person.py
new file mode 100644
index 0000000..2223429
--- /dev/null
+++ b/ctrack/users/migrations/0002_user_is_person.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.5 on 2020-05-22 15:19
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('users', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='user',
+ name='is_person',
+ field=models.BooleanField(default=False),
+ ),
+ ]
diff --git a/ctrack/users/models.py b/ctrack/users/models.py
index 8f07b15..d1ab662 100644
--- a/ctrack/users/models.py
+++ b/ctrack/users/models.py
@@ -1,5 +1,5 @@
from django.contrib.auth.models import AbstractUser
-from django.db.models import CharField
+from django.db.models import BooleanField, CharField
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
@@ -9,6 +9,7 @@ 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)
+ is_person = BooleanField(default=False)
def get_absolute_url(self):
return reverse("users:detail", kwargs={"username": self.username})
diff --git a/ctrack/users/tests/factories.py b/ctrack/users/tests/factories.py
index b4ddad0..eb5a17f 100644
--- a/ctrack/users/tests/factories.py
+++ b/ctrack/users/tests/factories.py
@@ -8,6 +8,7 @@ class UserFactory(DjangoModelFactory):
username = Faker("user_name")
email = Faker("email")
name = Faker("name")
+ is_person = False
@post_generation
def password(self, create: bool, extracted: Sequence[Any], **kwargs):
diff --git a/ctrack/users/tests/test_models.py b/ctrack/users/tests/test_models.py
index 1b33961..d83d8b8 100644
--- a/ctrack/users/tests/test_models.py
+++ b/ctrack/users/tests/test_models.py
@@ -1,5 +1,12 @@
import pytest
+from django.contrib.auth import get_user_model
+from ctrack.organisations.models import Mode, Person, Submode
+from ctrack.organisations.tests.factories import (
+ OrganisationFactory,
+ PersonFactory,
+ RoleFactory,
+)
from ctrack.users.models import User
pytestmark = pytest.mark.django_db
@@ -7,3 +14,9 @@ pytestmark = pytest.mark.django_db
def test_user_get_absolute_url(user: User):
assert user.get_absolute_url() == f"/users/{user.username}/"
+
+
+def test_user_is_person_object(user: User):
+ """User comes from ctrack.conftest.
+ """
+ assert user.is_person is False