From 0fad480db4f1d76bcbfd1e34f99760519bb05b0b Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 12 Nov 2023 17:41:46 +0000 Subject: [PATCH] some more update --- anatomy/tests/test_anatomy_exams.py | 2 +- longs/tests/test_longs_exams.py | 2 +- physics/tests/test_physics_exams.py | 2 +- rad/{ => tests}/test_helpers.py | 0 rad/tests/test_user_access.py | 0 rad/urls.py | 1 + rad/views.py | 3 + rapids/tests/test_rapids_exams.py | 2 +- rapids/tests/test_urls.py | 43 ++++- sbas/tests/test_sbas_exams.py | 2 +- templates/base.html | 2 +- templates/people.html | 240 ++++++++++++++++++++++++++++ 12 files changed, 292 insertions(+), 7 deletions(-) rename rad/{ => tests}/test_helpers.py (100%) create mode 100644 rad/tests/test_user_access.py create mode 100644 templates/people.html diff --git a/anatomy/tests/test_anatomy_exams.py b/anatomy/tests/test_anatomy_exams.py index acc7afff..3b8e01e3 100644 --- a/anatomy/tests/test_anatomy_exams.py +++ b/anatomy/tests/test_anatomy_exams.py @@ -25,7 +25,7 @@ from anatomy.models import ( from generic.models import CidUser, CidUserGroup, UserUserGroup -from rad.test_helpers import AssertNotFound, create_cid_user_and_groups +from rad.tests.test_helpers import AssertNotFound, create_cid_user_and_groups from django.contrib.auth.models import User diff --git a/longs/tests/test_longs_exams.py b/longs/tests/test_longs_exams.py index ac36e0d3..c7c96869 100644 --- a/longs/tests/test_longs_exams.py +++ b/longs/tests/test_longs_exams.py @@ -31,7 +31,7 @@ from generic.models import CidUser, CidUserGroup, UserUserGroup from django.contrib.auth.models import User -from rad.test_helpers import AssertNotFound, create_cid_user_and_groups +from rad.tests.test_helpers import AssertNotFound, create_cid_user_and_groups diff --git a/physics/tests/test_physics_exams.py b/physics/tests/test_physics_exams.py index 95170a9d..c2deb444 100644 --- a/physics/tests/test_physics_exams.py +++ b/physics/tests/test_physics_exams.py @@ -19,7 +19,7 @@ from physics.views import GenericExamViews as PhysicsExamViews from physics.models import Category, UserAnswer, Exam, Question from generic.models import CidUser, CidUserGroup, UserUserGroup -from rad.test_helpers import AssertNotFound, ExamTester, create_cid_user_and_groups, create_exam +from rad.tests.test_helpers import AssertNotFound, ExamTester, create_cid_user_and_groups, create_exam from django.contrib.auth.models import User diff --git a/rad/test_helpers.py b/rad/tests/test_helpers.py similarity index 100% rename from rad/test_helpers.py rename to rad/tests/test_helpers.py diff --git a/rad/tests/test_user_access.py b/rad/tests/test_user_access.py new file mode 100644 index 00000000..e69de29b diff --git a/rad/urls.py b/rad/urls.py index 760eea66..bce089b0 100644 --- a/rad/urls.py +++ b/rad/urls.py @@ -88,6 +88,7 @@ urlpatterns = [ views.UpdateUserProfileView.as_view(), name="account_profile_update", ), + path("people", views.people, name="people"), path("accounts/", views.UserListTableView.as_view(), name="accounts_list"), #path("accounts/", views.UserListView.as_view(), name="accounts_list"), path("accounts/", include("django.contrib.auth.urls")), diff --git a/rad/views.py b/rad/views.py index 8a928260..ce28068e 100644 --- a/rad/views.py +++ b/rad/views.py @@ -79,6 +79,9 @@ from django.template import RequestContext def feedback_checker(user): return user.groups.filter(name="feedback_checker").exists() +@user_is_cid_user_manager +def people(request): + return render(request, "people.html", {}) @login_required def profile(request): diff --git a/rapids/tests/test_rapids_exams.py b/rapids/tests/test_rapids_exams.py index 616375dd..418635f0 100644 --- a/rapids/tests/test_rapids_exams.py +++ b/rapids/tests/test_rapids_exams.py @@ -21,7 +21,7 @@ from generic.models import CidUser, CidUserGroup, UserUserGroup from django.contrib.auth.models import User -from rad.test_helpers import AssertNotFound, create_cid_user_and_groups +from rad.tests.test_helpers import AssertNotFound, create_cid_user_and_groups APP_NAME = "rapids" diff --git a/rapids/tests/test_urls.py b/rapids/tests/test_urls.py index 825f81f3..fe06831d 100644 --- a/rapids/tests/test_urls.py +++ b/rapids/tests/test_urls.py @@ -8,6 +8,8 @@ from rich.pretty import pprint from bs4 import BeautifulSoup +from django.contrib.auth.models import Group + from rapids.views import GenericExamViews as RapidExamViews from rapids.views import GenericExamViews as LongExamViews from sbas.views import GenericExamViews as SbaExamViews @@ -40,6 +42,17 @@ def create_superuser(db, django_user_model): "admin", "ross@xkjq.uk", "adminpassword" ) +@pytest.fixture +def create_cid_manager(db, django_user_model): + user = django_user_model.objects.create_user( + "cid_user", "cid@user.com", "password1234" + ) + g = Group.objects.create(name="cid_user_manager") + g.save() + user.groups.add(g) + return user + + @pytest.fixture(params=EXAM_VIEWS) def set_up_exams(request, django_user_model, create_superuser): basic_user = django_user_model.objects.create_user( @@ -212,4 +225,32 @@ def test_index(client, create_superuser, exam_views, django_user_model): json_response = json.loads(response.content)["exams"] - assert len(json_response) == 2 \ No newline at end of file + assert len(json_response) == 2 + +def test_cid_management(client, create_cid_manager, django_user_model): + urls = [ + reverse(f"people"), + #reverse(f"generic:update_cid"), + #reverse(f"generic:update_cid_exams"), + reverse(f"generic:manage_cids"), + reverse(f"generic:manage_cid_exams"), + reverse(f"generic:cid_group_view"), + reverse(f"generic:cid_group_view_all"), + reverse(f"generic:cid_group_create"), + ] + + for url in urls: + response = client.get(url) + assert response.status_code == 403 + + pass + + cid_manager = create_cid_manager + + client.force_login(cid_manager) + + for url in urls: + response = client.get(url) + assert response.status_code == 200 + + pass \ No newline at end of file diff --git a/sbas/tests/test_sbas_exams.py b/sbas/tests/test_sbas_exams.py index 8b69c876..2584dc98 100644 --- a/sbas/tests/test_sbas_exams.py +++ b/sbas/tests/test_sbas_exams.py @@ -19,7 +19,7 @@ from sbas.views import GenericExamViews as SbaExamViews from sbas.models import Category, UserAnswer, Exam, Question from generic.models import CidUser, CidUserGroup, UserUserGroup -from rad.test_helpers import AssertNotFound, ExamTester, create_cid_user_and_groups, create_exam +from rad.tests.test_helpers import AssertNotFound, ExamTester, create_cid_user_and_groups, create_exam from django.contrib.auth.models import User diff --git a/templates/base.html b/templates/base.html index 6c4a92c1..07e1d644 100644 --- a/templates/base.html +++ b/templates/base.html @@ -104,7 +104,7 @@ {% if request.user|has_group:"cid_user_manager" %} - Candidates + People {% endif %} {% endif %} diff --git a/templates/people.html b/templates/people.html new file mode 100644 index 00000000..c4e34310 --- /dev/null +++ b/templates/people.html @@ -0,0 +1,240 @@ +{% extends 'generic/base.html' %} + +{% load crispy_forms_tags %} +{% block css %} +{% endblock %} + +{% block content %} + +

People

+

The system contains a number of different people / groups. This affects how they are managed and what they are able to do.

+

They can be managed using the navigation links above

+ +

User(s)

+

Users on the system have a registered account. This allows them to log in to browse the site. In most cases they will be able to creeate and manage exams / packets as well as take those that they have been given access to.

+ +

All South West (internal) trainees should have an account. This allows for easier management as they can be grouped by grade, can be associated with supervisors and will have their history stored.

+ + +

Supervisor(s)

+

Each user can be associated with a "supervisor". This is a way of linking a user to their educational supervisor to allow for supervisor reviewing of results. By default this just includes the supervisors email (and site) but if the superivsor wishes they can associate their account which allows (TODO) for on demand access.

+ + +

Cid Candidate(s)

+

These are used when a person requires access to the test system for a one off purpose, for example a course. Ideally it should be avoided if a user has an account (see above) on the system.

+ +

The user will be given a candidate id (CID) and passcode that can be used to log into the system. This will allow them to take exams/packets and view results.

+ +

+The only required information is an email address. +

+ +

Although it is (currently) possible to link a cid user with a supervisor, this should be avoided as they should use a full account.

+ + +

Groups

+

Groups are how users are given access to exams / packets.

+

2 types of groups can be created, they are essentially the same with one managing CID candidates, the other standard accounts

+

Once a group has been created this can be associated with a packet/exam/collection and the users contained within can be given access

+ + +{% endblock %} + +{% block js %} + + +{% comment %} + + {% endcomment %} + + + + + +{% endblock %}