From ff9bca1e618e46b0c70f204314a363cafc82a3a1 Mon Sep 17 00:00:00 2001 From: Tom Price Date: Thu, 22 Jan 2015 20:48:37 +0000 Subject: [PATCH] Moved the table element from the main rigboard out to something reusuable. Added the ability to view organisations by people and vice versa, as well as the option to see all the rigs associated with orgs/people/venues. Added helper properties for the above --- PyRIGS/settings.py | 2 + RIGS/models.py | 28 +++++++ RIGS/templates/RIGS/event_table.html | 85 +++++++++++++++++++ RIGS/templates/RIGS/organisation_detail.html | 84 ++++++++++++------- RIGS/templates/RIGS/person_detail.html | 26 +++++- RIGS/templates/RIGS/rigboard.html | 86 +------------------- RIGS/templates/RIGS/venue_detail.html | 8 ++ 7 files changed, 200 insertions(+), 119 deletions(-) create mode 100644 RIGS/templates/RIGS/event_table.html diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index 1f6bdbfe..9a9fefda 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -25,6 +25,8 @@ TEMPLATE_DEBUG = True ALLOWED_HOSTS = [] +INTERNAL_IPS = ['127.0.0.1', '10.20.30.20'] + # Application definition diff --git a/RIGS/models.py b/RIGS/models.py index ff674c76..49ce3394 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -52,6 +52,18 @@ class Person(models.Model, RevisionMixin): string += "*" return string + @property + def organisations(self): + o = [] + for e in self.event_set.all(): + if e.organisation and e.organisation not in o: + o.append(e.organisation) + return o + + @property + def latest_events(self): + return self.event_set.order_by('-start_date') + class Meta: permissions = ( ('view_person', 'Can view Persons'), @@ -75,6 +87,18 @@ class Organisation(models.Model, RevisionMixin): string += "*" return string + @property + def persons(self): + p = [] + for e in self.event_set.all(): + if e.person and e.person not in p: + p.append(e.person) + return p + + @property + def latest_events(self): + return self.event_set.order_by('-start_date') + class Meta: permissions = ( ('view_organisation', 'Can view Organisations'), @@ -131,6 +155,10 @@ class Venue(models.Model, RevisionMixin): string += "*" return string + @property + def latest_events(self): + return self.event_set.order_by('-start_date') + class Meta: permissions = ( ('view_venue', 'Can view Venues'), diff --git a/RIGS/templates/RIGS/event_table.html b/RIGS/templates/RIGS/event_table.html new file mode 100644 index 00000000..5452b53b --- /dev/null +++ b/RIGS/templates/RIGS/event_table.html @@ -0,0 +1,85 @@ +
+ + + + + + + + + + {% for event in events %} + + + + + + + + {% endfor %} + +
Event DateEvent DetailsEvent TimingsMIC
+
{{ event.start_date|date:"SHORT_DATE_FORMAT" }}
+ {% if event.end_date and event.end_date != event.start_date %} +
{{ event.end_date|date:"SHORT_DATE_FORMAT" }}
+ {% endif %} +
+

+ {{ event.name }} + {% if event.venue %} + at {{ event.venue }} + {% endif %} +

+ {% if event.is_rig %} +
+ {{ event.person.name }} + {% if event.organisation %} + for {{ event.organisation.name }} + {% endif %} +
+ {% endif %} + {% if not event.cancelled and event.description %} +
+ {{ event.description|linebreaksbr }} +
+ {% endif %} +
+
+ {% if event.meet_at %} +
Crew meet
+
{{ event.meet_at|date:"H:i" }}
{{ event.meet_at|date:"(Y-m-d)" }}
+ {% endif %} + {% if event.start_time %} +
Event starts
+
+ {{ event.start_time|date:"H:i" }}
+ {{ event.start_date|date:"(Y-m-d)" }} +
+ {% endif %} + {% if event.end_time and event.start_time != event.end_time %} +
Event ends
+
+ {{ event.end_time|date:"H:i" }}
+ {{ event.end_date|date:"(Y-m-d)" }} +
+ {% endif %} +
+
+ {% if event.mic or not event.is_rig %} + {{ event.mic.initials }} + {% else %} + + {% endif %} +
+
\ No newline at end of file diff --git a/RIGS/templates/RIGS/organisation_detail.html b/RIGS/templates/RIGS/organisation_detail.html index 3bb4b479..b524d422 100644 --- a/RIGS/templates/RIGS/organisation_detail.html +++ b/RIGS/templates/RIGS/organisation_detail.html @@ -4,38 +4,61 @@ {% block title %}{{ object.name }}{% endblock %} {% block content %} -
-
- {% if not request.is_ajax %} + {% if not request.is_ajax %} +
+

{{ object.name }}
- Last edited {{ object.last_edited_at }} by {{ object.last_edited_by }} + Last edited {{ object.last_edited_at }} by {{ object.last_edited_by.name }}

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

Details

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

People

+ +
+
+ +
+
+

Events

+ {% with object.latest_events as events %} + {% include 'RIGS/event_table.html' %} + {% endwith %}
{% endblock %} @@ -44,7 +67,8 @@ {% block footer %}
- Lasted edited at {{ object.last_edited_at|date:"SHORT_DATE_FORMAT" }} by {{ object.last_edited_by }} + Lasted edited at {{ object.last_edited_at|date:"SHORT_DATE_FORMAT" }} + by {{ object.last_edited_by.name }}
diff --git a/RIGS/templates/RIGS/person_detail.html b/RIGS/templates/RIGS/person_detail.html index 403584a5..a389ba75 100644 --- a/RIGS/templates/RIGS/person_detail.html +++ b/RIGS/templates/RIGS/person_detail.html @@ -5,13 +5,14 @@ {% block content %}
-
+
+

Details

{% if not request.is_ajax %}

{{ object.name }}
- Last edited {{ object.last_edited_at }} by {{ object.last_edited_by }} + Last edited {{ object.last_edited_at }} by {{ object.last_edited_by.name }}

{% endif %} @@ -34,6 +35,23 @@
+
+

Organisations

+ +
+
+ +
+
+

Events

+ {% with object.latest_events as events %} + {% include 'RIGS/event_table.html' %} + {% endwith %} +
{% endblock %} @@ -41,7 +59,7 @@ {% block footer %}
- Lasted edited at {{ object.last_edited_at|date:"SHORT_DATE_FORMAT" }} by {{ user }} + Lasted edited at {{ object.last_edited_at|date:"SHORT_DATE_FORMAT" }} by {{ object.last_edited_by.name }}
diff --git a/RIGS/templates/RIGS/rigboard.html b/RIGS/templates/RIGS/rigboard.html index 83bf6ad4..07d26bfc 100644 --- a/RIGS/templates/RIGS/rigboard.html +++ b/RIGS/templates/RIGS/rigboard.html @@ -27,91 +27,7 @@
{# .row #} -
- - - - - - - - - - {% for event in events %} - - - - - - - - {% endfor %} - -
Event DateEvent DetailsEvent TimingsMIC
-
{{ event.start_date|date:"SHORT_DATE_FORMAT" }}
- {% if event.end_date and event.end_date != event.start_date %} -
{{ event.end_date|date:"SHORT_DATE_FORMAT" }}
- {% endif %} -
-

- {{ event.name }} - {% if event.venue %} - at {{ event.venue }} - {% endif %} -

- {% if event.is_rig %} -
- {{ event.person.name }} - {% if event.organisation %} - for {{ event.organisation.name }} - {% endif %} -
- {% endif %} - {% if not event.cancelled and event.description %} -
- {{ event.description|linebreaksbr }} -
- {% endif %} -
-
- {% if event.meet_at %} -
Crew meet
-
{{ event.meet_at|date:"H:i" }}
{{ event.meet_at|date:"(Y-m-d)" }}
- {% endif %} - {% if event.start_time %} -
Event starts
-
- {{ event.start_time|date:"H:i" }}
- {{ event.start_date|date:"(Y-m-d)" }} -
- {% endif %} - {% if event.end_time and event.start_time != event.end_time %} -
Event ends
-
- {{ event.end_time|date:"H:i" }}
- {{ event.end_date|date:"(Y-m-d)" }} -
- {% endif %} -
-
- {% if event.mic or not event.is_rig %} - {{ event.mic.initials }} - {% else %} - - {% endif %} -
-
+ {% include 'RIGS/event_table.html' %}
{% endblock %} \ No newline at end of file diff --git a/RIGS/templates/RIGS/venue_detail.html b/RIGS/templates/RIGS/venue_detail.html index 7b74e2c0..c5bb8478 100644 --- a/RIGS/templates/RIGS/venue_detail.html +++ b/RIGS/templates/RIGS/venue_detail.html @@ -35,6 +35,14 @@
+ +
+
+ {% with object.latest_events as events %} + {% include 'RIGS/event_table.html' %} + {% endwith %} +
+
{% endblock %} {% if request.is_ajax %}