summaryrefslogtreecommitdiffstats
path: root/expo/models_logbooks.py
diff options
context:
space:
mode:
authorsubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-05-13 05:24:37 +0100
committersubstantialnoninfringinguser <substantialnoninfringinguser@gmail.com>2009-05-13 05:24:37 +0100
commit8c818906b5c1228a6fb411cb96d1bd5f1663b49a (patch)
tree29e5d099b102f2a61fe40288fc5415ba8bf8e70e /expo/models_logbooks.py
parent1d8f647699a3f5f489f46dba595e03fc613cb4e3 (diff)
downloadtroggle-8c818906b5c1228a6fb411cb96d1bd5f1663b49a.tar.gz
troggle-8c818906b5c1228a6fb411cb96d1bd5f1663b49a.tar.bz2
troggle-8c818906b5c1228a6fb411cb96d1bd5f1663b49a.zip
[svn] Added QM model and parser. Had to merge models_cave.py and models_logbooks.py into models.py. This is because logbook entries now have an optional foreign key to caves, and QMs have a required foreign key to a logbook entry of the trip that created them. So, the two files became circularly dependent.
Also, the urls for the person model now allow lookups using their actual first and last name in the url instead of the primary key. We should do similar things for all models, maybe even using the url as a search which results in a page with multiple model instance results if the input is ambiguous (e.g. they only enter a first name). Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8093 by aaron @ 12/13/2008 11:17 PM
Diffstat (limited to 'expo/models_logbooks.py')
-rw-r--r--expo/models_logbooks.py82
1 files changed, 0 insertions, 82 deletions
diff --git a/expo/models_logbooks.py b/expo/models_logbooks.py
deleted file mode 100644
index 89f2125..0000000
--- a/expo/models_logbooks.py
+++ /dev/null
@@ -1,82 +0,0 @@
-from django.db import models
-from django.contrib import admin
-from django.forms import ModelForm
-
-class Expedition(models.Model):
- year = models.CharField(max_length=20, unique=True)
- name = models.CharField(max_length=100)
- start_date = models.DateField(blank=True,null=True)
- end_date = models.DateField(blank=True,null=True)
-
- def __unicode__(self):
- return self.year
-
- def GetPersonExpedition(self, name):
- person_expeditions = PersonExpedition.objects.filter(expedition=self)
- res = None
- for person_expedition in person_expeditions:
- for possible_name_from in person_expedition.GetPossibleNameForms():
- #print "nnn", possiblenamefrom
- if name == possible_name_from:
- assert not res, "Ambiguous: " + name
- res = person_expedition
- return res
-
-
-class Person(models.Model):
- first_name = models.CharField(max_length=100)
- last_name = models.CharField(max_length=100)
- is_vfho = models.BooleanField()
- mug_shot = models.CharField(max_length=100, blank=True,null=True)
- def __unicode__(self):
- return "%s %s" % (self.first_name, self.last_name)
-
-class PersonExpedition(models.Model):
- expedition = models.ForeignKey(Expedition)
- person = models.ForeignKey(Person)
- from_date = models.DateField(blank=True,null=True)
- to_date = models.DateField(blank=True,null=True)
- is_guest = models.BooleanField()
- nickname = models.CharField(max_length=100,blank=True,null=True)
-
- def GetPossibleNameForms(self):
- res = [ ]
- if self.person.last_name:
- res.append("%s %s" % (self.person.first_name, self.person.last_name))
- res.append("%s %s" % (self.person.first_name, self.person.last_name[0]))
- res.append(self.person.first_name)
- if self.nickname:
- res.append(self.nickname)
- return res
-
- def __unicode__(self):
- return "%s: (%s)" % (self.person, self.expedition)
-
-
-class LogbookEntry(models.Model):
- date = models.DateField()
- author = models.ForeignKey(PersonExpedition,blank=True,null=True) # the person who writes it up doesn't have to have been on the trip
- title = models.CharField(max_length=200)
-
- # this will be a foreign key of the place the logbook is describing
- place = models.CharField(max_length=100,blank=True,null=True)
- text = models.TextField()
-
- # several PersonTrips point in to this object
-
- def __unicode__(self):
- return "%s: (%s)" % (self.date, self.title)
-
-class PersonTrip(models.Model):
- person_expedition = models.ForeignKey(PersonExpedition)
-
- # this will be a foreign key of the place(s) the trip went through
- # possibly a trip has a plurality of triplets pointing into it
- place = models.CharField(max_length=100)
- date = models.DateField()
- time_underground = models.CharField(max_length=100)
- logbook_entry = models.ForeignKey(LogbookEntry)
- is_logbook_entry_author = models.BooleanField()
-
- def __unicode__(self):
- return "%s %s (%s)" % (self.person_expedition, self.place, self.date) \ No newline at end of file