From 30935c7d082fa662fc83ed3dea38cd96fcb276ed Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Fri, 11 Sep 2020 15:42:05 +0100 Subject: working on Person detail page --- ctrack/organisations/models.py | 3 + .../templates/organisations/person_detail.html | 73 ++++++++++++++++++++++ .../templates/organisations/person_list.html | 2 +- ctrack/organisations/urls.py | 2 + ctrack/organisations/views.py | 5 ++ 5 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 ctrack/organisations/templates/organisations/person_detail.html (limited to 'ctrack/organisations') diff --git a/ctrack/organisations/models.py b/ctrack/organisations/models.py index f91dabf..e256eb1 100644 --- a/ctrack/organisations/models.py +++ b/ctrack/organisations/models.py @@ -90,6 +90,9 @@ class Person(models.Model): def get_organisation_name(self): return self.organisation.name + def get_full_name(self): + return " ".join([self.first_name, self.last_name]) + class Meta: verbose_name_plural = "People" diff --git a/ctrack/organisations/templates/organisations/person_detail.html b/ctrack/organisations/templates/organisations/person_detail.html new file mode 100644 index 0000000..dea84aa --- /dev/null +++ b/ctrack/organisations/templates/organisations/person_detail.html @@ -0,0 +1,73 @@ +{% extends "base.html" %} + +{% block title %} +{{ person.get_full_name }} +{% endblock %} + +{% block content %} + + +
+
+

{{ person.get_full_name }}

+
+
+
{{ person.organisation.name }}
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name{{ person.get_full_name }}
Job Title{{ person.job_title }}
Organisation{{ person.organisation.name }}
Role{{ person.role.name }}
NIS Primary Point of Contact{{ person.primary_nis_contact }}
Voluntary Point of Contact{{ person.voluntary_point_of_contact }}
Has Egress{{ person.has_egress }}
Email{{ person.email }}
Secondary Email{{ person.secondary_email }}
Mobile Phone{{ person.mobile }}
Land line{{ person.landline }}
Update{{ person.date_updated }}
+
+
+
+ +{% endblock content %} diff --git a/ctrack/organisations/templates/organisations/person_list.html b/ctrack/organisations/templates/organisations/person_list.html index 53e812a..4c147c3 100644 --- a/ctrack/organisations/templates/organisations/person_list.html +++ b/ctrack/organisations/templates/organisations/person_list.html @@ -28,7 +28,7 @@ {% for p in object_list %} - {{ p.first_name }} {{ p.last_name }} + {{ p.first_name }} {{ p.last_name }} {{ p.organisation.name }} {{ p.mobile }} {{ p.email }} diff --git a/ctrack/organisations/urls.py b/ctrack/organisations/urls.py index ba13465..b5dadee 100644 --- a/ctrack/organisations/urls.py +++ b/ctrack/organisations/urls.py @@ -7,6 +7,7 @@ from ctrack.organisations.views import ( OrganisationListView, PersonListView, essential_service_detail, + person_detail, ) app_name = "organisations" @@ -26,5 +27,6 @@ urlpatterns = [ essential_service_detail, name="essential_service_detail", ), + path("person/", person_detail, name="person-detail"), # path("create", view=OrganisationCreate.as_view(), name="create") ] diff --git a/ctrack/organisations/views.py b/ctrack/organisations/views.py index eb264ca..7171fab 100644 --- a/ctrack/organisations/views.py +++ b/ctrack/organisations/views.py @@ -28,6 +28,11 @@ class PersonListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): permission_required = "organisations.view_person" +def person_detail(request, person_id): + p = get_object_or_404(Person, pk=person_id) + return render(request, "organisations/person_detail.html", {"person": p}) + + class OrganisationCreate(LoginRequiredMixin, PermissionRequiredMixin, CreateView): model = Organisation template_name = "organisations/org_create_formset.html" -- cgit v1.2.3