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 @@
{{person|wiki_to_html_short}} has been on expo in the following years:
+{% for personexpedition in person.personexpedition_set.all %} -
- {{personexpedition.expedition}} - |
-
-
-
|
Main page for expedition: {{personexpedition.expedition}}
+Main page for person: {{personexpedition.person}}
List of other expos by this person
diff --git a/templates/personindex.html b/templates/personindex.html index ca8b9b5..c328628 100644 --- a/templates/personindex.html +++ b/templates/personindex.html @@ -5,28 +5,23 @@ {% block content %} +
+
{{person|wiki_to_html_short}} |
+ {{person.Firstexpedition.expedition.year}} |
+ {{person.Lastexpedition.expedition.year}} |
+ |
{% endfor %}
+