[svn r8076] Djangoed Julians code

added underscores to field names
turned __str__ to __unicode__
This commit is contained in:
julian 2008-11-08 19:24:03 +01:00
parent f08d6b6ecf
commit b85c962575
2 changed files with 104 additions and 102 deletions

View File

@ -8,18 +8,18 @@ class Expedition(models.Model):
start_date = models.DateField(blank=True,null=True)
end_date = models.DateField(blank=True,null=True)
def __str__(self):
def __unicode__(self):
return self.year
def GetPersonExpedition(self, name):
personexpeditions = PersonExpedition.objects.filter(expedition=self)
person_expeditions = PersonExpedition.objects.filter(expedition=self)
res = None
for personexpedition in personexpeditions:
for possiblenameform in personexpedition.GetPossibleNameForms():
#print "nnn", possiblenameform
if name == possiblenameform:
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 = personexpedition
res = person_expedition
return res
@ -28,7 +28,7 @@ class Person(models.Model):
last_name = models.CharField(max_length=100)
is_vfho = models.BooleanField()
mug_shot = models.CharField(max_length=100, blank=True,null=True)
def __str__(self):
def __unicode__(self):
return "%s %s" % (self.first_name, self.last_name)
class PersonExpedition(models.Model):
@ -49,7 +49,7 @@ class PersonExpedition(models.Model):
res.append(self.nickname)
return res
def __str__(self):
def __unicode__(self):
return "%s: (%s)" % (self.person, self.expedition)
@ -64,22 +64,22 @@ class LogbookEntry(models.Model):
# several PersonTrips point in to this object
def __str__(self):
def __unicode__(self):
return "%s: (%s)" % (self.date, self.title)
class PersonTrip(models.Model):
personexpedition = models.ForeignKey(PersonExpedition)
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()
timeunderground = models.CharField(max_length=100)
logbookentry = models.ForeignKey(LogbookEntry)
is_logbookentryauthor = models.BooleanField()
time_underground = models.CharField(max_length=100)
logbook_entry = models.ForeignKey(LogbookEntry)
is_logbook_entry_author = models.BooleanField()
def __str__(self):
return "%s %s (%s)" % (self.personexpedition, self.place, self.date)
def __unicode__(self):
return "%s %s (%s)" % (self.person_expedition, self.place, self.date)

View File

@ -113,8 +113,8 @@ def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, tu):
lbo.save()
print "ttt", date, place
for tripperson in trippersons:
pto = models.PersonTrip(personexpedition = tripperson, place=place, date=date, timeunderground=(tu or ""),
logbookentry=lbo, is_logbookentryauthor=(tripperson == author))
pto = models.PersonTrip(person_expedition = tripperson, place=place, date=date, time_underground=(tu or ""),
logbook_entry=lbo, is_logbook_entry_author=(tripperson == author))
pto.save()
def ParseDate(tripdate, year):
@ -181,7 +181,8 @@ def Parseloghtmltxt(year, expedition, txt):
#print "\n", tripcave, "--- ppp", trippeople, len(triptext)
ltriptext = re.sub("</p>", "", triptext)
ltriptext = re.sub("\s*?\n\s*", " ", ltriptext)
ltriptext = re.sub("<p>", "\n\n", ltriptext).strip() EnterLogIntoDbase(date = ldate, place = tripcave, title = triptitle, text = ltriptext, trippeople=trippeople, expedition=expedition, tu=tu)
ltriptext = re.sub("<p>", "\n\n", ltriptext).strip()
EnterLogIntoDbase(date = ldate, place = tripcave, title = triptitle, text = ltriptext, trippeople=trippeople, expedition=expedition, tu=tu)
# main parser for pre-2001. simpler because the data has been hacked so much to fit it
@ -278,6 +279,7 @@ def LoadLogbooks():
# command line run through the loading stages
# you can comment out these in turn to control what gets reloaded
LoadExpos() LoadPersons()
LoadExpos()
LoadPersons()
LoadLogbooks()