aboutsummaryrefslogtreecommitdiffstats
path: root/ctrack
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-05-28 15:27:46 +0100
committerMatthew Lemon <lemon@matthewlemon.com>2020-05-28 15:27:46 +0100
commit8aab1bfc276d4abdb62145a6f8c60a8c077e9d6c (patch)
tree0c1f5592239ff3d5ed9070aaab27b825ed8e53f9 /ctrack
parenteceaeab4e1c4cb52e187e073c9dad858f0e0bcce (diff)
done a lot of mocking up of the stakeholder home page
Diffstat (limited to 'ctrack')
-rw-r--r--ctrack/core/views.py12
-rw-r--r--ctrack/templates/pages/home.html3
-rw-r--r--ctrack/templates/pages/stakeholder_home.html124
-rw-r--r--ctrack/users/tests/test_functional.py24
4 files changed, 107 insertions, 56 deletions
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 %}
- <h1>Welcome to ctrack - Department for Transport</h1>
-
- <p>User: {{ object }}</p>
<p>THIS IS A TEMPLATE FOR A REGULAR USER</p>
{% 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 @@
<div class="container mt-3">
<div class="row">
<div class="col-md-12 pl-0 my-2">
- <h1>Welcome to ctrack - Department for Transport</h1>
+
+ <h2>{{ org }} <span class="badge badge-light">{{ org.submode }}</span></h2>
+
+ <p><span class="text-muted">{{ org.person_set.first }}</span></p>
<p>THIS IS A TEMPLATE FOR A STAKEHOLDER USER</p>
+
+ <div class="row">
+ <div class="col-12">
+ <div class="border border-success p-2 rounded bg-light">
+ <h5>INFORMATION NOTICE:</h5>
+ <p>Please note that important notices go in here. This is the NIS Directive
+ portal for DfT. Etc.</p>
+ <p>Your lead inspector is <strong><a href="#">Bob McKinnon</a></strong>.</p>
+ <p>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
+ <strong>WILL</strong> be updated periodically.</p>
+ </div>
+ </div>
+ </div>
+
<hr>
- <div class="col md-12">
- <h2>Incident Reporting</h2>
- <table class="table table-sm">
- <thead>
+
+ <div class="row">
+ <div class="col md-12">
+ <h2>Incident Reporting</h2>
+ <table class="table">
+ <thead>
+ <tr>
+ <th scope="col">Incident</th>
+ <th scope="col">Date</th>
+ <th scope="col">Details</th>
+ <th scope="col">Status</th>
+ </tr>
+ </thead>
+ <tr>
+ <td>Power failure at Random Site</td>
+ <td>12 May 2020</td>
+ <td>There 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.</td>
+ <td><strong><span class="badge badge-primary">RESOLVED</span></strong></td>
+ </tr>
<tr>
- <th>Incident</th>
- <th>Date</th>
- <th>Details</th>
- <th>Status</th>
+ <td>Corruption of main database</td>
+ <td>8 December 2019</td>
+ <td>Weather 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.</td>
+ <td><strong><span class="badge badge-warning">UNRESOLVED</span></strong></td>
</tr>
- </thead>
- <tr>
- <td>Power failure at Random Site</td>
- <td>12 May 2020</td>
- <td>There 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.</td>
- <td><strong><span class="text-primary">RESOLVED</span></strong></td>
- </tr>
- <tr>
- <td>Corruption of main database</td>
- <td>8 December 2019</td>
- <td>Weather 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.</td>
- <td><strong><span class="text-warning">UNRESOLVED</span></strong></td>
- </tr>
- </table>
- <button class="btn btn-primary">Report an incident</button>
+ </table>
+ <button class="btn btn-primary">Report an incident</button>
+ </div>
</div>
<hr>
- <div class="col md-12">
- <h2>Audits and Inspections</h2>
- <p>No recent audits or inspections<br>
- No audits or inspections currently scheduled</p>
+ <div class="row">
+ <div class="col md-12">
+ <h2>Audits and Inspections</h2>
+ <p>No recent audits or inspections<br>
+ No audits or inspections currently scheduled</p>
+ </div>
</div>
- <h2>NIS systems</h2>
- <p>Table of NIS systems here...</p>
+ <hr>
+
+ <div class="row">
+ <div class="col md-12">
+ <h2>NIS systems</h2>
+ <table class="table">
+ <thead>
+ <tr>
+ <th scope="col">System Name</th>
+ <th scope="col">Description</th>
+ <th scope="col">CAF</th>
+ </tr>
+ </thead>
+ {% for system in systems %}
+ <tr>
+ <td>{{ system.name }}</td>
+ <td>{{ system.description }}</td>
+ <td>{{ system.caf }}</td>
+ </tr>
+ {% endfor %}
+ </table>
+ </div>
+ </div>
- <h2>DfT Engagement</h2>
- <p>No engagement with DfT currently scheduled</p>
+ <hr>
+
+ <div class="row">
+ <div class="col md-12">
+ <h2>DfT Engagement</h2>
+ <p>No engagement with DfT currently scheduled</p>
+ </div>
+ </div>
</div>
</div>
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(