forked from expo/troggle
[svn] revert some of the changes (href element) so that the links work
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8267 by julian @ 3/11/2009 10:44 AM
This commit is contained in:
parent
e8da6b9b8b
commit
90da85e856
@ -76,7 +76,13 @@ class Person(TroggleModel):
|
||||
mug_shot = models.CharField(max_length=100, blank=True,null=True)
|
||||
blurb = models.TextField(blank=True,null=True)
|
||||
|
||||
#href = models.CharField(max_length=200)
|
||||
|
||||
# this has been put back in so that the personexpedition links work
|
||||
# if you're going to insist on replace something that works with an over-complex, dire, inevitably-flawed pointless
|
||||
# and unnecessary regexp like (?P<first_name>[A-Z]*[a-z\-\']*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-z\-]*)/?
|
||||
# for no reason at all, at least make it work everywhere!
|
||||
href = models.CharField(max_length=200)
|
||||
|
||||
orderref = models.CharField(max_length=200) # for alphabetic
|
||||
|
||||
#the below have been removed and made methods. I'm not sure what the b in bisnotable stands for. - AC 16 Feb
|
||||
@ -113,14 +119,14 @@ class Person(TroggleModel):
|
||||
def bisnotable(self):
|
||||
return self.notability > 0.3
|
||||
|
||||
#def Sethref(self):
|
||||
#if self.last_name:
|
||||
#self.href = self.first_name.lower() + "_" + self.last_name.lower()
|
||||
#self.orderref = self.last_name + " " + self.first_name
|
||||
#else:
|
||||
# self.href = self.first_name.lower()
|
||||
#self.orderref = self.first_name
|
||||
#self.notability = 0.0 # set temporarily
|
||||
def Sethref(self):
|
||||
if self.last_name:
|
||||
self.href = self.first_name.lower() + "_" + self.last_name.lower()
|
||||
self.orderref = self.last_name + " " + self.first_name
|
||||
else:
|
||||
self.href = self.first_name.lower()
|
||||
self.orderref = self.first_name
|
||||
self.notability = 0.0 # set temporarily
|
||||
|
||||
|
||||
class PersonExpedition(TroggleModel):
|
||||
@ -209,6 +215,9 @@ class LogbookEntry(TroggleModel):
|
||||
cave = models.ForeignKey('Cave',blank=True,null=True)
|
||||
place = models.CharField(max_length=100,blank=True,null=True)
|
||||
text = models.TextField()
|
||||
|
||||
# having this commented out prevents us from ever devising a regular URL, possibly based on the date of the trip
|
||||
# and then disambiguated depending on how many trips there are
|
||||
#href = models.CharField(max_length=100)
|
||||
|
||||
|
||||
|
@ -94,35 +94,64 @@ def jgtfile(request, f):
|
||||
return HttpResponse("unknown file::%s::" % f, mimetype = "text/plain")
|
||||
|
||||
|
||||
def SaveImageInDir(name, imgdir, fdata):
|
||||
print ("hihihihi", fdata, settings.SURVEYS)
|
||||
print os.path.join(settings.SURVEYS, imgdir)
|
||||
if not os.path.isdir(os.path.join(settings.SURVEYS, imgdir)):
|
||||
print "*** Must have directory '%s' in '%s'" % (imgdir, settings.SURVEYS)
|
||||
def UniqueFile(fname):
|
||||
while True:
|
||||
fname = os.path.join(settings.SURVEYS, imgdir, name)
|
||||
if not os.path.exists(fname):
|
||||
break
|
||||
mname = re.match("(.*?)(?:-(\d+))?\.(png|jpg|jpeg)$(?i)", name)
|
||||
mname = re.match("(.*?)(?:-(\d+))?\.(png|jpg|jpeg)$(?i)", fname)
|
||||
if mname:
|
||||
name = "%s-%d.%s" % (mname.group(1), int(mname.group(2) or "0") + 1, mname.group(3))
|
||||
fname = "%s-%d.%s" % (mname.group(1), int(mname.group(2) or "0") + 1, mname.group(3))
|
||||
return fname
|
||||
|
||||
|
||||
# join it all up and then split them off for the directories that don't exist
|
||||
# anyway, this mkdir doesn't work
|
||||
def SaveImageInDir(name, imgdir, project, fdata, bbinary):
|
||||
print ("hihihihi", fdata, settings.SURVEYS)
|
||||
fimgdir = os.path.join(settings.SURVEYS, imgdir)
|
||||
if not os.path.isdir(fimgdir):
|
||||
print "*** Making directory", fimgdir
|
||||
os.path.mkdir(fimgdir)
|
||||
fprojdir = os.path.join(fimgdir, project)
|
||||
if not os.path.isdir(fprojdir):
|
||||
print "*** Making directory", fprojdir
|
||||
os.path.mkdir(fprojdir)
|
||||
print "hhh"
|
||||
|
||||
fname = os.path.join(fprojdir, name)
|
||||
print fname, "fff"
|
||||
fname = UniqueFile(fname)
|
||||
|
||||
p2, p1 = os.path.split(fname)
|
||||
p3, p2 = os.path.split(p2)
|
||||
p4, p3 = os.path.split(p3)
|
||||
res = os.path.join(p3, p2, p1)
|
||||
|
||||
print "saving file", fname
|
||||
fout = open(fname, "wb")
|
||||
fout = open(fname, (bbinary and "wb" or "w"))
|
||||
fout.write(fdata.read())
|
||||
fout.close()
|
||||
res = os.path.join(imgdir, name)
|
||||
return res.replace("\\", "/")
|
||||
|
||||
|
||||
# do we want to consider saving project/field rather than field/project
|
||||
def jgtuploadfile(request):
|
||||
filesuploaded = [ ]
|
||||
project, user, tunnelversion = request.POST["project"], request.POST["user"], request.POST["tunnelversion"]
|
||||
project, user, password, tunnelversion = request.POST["tunnelproject"], request.POST["tunneluser"], request.POST["tunnelpassword"], request.POST["tunnelversion"]
|
||||
print (project, user, tunnelversion)
|
||||
for uploadedfile in request.FILES.values():
|
||||
if uploadedfile.field_name in ["tileimage", "backgroundimage"] and \
|
||||
uploadedfile.content_type in ["image/png", "image/jpeg"]:
|
||||
fname = user + "_" + re.sub("[\\\\/]", "-", uploadedfile.name) # very escaped \
|
||||
print fname
|
||||
fileuploaded = SaveImageInDir(fname, uploadedfile.field_name, uploadedfile)
|
||||
fileuploaded = SaveImageInDir(fname, uploadedfile.field_name, project, uploadedfile, True)
|
||||
filesuploaded.append(settings.URL_ROOT + "/jgtfile/" + fileuploaded)
|
||||
if uploadedfile.field_name in ["sketch"] and \
|
||||
uploadedfile.content_type in ["text/plain"]:
|
||||
fname = user + "_" + re.sub("[\\\\/]", "-", uploadedfile.name) # very escaped \
|
||||
print fname
|
||||
fileuploaded = SaveImageInDir(fname, uploadedfile.field_name, project, uploadedfile, False)
|
||||
filesuploaded.append(settings.URL_ROOT + "/jgtfile/" + fileuploaded)
|
||||
#print "FF", request.FILES
|
||||
#print ("FFF", request.FILES.values())
|
||||
|
@ -63,8 +63,8 @@ def person(request, first_name='', last_name=''):
|
||||
# person = Person.objects.get(href=name)
|
||||
#
|
||||
|
||||
def personexpedition(request, first_name='', last_name='', year=''):
|
||||
person = Person.objects.get(first_name = first_name, last_name = last_name)
|
||||
def personexpedition(request, href, year):
|
||||
person = Person.objects.get(href=href)
|
||||
expedition = Expedition.objects.get(year=year)
|
||||
personexpedition = person.personexpedition_set.get(expedition=expedition)
|
||||
return render_response(request,'personexpedition.html', {'personexpedition': personexpedition, })
|
||||
|
@ -29,7 +29,8 @@ def frontpage(request):
|
||||
|
||||
#'randSent':randSent.randomLogbookSentence(),
|
||||
expeditions = Expedition.objects.order_by("-year")
|
||||
return render_response(request,'index.html', {'expeditions':expeditions, 'all':'all', "message":message})
|
||||
totallogbookentries = LogbookEntry.objects.count()
|
||||
return render_response(request,'index.html', {'expeditions':expeditions, 'all':'all', 'totallogbookentries':totallogbookentries, "message":message})
|
||||
|
||||
def calendar(request,year):
|
||||
week=['S','S','M','T','W','T','F']
|
||||
|
@ -198,7 +198,7 @@ def Parseloghtml01(year, expedition, txt):
|
||||
|
||||
|
||||
#print ldate, trippeople.strip()
|
||||
# could includ the tripid (url link for cross referencing)
|
||||
# could include the tripid (url link for cross referencing)
|
||||
EnterLogIntoDbase(date = ldate, place = tripcave, title = triptitle, text = ltriptext, trippeople=trippeople, expedition=expedition, logtime_underground=0)
|
||||
|
||||
|
||||
@ -245,6 +245,9 @@ yearlinks = [
|
||||
("1998", "1998/log.htm", Parseloghtml01),
|
||||
("1997", "1997/log.htm", Parseloghtml01),
|
||||
("1996", "1996/log.htm", Parseloghtml01),
|
||||
("1995", "1995/log.htm", Parseloghtml01),
|
||||
("1994", "1994/log.htm", Parseloghtml01),
|
||||
("1993", "1993/log.htm", Parseloghtml01),
|
||||
]
|
||||
|
||||
def SetDatesFromLogbookEntries(expedition):
|
||||
@ -255,22 +258,25 @@ def SetDatesFromLogbookEntries(expedition):
|
||||
personexpedition.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()
|
||||
# it might be if it f***ing worked! but it doesn't does it!
|
||||
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
|
||||
# from trips rather than logbook entries, which may include events outside the expedition (so what?)
|
||||
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.save()
|
||||
|
||||
# The below has been replaced with the methods get_next_by_id and get_previous_by_id
|
||||
# (this might be true, but it's sort of in the order of the logbook.
|
||||
# [Maybe we'd want to sort it by date and display it in that order, in which case it's tough luck! - JGT]
|
||||
# # order by appearance in the logbook (done by id)
|
||||
# lprevlogbookentry = None
|
||||
# for logbookentry in expedition.logbookentry_set.order_by('id'):
|
||||
@ -282,7 +288,9 @@ def SetDatesFromLogbookEntries(expedition):
|
||||
# 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.
|
||||
# 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.
|
||||
# [Not weird. Very common. A date is meaningful and almost gets there. Simply needs small amount of disambiguation to make it a primary key -- JGT]
|
||||
# # order by date for setting the references
|
||||
# lprevlogbookentry = None
|
||||
# for logbookentry in expedition.logbookentry_set.order_by('date'):
|
||||
@ -317,7 +325,7 @@ def LoadLogbooks():
|
||||
models.LogbookEntry.objects.all().delete()
|
||||
expowebbase = os.path.join(settings.EXPOWEB, "years")
|
||||
#yearlinks = [ ("2001", "2001/log.htm", Parseloghtml01), ] #overwrite
|
||||
#yearlinks = [ ("1996", "1996/log.htm", Parseloghtml01),] # overwrite
|
||||
#yearlinks = [ ("1993", "1993/log.htm", Parseloghtml01),] # overwrite
|
||||
|
||||
for year, lloc, parsefunc in yearlinks:
|
||||
expedition = models.Expedition.objects.filter(year = year)[0]
|
||||
@ -327,4 +335,3 @@ def LoadLogbooks():
|
||||
parsefunc(year, expedition, txt)
|
||||
SetDatesFromLogbookEntries(expedition)
|
||||
|
||||
|
||||
|
@ -83,11 +83,11 @@ 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()
|
||||
parseMugShotAndBlurb(personline=personline, header=header, person=person)
|
||||
#parseMugShotAndBlurb(personline=personline, header=header, person=person)
|
||||
|
||||
# make person expedition from table
|
||||
for year, attended in zip(headers, personline)[5:]:
|
||||
@ -106,7 +106,7 @@ def LoadPersonsExpos():
|
||||
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.Sethref()
|
||||
person.save()
|
||||
else:
|
||||
person = persons[0]
|
||||
|
@ -6,8 +6,8 @@
|
||||
{% block content %}
|
||||
|
||||
<h2>The unfinished front page</h2>
|
||||
|
||||
<ul>
|
||||
<li><b>About {{totallogbookentries}} logbook entries have been loaded</b></li>
|
||||
<li><b><a href="{% url personindex %}">List of People</a></b></li>
|
||||
<li><b><a href="{% url caveindex %}">List of Caves</a></b></li>
|
||||
<li><a href="{% url jgtfile aaaa %}">JGT list of files</a> (temporary simple file list and tunnel use)</li>
|
||||
@ -15,21 +15,24 @@
|
||||
<li><a href="{% url survexindex all %}">Survex directory</a></li>
|
||||
<li><a href="{% url expedition 2008 %}">Expedition 2008</a></li>
|
||||
<li><a href="{% url expedition 2007 %}">Expedition 2007</a></li>
|
||||
<li><a href="{% url expedition 1996 %}">Expedition 1996</a></li>
|
||||
<li><a href="{% url expedition 1993 %}">Expedition 1993</a> (earliest parsed)</li>
|
||||
</ul>
|
||||
|
||||
<h2>Further work</h2>
|
||||
|
||||
<p>Julian's work:
|
||||
<p>parse 1992-1976 logbooks; (esp top 161)</p>
|
||||
<p>detect T/U on log entries; </p>
|
||||
<p>name matching and spelling in survex files; </p>
|
||||
<p>Improve logbook wikihtml text</p>
|
||||
|
||||
<p>Other work:</p>
|
||||
<p>surf through the tunnel sketches and images</p>
|
||||
<p>bugs with all.svx block (double dot)
|
||||
<p>name matching and spelling in survex files; </p>
|
||||
<p>render bitmap view of every survex block as a thumbnail</p>
|
||||
<p>upload tunnel images and tunnel sketches</p>
|
||||
<p>parse 1995-1976 logbooks; (esp top 161)</p>
|
||||
<p>where are the subcaves; </p>
|
||||
<p>cave section entrance match for logbook entries</p>
|
||||
<p>detect T/U on log entries; </p>
|
||||
<p>Improve logbook wikihtml text</p>
|
||||
<p>simplify the survex parsing code (if necessary); </p>
|
||||
<p>wiki survex stop linegap between comment lins</p>
|
||||
<p>links between logbooks and survex blocks to cave things; </p>
|
||||
@ -48,6 +51,7 @@
|
||||
{% for expedition in expeditions %}
|
||||
<li>
|
||||
<a href="{% url expedition expedition.year %}">{{expedition.name}}</a>
|
||||
- <b>{{expedition.logbookentry_set.count}}</b> logbook entries
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
@ -44,13 +44,13 @@
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{% if persontrip.get_previous_by_date %}
|
||||
<a href="{{ persontrip.get_previous_by_date.logbook_entry.get_absolute_url }}">{{persontrip.get_previous_by_date.date}}</a>
|
||||
{% if persontrip.persontrip_prev %}
|
||||
<a href="{{ persontrip.persontrip_prev.logbook_entry.get_absolute_url }}">{{persontrip.persontrip_prev.date}}</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if persontrip.get_next_by_date %}
|
||||
<a href="{{ persontrip.get_next_by_date.logbook_entry.get_absolute_url }}">{{persontrip.get_next_by_date.date}}</a>
|
||||
{% if persontrip.persontrip_next %}
|
||||
<a href="{{ persontrip.persontrip_next.logbook_entry.get_absolute_url }}">{{persontrip.persontrip_next.date}}</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
3
urls.py
3
urls.py
@ -21,7 +21,8 @@ urlpatterns = patterns('',
|
||||
#url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"),
|
||||
|
||||
url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"),
|
||||
url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-z]*)/(?P<year>\d+)/?$', views_logbooks.personexpedition, name="personexpedition"),
|
||||
#url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-z]*)/(?P<year>\d+)/?$', views_logbooks.personexpedition, name="personexpedition"),
|
||||
url(r'^personexpedition/(.+?)/(\d+)$', views_logbooks.personexpedition, name="personexpedition"),
|
||||
url(r'^logbookentry/(.+)$', views_logbooks.logbookentry,name="logbookentry"),
|
||||
|
||||
url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"),
|
||||
|
Loading…
Reference in New Issue
Block a user