From b7bf1b37acbae3e28726dc53b3f24f5829c0906a Mon Sep 17 00:00:00 2001 From: substantialnoninfringinguser Date: Wed, 13 May 2009 05:26:14 +0100 Subject: [PATCH] [svn] Added new photo model. Logbook parser now looks for mugshots when adding people. If it finds an image, it adds a new photo model instance linked to that person. If it finds an html page, it adds the body text of that page as the person's "blurb" and then adds the mugshot. My interface web design isn't working, sorry. Need a blank slate on that one. Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8150 by aaron @ 1/4/2009 2:06 PM --- databaseReset.py | 2 +- expo/models.py | 2 +- media/css/main2.css | 12 ++++- parsers/logbooks.py | 124 +++++++++++++++++++++++++++++--------------- 4 files changed, 96 insertions(+), 44 deletions(-) diff --git a/databaseReset.py b/databaseReset.py index 212c59015..e58f3fc3c 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -17,7 +17,7 @@ user.is_staff = True user.is_superuser = True user.save() -import parsers.logbooks import parsers.cavetab +import parsers.logbooks import parsers.QMs import parsers.survex diff --git a/expo/models.py b/expo/models.py index 324d478ce..1723f4aba 100644 --- a/expo/models.py +++ b/expo/models.py @@ -162,7 +162,7 @@ class LogbookEntry(models.Model): place = models.CharField(max_length=100,blank=True,null=True) text = models.TextField() class Meta: - verbose_name_plural = "LogbookEntries" + verbose_name_plural = "Logbook Entries" # several PersonTrips point in to this object def __unicode__(self): diff --git a/media/css/main2.css b/media/css/main2.css index b0810c64e..6ac3a3ece 100644 --- a/media/css/main2.css +++ b/media/css/main2.css @@ -9,7 +9,17 @@ body, td, center, ul, p, input { body { background-color: #000; } - +#expoHeader { + position: relative; + display: inline; + top:60px; +} +#expoFinalDate { + display: inline; +} +h1 { + display: inline; +} a:link, a:visited { text-decoration: none; } div.centre img { vertical-align: middle; } diff --git a/parsers/logbooks.py b/parsers/logbooks.py index 75caeaf79..82ad29b22 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -1,11 +1,16 @@ #.-*- coding: utf-8 -*- - -import settings -import expo.models as models +import sys +import os +sys.path.append('C:\\Expo\\expoweb') +from troggle import * +os.environ['DJANGO_SETTINGS_MODULE']='troggle.settings' +import troggle.settings as settings +import troggle.expo.models as models import csv import re -import os import datetime +from django.db.models import Q + persontab = open(os.path.join(settings.EXPOWEB, "noinfo", "folk.csv")) personreader = csv.reader(persontab) @@ -39,43 +44,18 @@ def LoadPersons(): firstname, lastname = mname.group(1), mname.group(2) or "" - #print firstname, lastname, "NNN", nickname + print firstname, lastname, "NNN", nickname #assert lastname == person[header[""]], person pObject = models.Person(first_name = firstname, last_name = lastname, is_vfho = person[header["VfHO member"]], - ) + ) is_guest = person[header["Guest"]] == "1" # this is really a per-expo catagory; not a permanent state pObject.save() - - #create mugshot Photo instance - mugShotPath = settings.EXPOWEB+"folk/"+person[header["Mugshot"]] - if mugShotPath[-3:]=='jpg': #if person just has an image, add it - mugShotObj = models.Photo( - caption="Mugshot for "+firstname+" "+lastname, - is_mugshot=True, - file=mugShotPath, - ) - mugShotObj.save() - mugShotObj.contains_person.add(pObject) - mugShotObj.save() - elif mugShotPath[-3:]=='htm': #if person has an html page, find the image(s) and add it. Also, add the text from the html page to the "blurb" field in his model instance. - personPageOld=open(mugShotPath,'r').read() - pObject.blurb=re.search('.*.*1: + print "Ambiguous place " + str(place) + " entered. Choose from " + str(tripCaveRes) + correctIndex=input("type list index of correct cave") + return tripCaveRes[correctIndex] + else: + print "No cave found for place " , place + return + def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, tu): trippersons, author = GetTripPersons(trippeople, expedition) + tripCave = GetTripCave(place) + lbo = models.LogbookEntry(date=date, place=place, title=title[:50], text=text, author=author) + if tripCave: + lbo.cave=tripCave lbo.save() print "ttt", date, place for tripperson in trippersons: @@ -281,8 +323,8 @@ def LoadLogbooks(): models.LogbookEntry.objects.all().delete() expowebbase = os.path.join(settings.EXPOWEB, "years") yearlinks = [ - ("2008", "2008/logbook/2008logbook.txt", Parselogwikitxt), - ("2007", "2007/logbook/2007logbook.txt", Parselogwikitxt), + ("2008", "2008/2008logbook.txt", Parselogwikitxt), + ("2007", "2007/2007logbook.txt", Parselogwikitxt), ("2006", "2006/logbook/logbook_06.txt", Parselogwikitxt), ("2005", "2005/logbook.html", Parseloghtmltxt), ("2004", "2004/logbook.html", Parseloghtmltxt),