diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-31 11:40:43 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-05-31 11:40:43 +0100 |
commit | 5c6b9e60547a5884b7debe450aa0ddaea075d4f9 (patch) | |
tree | 3aa263142f691d311f754da53b8a31dfaad23928 /ctrack | |
parent | 9917bd1793d0362b84704d0ad4409be4ec9dbdd3 (diff) |
working on user groups and tests
Diffstat (limited to 'ctrack')
-rw-r--r-- | ctrack/core/utils.py | 9 | ||||
-rw-r--r-- | ctrack/templates/account/logout.html | 35 | ||||
-rw-r--r-- | ctrack/users/tests/test_credentials.py | 16 |
3 files changed, 44 insertions, 16 deletions
diff --git a/ctrack/core/utils.py b/ctrack/core/utils.py index bebf176..ef998d0 100644 --- a/ctrack/core/utils.py +++ b/ctrack/core/utils.py @@ -1,6 +1,8 @@ import random from random import choice, randint +from django.contrib.auth import get_user_model +from django.contrib.auth.models import Group from faker import Faker from ctrack.assessments.models import ( @@ -69,6 +71,9 @@ def populate_db(**kwargs): _org_number = kwargs.get("orgs") _igp_number = kwargs.get("igps") + # Groups + cct_staff_group = Group.objects.create(name="cct_users") + # Set up some reasonable Modes and SubModes m1 = Mode.objects.create(descriptor="Rail") m2 = Mode.objects.create(descriptor="Maritime") @@ -155,6 +160,10 @@ def populate_db(**kwargs): ) for _ in range(5) ] + inspector_user = get_user_model().objects.create( + username="inspector1", name="inspector1" + ) + inspector_user.groups.add(cct_staff_group) etf1 = EngagementTypeFactory(descriptor="Information Notice") etf2 = EngagementTypeFactory(descriptor="Designation Letter") diff --git a/ctrack/templates/account/logout.html b/ctrack/templates/account/logout.html index 8e2e675..2ce13ea 100644 --- a/ctrack/templates/account/logout.html +++ b/ctrack/templates/account/logout.html @@ -1,21 +1,32 @@ {% extends "account/base.html" %} -{% load i18n %} - -{% block head_title %}{% trans "Sign Out" %}{% endblock %} +{% block head_title %}Sign Out{% endblock %} {% block inner %} -<h1>{% trans "Sign Out" %}</h1> -<p>{% trans 'Are you sure you want to sign out?' %}</p> -<form method="post" action="{% url 'account_logout' %}"> - {% csrf_token %} - {% if redirect_field_value %} - <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/> - {% endif %} - <button class="btn btn-danger" type="submit">{% trans 'Sign Out' %}</button> -</form> + <div class="container"> + <div class="col-md-12 my-3 p-3 border border-danger rounded"> + <div class="row"> + <div class="col-md-12"> + <h2>Sign Out</h2> + <p>Are you sure you want to sign out?</p> + <form method="post" action="{% url 'account_logout' %}"> + {% csrf_token %} + {% if redirect_field_value %} + <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}"/> + {% endif %} + <button class="btn btn-danger" type="submit">Sign Out</button> + </form> + </div> + + </div> + + </div> + + </div> + + {% endblock %} diff --git a/ctrack/users/tests/test_credentials.py b/ctrack/users/tests/test_credentials.py index 7538643..a63ffe0 100644 --- a/ctrack/users/tests/test_credentials.py +++ b/ctrack/users/tests/test_credentials.py @@ -22,9 +22,17 @@ def user_A(db) -> Group: return user -def test_should_create_user(user_A: get_user_model()) -> None: - assert user_A.username == "A" +def test_there_is_a_cct_user_group(db): + group = Group.objects.create(name="cct_user") + assert Group.objects.get(name="cct_user") + user = get_user_model().objects.create_user("INSPECTOR") + user.groups.add(group) + assert group in user.groups.all() + + +# def test_should_create_user(user_A: get_user_model()) -> None: +# assert user_A.username == "A" -def test_user_is_in_app_user_group(user_A: get_user_model()) -> None: - assert user_A.groups.filter(name="cct_user").exists() +# def test_user_is_in_app_user_group(user_A: get_user_model()) -> None: +# assert user_A.groups.filter(name="cct_user").exists() |