From 264594ed05b2723f443798a326d07afbbdaf185f Mon Sep 17 00:00:00 2001 From: substantialnoninfringinguser Date: Wed, 13 May 2009 05:44:35 +0100 Subject: [PATCH] [svn] made index of people Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8224 by julian @ 1/24/2009 6:26 PM --- expo/models.py | 14 +++++++++++++ expo/views_logbooks.py | 8 +++++++- expo/views_other.py | 2 +- media/css/main2.css | 2 +- parsers/people.py | 19 ++++++++++++------ templates/base.html | 5 +---- templates/index.html | 2 +- templates/person.html | 26 +++++++----------------- templates/personexpedition.html | 1 + templates/personindex.html | 35 ++++++++++++++------------------- 10 files changed, 61 insertions(+), 53 deletions(-) diff --git a/expo/models.py b/expo/models.py index b8885ea..50140aa 100644 --- a/expo/models.py +++ b/expo/models.py @@ -19,6 +19,9 @@ class Expedition(models.Model): def __unicode__(self): return self.year + class Meta: + ordering = ('year',) + def GuessDateFrom(self): try: return self.logbookentry_set.order_by('date')[0].date @@ -71,12 +74,20 @@ class Person(models.Model): class Meta: verbose_name_plural = "People" + class Meta: + ordering = ('last_name', 'first_name') def __unicode__(self): if self.last_name: return "%s %s" % (self.first_name, self.last_name) return self.first_name + # these ought to be possible by piping through |min in the template, or getting the first of an ordered list + def Firstexpedition(self): + return self.personexpedition_set.order_by('expedition')[0] + def Lastexpedition(self): + return self.personexpedition_set.order_by('-expedition')[0] + class PersonExpedition(models.Model): expedition = models.ForeignKey(Expedition) @@ -96,6 +107,9 @@ class PersonExpedition(models.Model): print res return res + class Meta: + ordering = ('expedition',) + def GetPersonChronology(self): res = { } for persontrip in self.persontrip_set.all(): diff --git a/expo/views_logbooks.py b/expo/views_logbooks.py index 7d18ba1..72c44e8 100644 --- a/expo/views_logbooks.py +++ b/expo/views_logbooks.py @@ -10,7 +10,13 @@ import re def personindex(request): persons = Person.objects.all() - return render_to_response('personindex.html', {'persons': persons, 'settings': settings}) + + personss = [ ] + ncols = 5 + nc = (len(persons) + ncols - 1) / ncols + for i in range(ncols): + personss.append(persons[i * nc: (i + 1) * nc]) + return render_to_response('personindex.html', {'persons': persons, 'personss':personss, 'settings': settings}) def expedition(request, expeditionname): year = int(expeditionname) diff --git a/expo/views_other.py b/expo/views_other.py index 7d5d655..7c5fc92 100644 --- a/expo/views_other.py +++ b/expo/views_other.py @@ -28,7 +28,7 @@ def frontPage(request): message = "Reloaded survexblocks" #'randSent':randSent.randomLogbookSentence(), - expeditions = Expedition.objects.all() + expeditions = Expedition.objects.order_by("-year") return render_to_response('index.html', {'expeditions':expeditions, 'settings':settings, "message":message}) def calendar(request,year): diff --git a/media/css/main2.css b/media/css/main2.css index b07c65c..4f827b3 100644 --- a/media/css/main2.css +++ b/media/css/main2.css @@ -129,7 +129,7 @@ table.expeditionlogbooks td ul#expeditionlist { - width: 300px + width: 800px } div.survexblock diff --git a/parsers/people.py b/parsers/people.py index 93d8a0e..4a2ea11 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -91,7 +91,7 @@ def LoadPersonsExpos(): is_guest = person[header["Guest"]] == "1" # this is really a per-expo catagory; not a permanent state pObject.save() - parseMugShotAndBlurb(firstname, lastname, person, header, pObject) + #parseMugShotAndBlurb(firstname, lastname, person, header, pObject) for year, attended in zip(headers, person)[5:]: yo = models.Expedition.objects.filter(year = year)[0] @@ -111,11 +111,18 @@ def LoadPersonsExpos(): firstname, lastname = name.split() is_guest = name in ["Eeva Makiranta", "Keith Curtis"] print "2008:", name - pObject = models.Person(first_name = firstname, - last_name = lastname, - is_vfho = False, - mug_shot = "") - pObject.save() + persons = list(models.Person.objects.filter(first_name=firstname, last_name=lastname)) + if not persons: + pObject = models.Person(first_name = firstname, + last_name = lastname, + is_vfho = False, + mug_shot = "") + pObject.href = firstname.lower() + if lastname: + pObject.href += "_" + lastname.lower() + pObject.save() + else: + pObject = persons[0] yo = models.Expedition.objects.filter(year = "2008")[0] pyo = models.PersonExpedition(person = pObject, expedition = yo, nickname="", is_guest=is_guest) pyo.save() diff --git a/templates/base.html b/templates/base.html index 36ae852..5357af1 100644 --- a/templates/base.html +++ b/templates/base.html @@ -15,10 +15,7 @@
-

CUCC Expeditions to Austria: 1976 -

-
-

1976

-
+

CUCC Expeditions to Austria: 1976 - 2008


diff --git a/templates/index.html b/templates/index.html index bc0bfa9..cafc8a8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -27,8 +27,8 @@

{{message}}