summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-10-14 17:46:36 +0100
committerMatthew Lemon <y@yulqen.org>2024-10-14 17:46:36 +0100
commitbbdc85fbc53a914f9375aae0a9f3730a940ded95 (patch)
treea27c2f2ffc319eb91294d9409aa643e51aadd385
parent95507940f12a0a62e2e207b02cecfca2c3c69418 (diff)
We have a basic SOP list view
- added the new url file - styled similar to EP list for organisation - uses a spanned row in the table for a description or summary of the document - TODO: update the model to use the summary row - TODO: add more metadata
-rw-r--r--ded/urls.py2
-rw-r--r--instruments/templates/instruments/sop_list.html53
-rw-r--r--instruments/tests/test_views.py10
-rw-r--r--instruments/urls.py8
-rw-r--r--instruments/views.py9
5 files changed, 81 insertions, 1 deletions
diff --git a/ded/urls.py b/ded/urls.py
index 229fb29..3d7e36c 100644
--- a/ded/urls.py
+++ b/ded/urls.py
@@ -13,6 +13,7 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
+
from django.contrib import admin
from django.urls import include, path
@@ -20,6 +21,7 @@ urlpatterns = [
# path("__debug__", include("debug_toolbar.urls")),
path("accounts/", include("django.contrib.auth.urls")),
path("engagements/", include("engagements.urls")),
+ path("instruments/", include("instruments.urls")),
path("admin/", admin.site.urls),
path("", include("core.urls")),
]
diff --git a/instruments/templates/instruments/sop_list.html b/instruments/templates/instruments/sop_list.html
new file mode 100644
index 0000000..7550ca1
--- /dev/null
+++ b/instruments/templates/instruments/sop_list.html
@@ -0,0 +1,53 @@
+
+{% extends "core/base.html" %}
+
+{% block content %}
+
+
+<div class="flex py-4">
+ <div class="w-1/2 px-4 py-8 my-5 bg-white shadow-md rounded-lg">
+ <header class="bg-blue-100 p-4">
+ <h2 class="text-2xl font-bold">Standard Operating Procedures (SOPs)</h2>
+
+ </header>
+ <div class="p-4 mb-4">
+ <div class="overflow-x-auto">
+ <table class="divide-y divide-gray-200">
+ <thead class="bg-gray-50">
+ <tr>
+ <th scope="col" class="px-2 py-1 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
+ <th scope="col" class="px-2 py-1 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Sharepoint</th>
+ <th scope="col" class="px-2 py-1 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Lead Inspector</th>
+ <th scope="col" class="px-2 py-1 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
+ </tr>
+ </thead>
+ <tbody class="divide-y divide-gray-200">
+ {% for obj in object_list %}
+ <tr>
+ <td class="px-2 py-1 whitespace-nowrap text-m">{{ obj.name }}</td>
+ <td class="px-2 py-1 whitespace-nowrap text-m">{{ obj.sp_link }}</td>
+ <td class="px-2 py-1 whitespace-nowrap text-m">{{ obj.author_lead.fullname }}</td>
+ <td class="px-2 py-1 whitespace-nowrap text-m">{{ obj.draft_status }}</td>
+
+ </tr>
+ <tr>
+ <td colspan="5">
+ <p class="text-sm text-gray-500 px-1 py-2">{% lorem %}</p>
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+
+ </div>
+
+ </div>
+
+
+
+
+ </div>
+
+</div>
+
+{% endblock content %}
diff --git a/instruments/tests/test_views.py b/instruments/tests/test_views.py
new file mode 100644
index 0000000..048ab47
--- /dev/null
+++ b/instruments/tests/test_views.py
@@ -0,0 +1,10 @@
+import pytest
+from django.urls import reverse
+
+pytestmark = pytest.mark.django_db
+
+
+def test_view_url_exists_at_desired_location(client):
+ url = reverse("instruments:sop-list")
+ response = client.get(url)
+ assert response.status_code == 200
diff --git a/instruments/urls.py b/instruments/urls.py
new file mode 100644
index 0000000..4358f91
--- /dev/null
+++ b/instruments/urls.py
@@ -0,0 +1,8 @@
+from django.urls import path
+
+from . import views
+
+app_name = "instruments"
+urlpatterns = [
+ path("sops", views.SOPListView.as_view(), name="sop-list"),
+]
diff --git a/instruments/views.py b/instruments/views.py
index fd0e044..0329e00 100644
--- a/instruments/views.py
+++ b/instruments/views.py
@@ -1,3 +1,10 @@
# from django.shortcuts import render
-# Create your views here.
+from django.views.generic.list import ListView
+
+from .models import SOP
+
+
+class SOPListView(ListView):
+ model = SOP
+ paginate_by = 100