diff options
-rw-r--r-- | config/urls.py | 2 | ||||
-rw-r--r-- | ctrack/core/urls.py | 9 | ||||
-rw-r--r-- | ctrack/core/views.py | 4 | ||||
-rw-r--r-- | ctrack/organisations/models.py | 4 | ||||
-rw-r--r-- | ctrack/templates/base.html | 4 | ||||
-rw-r--r-- | ctrack/templates/pages/home.html | 10 | ||||
-rw-r--r-- | ctrack/users/migrations/0002_user_is_person.py | 18 | ||||
-rw-r--r-- | ctrack/users/models.py | 3 | ||||
-rw-r--r-- | ctrack/users/tests/factories.py | 1 | ||||
-rw-r--r-- | ctrack/users/tests/test_models.py | 13 |
10 files changed, 60 insertions, 8 deletions
diff --git a/config/urls.py b/config/urls.py index 43bec0d..663ec38 100644 --- a/config/urls.py +++ b/config/urls.py @@ -9,7 +9,7 @@ from django.views import defaults as default_views admin.site.site_header = "ctrack admin" urlpatterns = [ - path("", TemplateView.as_view(template_name="pages/home.html"), name="home"), + path("", include("ctrack.core.urls", namespace="core")), path( "about/", TemplateView.as_view(template_name="pages/about.html"), name="about" ), diff --git a/ctrack/core/urls.py b/ctrack/core/urls.py new file mode 100644 index 0000000..8f2ca6e --- /dev/null +++ b/ctrack/core/urls.py @@ -0,0 +1,9 @@ +from django.urls import path + +from ctrack.core.views import home_page + +app_name = "core" + +urlpatterns = [ + path("", home_page, name="home") +] diff --git a/ctrack/core/views.py b/ctrack/core/views.py index 91ea44a..bee2d72 100644 --- a/ctrack/core/views.py +++ b/ctrack/core/views.py @@ -1,3 +1,5 @@ from django.shortcuts import render -# Create your views here. + +def home_page(request): + return render(request, "pages/home.html") diff --git a/ctrack/organisations/models.py b/ctrack/organisations/models.py index b14b03b..b11e97b 100644 --- a/ctrack/organisations/models.py +++ b/ctrack/organisations/models.py @@ -41,7 +41,7 @@ class Person(models.Model): (6, "Other"), ] - def get_sentinel_user(): + def get_sentinel_user(): # type: ignore """ We need this so that we can ensure models.SET() is applied with a callable to handle when Users are deleted from the system, preventing the Person objects @@ -110,7 +110,7 @@ class Organisation(models.Model): (3, "NA"), ] - def get_sentinel_user(): + def get_sentinel_user(): # type: ignore """ We need this so that we can ensure models.SET() is applied with a callable to handle when Users are deleted from the system, preventing the Organisations diff --git a/ctrack/templates/base.html b/ctrack/templates/base.html index 4164b06..4398926 100644 --- a/ctrack/templates/base.html +++ b/ctrack/templates/base.html @@ -40,12 +40,12 @@ <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> - <a id="_title" class="navbar-brand" href="{% url 'home' %}">ctrack</a> + <a id="_title" class="navbar-brand" href="{% url 'core:home' %}">ctrack</a> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <li class="nav-item active"> - <a class="nav-link" href="{% url 'home' %}">Home <span class="sr-only">(current)</span></a> + <a class="nav-link" href="{% url 'core:home' %}">Home <span class="sr-only">(current)</span></a> </li> <li class="nav-item active"> <a href="{% url 'caf:es_list' %}" class="nav-link">Applicable Systems</a> diff --git a/ctrack/templates/pages/home.html b/ctrack/templates/pages/home.html index 63913c1..fbce9ff 100644 --- a/ctrack/templates/pages/home.html +++ b/ctrack/templates/pages/home.html @@ -1 +1,9 @@ -{% extends "base.html" %}
\ No newline at end of file +{% extends "base.html" %} + +{% block content %} + + <h1>User profile page</h1> + + <p>User: {{ object }}</p> + +{% endblock content %} 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 |