From 8aab1bfc276d4abdb62145a6f8c60a8c077e9d6c Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Thu, 28 May 2020 15:27:46 +0100 Subject: done a lot of mocking up of the stakeholder home page --- ctrack/core/views.py | 12 ++- ctrack/templates/pages/home.html | 3 - ctrack/templates/pages/stakeholder_home.html | 124 +++++++++++++++++++-------- ctrack/users/tests/test_functional.py | 24 ++---- 4 files changed, 107 insertions(+), 56 deletions(-) (limited to 'ctrack') diff --git a/ctrack/core/views.py b/ctrack/core/views.py index 107458e..b80d212 100644 --- a/ctrack/core/views.py +++ b/ctrack/core/views.py @@ -1,10 +1,20 @@ from django.contrib.auth.decorators import login_required from django.shortcuts import render +from ctrack.organisations.models import Organisation + @login_required def home_page(request): if request.user.is_stakeholder: - return render(request, "pages/stakeholder_home.html") + org = Organisation.objects.get( + name=request.user.stakeholder.person.get_organisation_name() + ) + systems = org.applicablesystem_set.all() + return render( + request, + "pages/stakeholder_home.html", + context={"org": org, "systems": systems}, + ) else: return render(request, "pages/home.html") diff --git a/ctrack/templates/pages/home.html b/ctrack/templates/pages/home.html index 36a3abf..324da8e 100644 --- a/ctrack/templates/pages/home.html +++ b/ctrack/templates/pages/home.html @@ -2,9 +2,6 @@ {% block content %} -

Welcome to ctrack - Department for Transport

- -

User: {{ object }}

THIS IS A TEMPLATE FOR A REGULAR USER

{% endblock content %} diff --git a/ctrack/templates/pages/stakeholder_home.html b/ctrack/templates/pages/stakeholder_home.html index 9832d7d..d7e1793 100644 --- a/ctrack/templates/pages/stakeholder_home.html +++ b/ctrack/templates/pages/stakeholder_home.html @@ -7,53 +7,103 @@
-

Welcome to ctrack - Department for Transport

+ +

{{ org }} {{ org.submode }}

+ +

{{ org.person_set.first }}

THIS IS A TEMPLATE FOR A STAKEHOLDER USER

+ +
+
+
+
INFORMATION NOTICE:
+

Please note that important notices go in here. This is the NIS Directive + portal for DfT. Etc.

+

Your lead inspector is Bob McKinnon.

+

Other important messages will appear here when we deem it necessary. + Please ensure you remain in touch with what appears in this box because it + WILL be updated periodically.

+
+
+
+
-
-

Incident Reporting

- - + +
+
+

Incident Reporting

+
+ + + + + + + + + + + + + + - - - - + + + + - - - - - - - - - - - - - -
IncidentDateDetailsStatus
Power failure at Random Site12 May 2020There was a problem with some wires inside the black box at the site. + There was very little we could do until someone switched the circuit breakers off, + then we had to switch off the server that supplies the TLS link to the estate management + system. We failed on this one, big time.RESOLVED
IncidentDateDetailsStatusCorruption of main database8 December 2019Weather got to the night-watchperson, who typed in the command to seal + the compound incorrectly. This led to a deluge of sand into the minky processor + which eventually wiped all data tables.UNRESOLVED
Power failure at Random Site12 May 2020There was a problem with some wires inside the black box at the site. - There was very little we could do until someone switched the circuit breakers off, - then we had to switch off the server that supplies the TLS link to the estate management - system. We failed on this one, big time.RESOLVED
Corruption of main database8 December 2019Weather got to the night-watchperson, who typed in the command to seal - the compound incorrectly. This led to a deluge of sand into the minky processor - which eventually wiped all data tables.UNRESOLVED
- + + +

-
-

Audits and Inspections

-

No recent audits or inspections
- No audits or inspections currently scheduled

+
+
+

Audits and Inspections

+

No recent audits or inspections
+ No audits or inspections currently scheduled

+
-

NIS systems

-

Table of NIS systems here...

+
+ +
+
+

NIS systems

+ + + + + + + + + {% for system in systems %} + + + + + + {% endfor %} +
System NameDescriptionCAF
{{ system.name }}{{ system.description }}{{ system.caf }}
+
+
-

DfT Engagement

-

No engagement with DfT currently scheduled

+
+ +
+
+

DfT Engagement

+

No engagement with DfT currently scheduled

+
+
diff --git a/ctrack/users/tests/test_functional.py b/ctrack/users/tests/test_functional.py index 3449c9a..5622ab3 100644 --- a/ctrack/users/tests/test_functional.py +++ b/ctrack/users/tests/test_functional.py @@ -28,11 +28,6 @@ def test_regular_user_can_log_in(browser, live_server): current_url = browser.current_url assert current_url == live_server + "/" - # On the other side, he sees some basic details about himself. - assert "ctrack - Department for Transport" in browser.title - - h1 = browser.find_element_by_tag_name("h1") - assert h1.text == "Welcome to ctrack - Department for Transport" type_user_message = browser.find_elements_by_tag_name("p") assert "THIS IS A TEMPLATE FOR A REGULAR USER" in [ m.text for m in type_user_message @@ -44,6 +39,7 @@ def test_stakeholder_can_log_in_and_see_their_home(browser, live_server, stakeho user = User.objects.create_user(username="toss", password="knob") user.stakeholder = stakeholder + org = user.stakeholder.person.get_organisation_name() user.save() browser.get(live_server + "/accounts/login") browser.find_element_by_id("id_login").send_keys("toss") @@ -53,16 +49,14 @@ def test_stakeholder_can_log_in_and_see_their_home(browser, live_server, stakeho current_url = browser.current_url assert current_url == live_server + "/" - # On the other side, he sees some basic details about himself. - assert "ctrack - Department for Transport" in browser.title - - # Such as his own name in an H1 tag! - h1 = browser.find_element_by_tag_name("h1") - assert h1.text == "Welcome to ctrack - Department for Transport" - type_user_message = browser.find_elements_by_tag_name("p") - assert "THIS IS A TEMPLATE FOR A STAKEHOLDER USER" in [ - m.text for m in type_user_message - ] + p_tags = browser.find_elements_by_tag_name("p") + h2_tags = browser.find_elements_by_tag_name("h2") + assert "THIS IS A TEMPLATE FOR A STAKEHOLDER USER" in [m.text for m in p_tags] + assert org in [m.text for m in h2_tags] + assert ( + f"{user.stakeholder.person.first_name} {user.stakeholder.person.last_name}" + in [m.text for m in p_tags] + ) def test_stakeholder_can_log_in_but_receieved_permisson_denied_when_off_piste( -- cgit v1.2.3