From a89139763f2b7206dc8962aa91ac41866cb71981 Mon Sep 17 00:00:00 2001
From: substantialnoninfringinguser <substantialnoninfringinguser@gmail.com>
Date: Fri, 3 Jul 2009 00:50:56 +0100
Subject: [PATCH] [svn] Use template block "related" for related objects.
 Various cleanup, fix personexpedition date views.

---
 core/models.py                  |  7 ++-----
 media/css/main3.css             |  5 +++++
 templates/base.html             | 10 ++++++++--
 templates/cave.html             |  9 +++++----
 templates/expedition.html       | 15 +++++++++------
 templates/frontpage.html        | 12 ++++++------
 templates/logbookentry.html     |  2 +-
 templates/logbooksearch.html    | 21 ---------------------
 templates/personexpedition.html |  3 ++-
 templates/qm.html               | 12 ++++--------
 templates/subcave.html          | 29 ++++++++++++++---------------
 11 files changed, 56 insertions(+), 69 deletions(-)
 delete mode 100644 templates/logbooksearch.html

diff --git a/core/models.py b/core/models.py
index fa961ed..8778aa1 100644
--- a/core/models.py
+++ b/core/models.py
@@ -180,7 +180,7 @@ class PersonExpedition(TroggleModel):
     def GetPersonChronology(self):
         res = { }
         for persontrip in self.persontrip_set.all():
-            a = res.setdefault(persontrip.date, { })
+            a = res.setdefault(persontrip.date(), { })
             a.setdefault("persontrips", [ ]).append(persontrip)
         for personrole in self.personrole_set.all():
             a = res.setdefault(personrole.survex_block.date, { })
@@ -236,7 +236,7 @@ class PersonExpedition(TroggleModel):
 class LogbookEntry(TroggleModel):
     date    = models.DateField()
     expedition  = models.ForeignKey(Expedition,blank=True,null=True)  # yes this is double-
-    author  = models.ForeignKey(PersonExpedition,blank=True,null=True)  # the person who writes it up doesn't have to have been on the trip.
+      = models.ForeignKey(PersonExpedition,blank=True,null=True)  # the person who writes it up doesn't have to have been on the trip.
     # Re: the above- so this field should be "typist" or something, not "author". - AC 15 jun 09
     title   = models.CharField(max_length=200)
     cave    = models.ForeignKey('Cave',blank=True,null=True)
@@ -287,9 +287,6 @@ class PersonTrip(TroggleModel):
         else:
             return self.logbook_entry.place
 
-    #persontrip_next  = models.ForeignKey('PersonTrip', related_name='pnext', blank=True,null=True)
-    #persontrip_prev  = models.ForeignKey('PersonTrip', related_name='pprev', blank=True,null=True)
-
     def __unicode__(self):
         return "%s %s (%s)" % (self.person_expedition, self.place(), self.date())
 
diff --git a/media/css/main3.css b/media/css/main3.css
index 17779bd..fae73df 100644
--- a/media/css/main3.css
+++ b/media/css/main3.css
@@ -405,6 +405,11 @@ div#related
 	color:#666666;
 }
 
+div#related table
+{
+	border-collapse:separate
+}
+
 .addlink {
     padding-left: 12px;
     background: url(../icon_addlink.gif) 0 .2em no-repeat;
diff --git a/templates/base.html b/templates/base.html
index 4fc24c5..9813c7e 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -13,7 +13,7 @@
 
 {% block head %}{% endblock %}
 </head>
-<body>
+<body onLoad="contentHeight();">
 
 <div id="header"> 
   <h1>CUCC Expeditions to Austria: 1976 - 2009</h1>
@@ -38,12 +38,18 @@
   {% endblock %}
 </div>
  
+
  
-  <div id="content" >
+<div id="content" >
 
   	{% block contentheader %}
     {% endblock %}
 
+<div id="related"> 
+{% block related %}
+{% endblock %}
+</div>
+
     {% block content %}
     REPLACE : The content
     {% endblock %}
diff --git a/templates/cave.html b/templates/cave.html
index 8aaea22..9469118 100644
--- a/templates/cave.html
+++ b/templates/cave.html
@@ -1,10 +1,9 @@
 {% extends "cavebase.html" %}
 {% load wiki_markup %}
 {% block editLink %}| <a href={{cave.get_admin_url}}>Edit cave {{cave|wiki_to_html_short}}</a>{% endblock %}
-{% block content %}
 
-<div id="col2">
-  <h3>All logbook entries regarding this cave ({{cave.logbookentry_set.count}})</h3>
+{% block related %}
+  <h2>All logbook entries regarding this cave ({{cave.logbookentry_set.count}})</h2>
   <table>
   {% for logbookentry in cave.logbookentry_set.all %}
   {% if logbookentry.title %}
@@ -15,7 +14,9 @@
   {% endif %}
   {% endfor %}
   </table>
-</div>
+{% endblock %}
+
+{% block content %}
 
 {% if cave.entrances %}
     <h2>Entrances</h2>
diff --git a/templates/expedition.html b/templates/expedition.html
index 4f91abd..d208b7d 100644
--- a/templates/expedition.html
+++ b/templates/expedition.html
@@ -1,16 +1,15 @@
 {% extends "base.html" %}
 {% load wiki_markup %}
+{% load link %}
 
 {% block title %}Expedition {{expedition.name}}{% endblock %}
 {% block editLink %}<a href={{expedition.get_admin_url}}>Edit expedition {{expedition|wiki_to_html_short}}</a>{% endblock %}
-{% block content %}
-<h2>{{expedition.name}}: {{expedition.date_from}} - {{expedition.date_to}}</h2>
 
-<div id="col2">
+{% block related %}
 <table class="prevnextexpeditions">
 <tr>
-  <td>{% if expedition_prev %}&lt; &lt; <a href="{{ expedition_prev.get_absolute_url }}">{{expedition_prev.year}}</a>{% endif %}</td>
-  <td>{% if expedition_next %}&gt; &gt; <a href="{{ expedition_next.get_absolute_url }}">{{expedition_next.year}}</a>{% endif %}</td>
+  <td>{% if expedition_prev %}&lt; &lt; {{ expedition_prev|link }} {% endif %}</td>
+  <td>{% if expedition_next %}&gt; &gt; {{ expedition_next|link }} {% endif %}</td>
 </tr>
 </ul>
 
@@ -24,7 +23,11 @@
   </tr>
 {% endfor %}
 </table>
-</div>
+{% endblock %}
+
+{% block content %}
+<h2>{{expedition.name}}: {{expedition.date_from}} - {{expedition.date_to}}</h2>
+
 
 <div id="col1">
 <h3>Logbook entries</h3>
diff --git a/templates/frontpage.html b/templates/frontpage.html
index bf04709..873f198 100644
--- a/templates/frontpage.html
+++ b/templates/frontpage.html
@@ -3,11 +3,7 @@
 
 {% block title %}Cambridge Expeditions to Austria{% endblock %}
 
-
-
-{% block content %}
-
-    <div id="related">
+	{% block related %}
         <h2>Recent Actions</h2>
             {% load log %}
             {% get_admin_log 10 as admin_log %}
@@ -32,7 +28,11 @@
             {% endfor %}
             </ul>
             {% endif %}
-    </div>
+	{% endblock %}
+
+{% block content %}
+
+
 
 
 <div id="col1">
diff --git a/templates/logbookentry.html b/templates/logbookentry.html
index 89069e8..9e632a4 100644
--- a/templates/logbookentry.html
+++ b/templates/logbookentry.html
@@ -7,7 +7,7 @@
 
 <h2>{{logbookentry.title|safe}}</h2>
 
-<div id="col2">
+<div id="related">
 <p><a href="{{ logbookentry.expedition.get_absolute_url }}">{{logbookentry.expedition.name}}</a></p>
 
 {% if logbookentry.cave %}
diff --git a/templates/logbooksearch.html b/templates/logbooksearch.html
deleted file mode 100644
index 2fc00f8..0000000
--- a/templates/logbooksearch.html
+++ /dev/null
@@ -1,21 +0,0 @@
-{% extends "base.html" %}
-{% load wiki_markup %}
-{% block title %}Logbook search results for "{{ query_string }}"{% endblock%}
-
-{% block content %}
-
-<h1> Troggle logbook search </h1>
-
-<p>Your search string, <b>{{ query_string }}</b>, 
-
-{% if found_entries %}
-	was found in the following <b>{{entry.count}}</b> logbook titles and / or entries:</p>
-	<ul>
-		{% for entry in found_entries %}
-			<li><a href="{{ settings.URL_ROOT }}logbookentry/{{ entry.pk }}">{{ entry|wiki_to_html_short  }} </a></li>
-		{% endfor %}
-	</ul>
-	{% else %}
-		was not found in any logbook titles and / or entries. Please try again.
-	{% endif %}
-{% endblock %}
\ No newline at end of file
diff --git a/templates/personexpedition.html b/templates/personexpedition.html
index 4b762a4..a0245aa 100644
--- a/templates/personexpedition.html
+++ b/templates/personexpedition.html
@@ -1,5 +1,6 @@
 {% extends "base.html" %}
 {% load wiki_markup %}
+{% load link %}
 
 {% block title %}Person {{personexpedition.person|wiki_to_html_short}} for {{personexpedition.expedition}}{% endblock %}
 
@@ -18,7 +19,7 @@
 {% ifequal otherpersonexpedition personexpedition %}
   | <b>{{otherpersonexpedition.expedition.year}}</b>
 {% else %}
-  | <a href="{{ otherpersonexpedition.get_absolute_url }}">{{otherpersonexpedition.expedition.year}}</a>
+  | {{ otherpersonexpedition|link }}
 {% endifequal %}
 {% endfor %}
 </p>
diff --git a/templates/qm.html b/templates/qm.html
index 52413f0..6e2a2fb 100644
--- a/templates/qm.html
+++ b/templates/qm.html
@@ -18,18 +18,14 @@
 </table>
 {% endblock %}
 
-{% block content %}
+{% block related %}
 
-
-<div id="col2">
-
-  <h2>Related items</h2>
+{% endblock %}
+<h2>Related items</h2>
   
 Parent cave: {{qm.found_by.cave|link}}
 (todo: add parent survey and parent subcave)
-
-
-</div>
+{% block content %}
 
 <h3>Location</h3>
 {{qm.location_description}}
diff --git a/templates/subcave.html b/templates/subcave.html
index 4cd9be0..fbb8d1d 100644
--- a/templates/subcave.html
+++ b/templates/subcave.html
@@ -11,20 +11,7 @@
 
 
 {% block content %}
-
-ok here comes the drilldown<br />
-{% drilldown_tree_for_node subcave as drilldown %}
-{% for each in drilldown %}
-{{ each }}>
-{% endfor %}
-
-
-<h2>{{subcave}}</h2>
-<p>
-	{{subcave.description}}
-</p>
-
-<div id="col2">
+{% block related %}
 
   <h2>Related places</h2>
   
@@ -55,6 +42,18 @@ ok here comes the drilldown<br />
   </ul>
 
 
-</div>
+{% endblock %}
+
+ok here comes the drilldown<br />
+{% drilldown_tree_for_node subcave as drilldown %}
+{% for each in drilldown %}
+{{ each }}>
+{% endfor %}
+
+
+<h2>{{subcave}}</h2>
+<p>
+	{{subcave.description}}
+</p>
 
 {% endblock content %}
\ No newline at end of file