From 4c07298e5e399148c93866d7cbe967aafa0458ab Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 29 Jun 2015 02:25:53 +0100 Subject: [PATCH] Rewrote UI for person and organisation detail pages - now matches design of event_detail and is generally much prettier. Also happens to fix issue #6 --- RIGS/models.py | 17 ++- RIGS/templates/RIGS/organisation_detail.html | 131 +++++++++++-------- RIGS/templates/RIGS/person_detail.html | 122 ++++++++++------- 3 files changed, 169 insertions(+), 101 deletions(-) diff --git a/RIGS/models.py b/RIGS/models.py index 6c4c9c9c..9e04022d 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -9,6 +9,7 @@ from django.utils.encoding import python_2_unicode_compatible import reversion import string import random +from collections import Counter from django.core.urlresolvers import reverse_lazy from decimal import Decimal @@ -91,9 +92,13 @@ class Person(models.Model, RevisionMixin): def organisations(self): o = [] for e in Event.objects.filter(person=self).select_related('organisation'): - if e.organisation and e.organisation not in o: + if e.organisation: o.append(e.organisation) - return o + + #Count up occurances and put them in descending order + c = Counter(o) + stats = c.most_common() + return stats @property def latest_events(self): @@ -131,9 +136,13 @@ class Organisation(models.Model, RevisionMixin): def persons(self): p = [] for e in Event.objects.filter(organisation=self).select_related('person'): - if e.person and e.person not in p: + if e.person: p.append(e.person) - return p + + #Count up occurances and put them in descending order + c = Counter(p) + stats = c.most_common() + return stats @property def latest_events(self): diff --git a/RIGS/templates/RIGS/organisation_detail.html b/RIGS/templates/RIGS/organisation_detail.html index 098d4a42..51e88b7d 100644 --- a/RIGS/templates/RIGS/organisation_detail.html +++ b/RIGS/templates/RIGS/organisation_detail.html @@ -1,82 +1,109 @@ {% extends request.is_ajax|yesno:"base_ajax.html,base.html" %} {% load widget_tweaks %} -{% block title %}{{ object.name }}{% endblock %} +{% block title %}Organisation {{ object.pk|stringformat:"05d" }} |{{ object.name }}{% endblock %} {% block content %} - {% if not request.is_ajax %} -
- -
- Edit -
-
-
-
- {% endif %}
+ {% if not request.is_ajax %} +
+

Organisation {{ object.pk|stringformat:"05d" }} | {{ object.name }}

+
+ +
+
+ Edit +
+
+ {% endif %}
-

Details

-
-
Name
-
{{ object.name }}
+
+
Organisation Details
+
+
+
Name
+
{{ object.name }}
-
Phone
-
{{ object.phone }}
+
Phone
+
{{ object.phone }}
-
Email
-
{{ object.email }}
+
Email
+
{{ object.email }}
-
Address
-
{{ object.address|linebreaksbr }}
+
Address
+
{{ object.address|linebreaksbr }}
-
Notes
-
{{ object.notes|linebreaksbr }}
+
Notes
+
{{ object.notes|linebreaksbr }}
-
Union Account
-
{{ object.union_account|yesno|capfirst }}
-
+
Union Account
+
{{ object.union_account|yesno|capfirst }}
+
+
+
-

People

- +
+
Associated People
+
+
+ {% for person,count in object.persons %} + {{ person.pk|stringformat:"05d" }} | {{ person.name }} {{count}} + {% endfor %} +
+
+
-

Events

- {% with object.latest_events as events %} - {% include 'RIGS/event_table.html' %} - {% endwith %} +
+
Associated Events
+
+ {% with object.latest_events as events %} + {% include 'RIGS/event_table.html' %} + {% endwith %} +
+
+ + + {% if not request.is_ajax %} +
+ +
+ {% endif %} + {% endblock %} {% if request.is_ajax %} {% block footer %}
- -
- diff --git a/RIGS/templates/RIGS/person_detail.html b/RIGS/templates/RIGS/person_detail.html index cd666a7f..ff7346cf 100644 --- a/RIGS/templates/RIGS/person_detail.html +++ b/RIGS/templates/RIGS/person_detail.html @@ -1,74 +1,106 @@ {% extends request.is_ajax|yesno:"base_ajax.html,base.html" %} {% load widget_tweaks %} -{% block title %}{{ object.name }}{% endblock %} +{% block title %}Person {{ object.pk|stringformat:"05d" }} | {{ object.name }}{% endblock %} {% block content %}
-
-

Details

- {% if not request.is_ajax %} -

{{ object.name }}
- - Last edited at {{ object.last_edited_at|date:"d/m/Y H:i" }} by {{ object.last_edited_by.name }} - -

-
- Edit + {% if not request.is_ajax %} +
+

Person {{ object.pk|stringformat:"05d" }} | {{ object.name }}

+
+ +
+ - {% endif %} -
-
-
Name
-
{{ object.name }}
+
+ {% endif %} +
+
+
Person Details
+
+
+
Name
+
{{ object.name }}
-
Phone
-
{{ object.phone }}
+
Phone
+
{{ object.phone }}
-
Email
-
{{ object.email }}
+
Email
+
{{ object.email }}
-
Address
-
{{ object.address|linebreaksbr }}
+
Address
+
{{ object.address|linebreaksbr }}
-
Notes
-
{{ object.notes|linebreaksbr }}
-
+
Notes
+
{{ object.notes|linebreaksbr }}
+ +
+
-

Organisations

- +
+
Associated Organisations
+
+
+ {% for organisation,count in object.organisations %} + {{ organisation.pk|stringformat:"05d" }} | {{ organisation.name }} {{count}} + {% endfor %} +
+
+
-

Events

- {% with object.latest_events as events %} - {% include 'RIGS/event_table.html' %} - {% endwith %} +
+
Associated Events
+
+ {% with object.latest_events as events %} + {% include 'RIGS/event_table.html' %} + {% endwith %} +
+
+ + + {% if not request.is_ajax %} + + {% endif %} + {% endblock %} {% if request.is_ajax %} {% block footer %}