diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2020-09-11 15:42:05 +0100 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2020-09-11 15:42:05 +0100 |
commit | 30935c7d082fa662fc83ed3dea38cd96fcb276ed (patch) | |
tree | 37495bd128708a4b8c42c70149dbb110f6e79ecc | |
parent | 5f9f280f177a4154366b6b28f9c87a9b9f4851d7 (diff) |
working on Person detail page
-rw-r--r-- | ctrack/organisations/models.py | 3 | ||||
-rw-r--r-- | ctrack/organisations/templates/organisations/person_detail.html | 73 | ||||
-rw-r--r-- | ctrack/organisations/templates/organisations/person_list.html | 2 | ||||
-rw-r--r-- | ctrack/organisations/urls.py | 2 | ||||
-rw-r--r-- | ctrack/organisations/views.py | 5 |
5 files changed, 84 insertions, 1 deletions
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 %} + + +<div class="container mt-3"> + <div class="row"> + <h3>{{ person.get_full_name }}</h3> + </div> + <div class="row"> + <h5>{{ person.organisation.name }}</h5> + </div> + <div class="row"> + <div class="col-md-12 my-2"> + <table class="table table-sm table-bordered"> + <tr> + <td><strong>Name</strong></td> + <td>{{ person.get_full_name }}</td> + </tr> + <tr> + <td>J<strong>ob Title</strong></td> + <td>{{ person.job_title }}</td> + </tr> + <tr> + <td><strong>Organisation</strong></td> + <td>{{ person.organisation.name }}</td> + </tr> + <tr> + <td><strong>Role</strong></td> + <td>{{ person.role.name }}</td> + </tr> + <tr> + <td><strong>NIS Primary Point of Contact</strong></td> + <td>{{ person.primary_nis_contact }}</td> + </tr> + <tr> + <td><strong>Voluntary Point of Contact</strong></td> + <td>{{ person.voluntary_point_of_contact }}</td> + </tr> + <tr> + <td><strong>Has Egress</strong></td> + <td>{{ person.has_egress }}</td> + </tr> + <tr> + <td><strong>Email</strong></td> + <td>{{ person.email }}</td> + </tr> + <tr> + <td><strong>Secondary Email</strong></td> + <td>{{ person.secondary_email }}</td> + </tr> + <tr> + <td><strong>Mobile Phone</strong></td> + <td>{{ person.mobile }}</td> + </tr> + <tr> + <td><strong>Land line</strong></td> + <td>{{ person.landline }}</td> + </tr> + <tr> + <td><strong>Update</strong></td> + <td>{{ person.date_updated }}</td> + </tr> + </table> + </div> + </div> +</div> + +{% 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 @@ </thead> {% for p in object_list %} <tr> - <td><a href="#">{{ p.first_name }} {{ p.last_name }}</a></td> + <td><a href="{% url "organisations:person-detail" p.pk %}">{{ p.first_name }} {{ p.last_name }}</a></td> <td><a href="{% url "organisations:detail" p.organisation.slug %}">{{ p.organisation.name }}</a></td> <td>{{ p.mobile }}</td> <td><a href="mailto:{{ p.email }}">{{ p.email }}</a></td> 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/<int:person_id>", 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" |