forked from expo/troggle
[svn]
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8245 by aaron @ 2/17/2009 1:09 AM
This commit is contained in:
@@ -52,7 +52,7 @@ def parseCaveQMs(cave,pathToCSV):
|
||||
newQM.completion_description=line[5]
|
||||
newQM.comment=line[6]
|
||||
newQM.save()
|
||||
print "QM "+str(newQM) + " added to database"
|
||||
print "QM "+str(newQM) + ' added to database\r',
|
||||
except KeyError:
|
||||
continue
|
||||
# except IndexError:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
sys.path.append("/home/mjg/expoweb/troggle")
|
||||
import expo.models as models
|
||||
import settings as settings
|
||||
import troggle.expo.models as models
|
||||
from django.conf import settings
|
||||
import csv
|
||||
import time
|
||||
|
||||
@@ -177,7 +177,6 @@ def LoadCaveTab():
|
||||
addToArgs(Notes, "notes")
|
||||
|
||||
newCave = models.Cave(**args)
|
||||
newCave.Sethref()
|
||||
newCave.save()
|
||||
|
||||
if line[Area]:
|
||||
|
||||
@@ -20,7 +20,7 @@ import os
|
||||
#
|
||||
# the logbook loading section
|
||||
#
|
||||
def GetTripPersons(trippeople, expedition, logtime_underground):
|
||||
def GetTripPersons(trippeople, expedition, logtime_underground):
|
||||
res = [ ]
|
||||
author = None
|
||||
for tripperson in re.split(",|\+|&|&(?!\w+;)| and ", trippeople):
|
||||
@@ -252,45 +252,50 @@ def SetDatesFromLogbookEntries(expedition):
|
||||
persontrips = personexpedition.persontrip_set.order_by('date')
|
||||
personexpedition.date_from = min([persontrip.date for persontrip in persontrips] or [None])
|
||||
personexpedition.date_to = max([persontrip.date for persontrip in persontrips] or [None])
|
||||
personexpedition.dates_guessed = True
|
||||
personexpedition.save()
|
||||
|
||||
lprevpersontrip = None
|
||||
for persontrip in persontrips:
|
||||
persontrip.persontrip_prev = lprevpersontrip
|
||||
if lprevpersontrip:
|
||||
lprevpersontrip.persontrip_next = persontrip
|
||||
lprevpersontrip.save()
|
||||
persontrip.persontrip_next = None
|
||||
lprevpersontrip = persontrip
|
||||
persontrip.save()
|
||||
|
||||
# The below is all unnecessary, just use the built in get_previous_by_date and get_next_by_date
|
||||
# lprevpersontrip = None
|
||||
# for persontrip in persontrips:
|
||||
# persontrip.persontrip_prev = lprevpersontrip
|
||||
# if lprevpersontrip:
|
||||
# lprevpersontrip.persontrip_next = persontrip
|
||||
# lprevpersontrip.save()
|
||||
# persontrip.persontrip_next = None
|
||||
# lprevpersontrip = persontrip
|
||||
# persontrip.save()
|
||||
|
||||
# from trips rather than logbook entries, which may include events outside the expedition
|
||||
expedition.date_from = min([personexpedition.date_from for personexpedition in expedition.personexpedition_set.all() if personexpedition.date_from] or [None])
|
||||
expedition.date_to = max([personexpedition.date_to for personexpedition in expedition.personexpedition_set.all() if personexpedition.date_to] or [None])
|
||||
expedition.dates_guessed = True
|
||||
expedition.save()
|
||||
|
||||
# order by appearance in the logbook (done by id)
|
||||
lprevlogbookentry = None
|
||||
for logbookentry in expedition.logbookentry_set.order_by('id'):
|
||||
logbookentry.logbookentry_prev = lprevlogbookentry
|
||||
if lprevlogbookentry:
|
||||
lprevlogbookentry.logbookentry_next = logbookentry
|
||||
lprevlogbookentry.save()
|
||||
logbookentry.logbookentry_next = None
|
||||
logbookentry.save()
|
||||
lprevlogbookentry = logbookentry
|
||||
|
||||
# The below has been replaced with the methods get_next_by_id and get_previous_by_id
|
||||
# # order by appearance in the logbook (done by id)
|
||||
# lprevlogbookentry = None
|
||||
# for logbookentry in expedition.logbookentry_set.order_by('id'):
|
||||
# logbookentry.logbookentry_prev = lprevlogbookentry
|
||||
# if lprevlogbookentry:
|
||||
# lprevlogbookentry.logbookentry_next = logbookentry
|
||||
# lprevlogbookentry.save()
|
||||
# logbookentry.logbookentry_next = None
|
||||
# logbookentry.save()
|
||||
# lprevlogbookentry = logbookentry
|
||||
|
||||
# order by date for setting the references
|
||||
lprevlogbookentry = None
|
||||
for logbookentry in expedition.logbookentry_set.order_by('date'):
|
||||
if lprevlogbookentry and lprevlogbookentry.date == logbookentry.date:
|
||||
mcount = re.search("_(\d+)$", lprevlogbookentry.href)
|
||||
mc = mcount and (int(mcount.group(1)) + 1) or 1
|
||||
logbookentry.href = "%s_%d" % (logbookentry.date, mc)
|
||||
else:
|
||||
logbookentry.href = "%s" % logbookentry.date
|
||||
logbookentry.save()
|
||||
lprevlogbookentry = logbookentry
|
||||
# This combined date / number key is a weird way of doing things. Use the primary key instead. If we are going to use the date for looking up entries, we should set it up to allow multiple results.
|
||||
# # order by date for setting the references
|
||||
# lprevlogbookentry = None
|
||||
# for logbookentry in expedition.logbookentry_set.order_by('date'):
|
||||
# if lprevlogbookentry and lprevlogbookentry.date == logbookentry.date:
|
||||
# mcount = re.search("_(\d+)$", lprevlogbookentry.href)
|
||||
# mc = mcount and (int(mcount.group(1)) + 1) or 1
|
||||
# logbookentry.href = "%s_%d" % (logbookentry.date, mc)
|
||||
# else:
|
||||
# logbookentry.href = "%s" % logbookentry.date
|
||||
# logbookentry.save()
|
||||
# lprevlogbookentry = logbookentry
|
||||
|
||||
|
||||
def LoadLogbookForExpedition(expedition):
|
||||
|
||||
@@ -56,7 +56,7 @@ def LoadPersonsExpos():
|
||||
print "Loading expeditions"
|
||||
models.Expedition.objects.all().delete()
|
||||
years = headers[5:]
|
||||
years.append("2008")
|
||||
# years.append("2008")
|
||||
for year in years:
|
||||
expedition = models.Expedition(year = year, name = "CUCC expo %s" % year)
|
||||
expedition.save()
|
||||
@@ -77,7 +77,7 @@ def LoadPersonsExpos():
|
||||
|
||||
person = models.Person(first_name=mname.group(1), last_name=(mname.group(2) or ""))
|
||||
person.is_vfho = personline[header["VfHO member"]]
|
||||
person.Sethref()
|
||||
#person.Sethref()
|
||||
#print "NNNN", person.href
|
||||
is_guest = (personline[header["Guest"]] == "1") # this is really a per-expo catagory; not a permanent state
|
||||
person.save()
|
||||
@@ -90,33 +90,33 @@ def LoadPersonsExpos():
|
||||
personexpedition = models.PersonExpedition(person=person, expedition=expedition, nickname=nickname, is_guest=is_guest)
|
||||
personexpedition.save()
|
||||
|
||||
|
||||
# The below is no longer necessary because the 2008 expedition people have been added to surveys.csv. - AC 16 Feb 09
|
||||
# this fills in those people for whom 2008 was their first expo
|
||||
print "Loading personexpeditions 2008"
|
||||
for name in expomissing:
|
||||
firstname, lastname = name.split()
|
||||
is_guest = name in ["Eeva Makiranta", "Keith Curtis"]
|
||||
print "2008:", name
|
||||
persons = list(models.Person.objects.filter(first_name=firstname, last_name=lastname))
|
||||
if not persons:
|
||||
person = models.Person(first_name=firstname, last_name = lastname, is_vfho = False, mug_shot = "")
|
||||
person.Sethref()
|
||||
person.save()
|
||||
else:
|
||||
person = persons[0]
|
||||
expedition = models.Expedition.objects.get(year="2008")
|
||||
personexpedition = models.PersonExpedition(person=person, expedition=expedition, nickname="", is_guest=is_guest)
|
||||
personexpedition.save()
|
||||
# print "Loading personexpeditions 2008"
|
||||
# for name in expomissing:
|
||||
# firstname, lastname = name.split()
|
||||
# is_guest = name in ["Eeva Makiranta", "Keith Curtis"]
|
||||
# print "2008:", name
|
||||
# persons = list(models.Person.objects.filter(first_name=firstname, last_name=lastname))
|
||||
# if not persons:
|
||||
# person = models.Person(first_name=firstname, last_name = lastname, is_vfho = False, mug_shot = "")
|
||||
# #person.Sethref()
|
||||
# person.save()
|
||||
# else:
|
||||
# person = persons[0]
|
||||
# expedition = models.Expedition.objects.get(year="2008")
|
||||
# personexpedition = models.PersonExpedition(person=person, expedition=expedition, nickname="", is_guest=is_guest)
|
||||
# personexpedition.save()
|
||||
|
||||
# could rank according to surveying as well
|
||||
print "Setting person notability"
|
||||
for person in models.Person.objects.all():
|
||||
person.notability = 0.0
|
||||
for personexpedition in person.personexpedition_set.all():
|
||||
if not personexpedition.is_guest:
|
||||
person.notability += 1.0 / (2012 - int(personexpedition.expedition.year))
|
||||
person.bisnotable = person.notability > 0.3 # I don't know how to filter by this
|
||||
person.save()
|
||||
# print "Setting person notability"
|
||||
# for person in models.Person.objects.all():
|
||||
# person.notability = 0.0
|
||||
# for personexpedition in person.personexpedition_set.all():
|
||||
# if not personexpedition.is_guest:
|
||||
# person.notability += 1.0 / (2012 - int(personexpedition.expedition.year))
|
||||
# person.bisnotable = person.notability > 0.3 # I don't know how to filter by this
|
||||
# person.save()
|
||||
|
||||
|
||||
# used in other referencing parser functions
|
||||
|
||||
@@ -42,7 +42,7 @@ for survey in surveyreader:
|
||||
#try and find the sketch_scan
|
||||
pass
|
||||
surveyobj.save()
|
||||
print "added survey " + survey[header['Year']] + "#" + surveyobj.wallet_number
|
||||
print "added survey " + survey[header['Year']] + "#" + surveyobj.wallet_number + "\r",
|
||||
|
||||
# add survey scans
|
||||
def parseSurveyScans(year):
|
||||
@@ -53,7 +53,7 @@ def parseSurveyScans(year):
|
||||
surveyNumber=re.match(r'\d\d\d\d#0*(\d+)',surveyFolder).groups()
|
||||
scanList=os.listdir(os.path.join(yearPath,surveyFolder))
|
||||
except AttributeError:
|
||||
print surveyFolder + " ignored"
|
||||
print surveyFolder + " ignored",
|
||||
continue
|
||||
|
||||
for scan in scanList:
|
||||
@@ -61,7 +61,7 @@ def parseSurveyScans(year):
|
||||
scanChopped=re.match(r'(?i).*(notes|elev|plan|elevation|extend)(\d*)\.(png|jpg|jpeg)',scan).groups()
|
||||
scanType,scanNumber,scanFormat=scanChopped
|
||||
except AttributeError:
|
||||
print "Adding scans: " + scan + " ignored"
|
||||
print "Adding scans: " + scan + " ignored \r",
|
||||
continue
|
||||
if scanType == 'elev' or scanType == 'extend':
|
||||
scanType = 'elevation'
|
||||
|
||||
Reference in New Issue
Block a user