mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-11-27 01:32:03 +00:00
[svn r8274] Reverted the reverts from 8267. Fixed the next / previous trip in personexpedition on the LogbookEntry template -- I had misunderstood what this was supposed to do last time I messed with it. This involved adding the methods PersonTrip.get_persons_next_trip and persons_previous_trip. Couldn't find any other broken things.
Kept the productive changes in 8267: extending the logbook parsing back to 1993, changing index page, changes to view_surveys.py
This commit is contained in:
parent
a2057e63f5
commit
97c9772696
@ -260,7 +260,19 @@ class PersonTrip(TroggleModel):
|
|||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return "%s %s (%s)" % (self.person_expedition, self.place, self.date)
|
return "%s %s (%s)" % (self.person_expedition, self.place, self.date)
|
||||||
|
|
||||||
|
def get_persons_next_trip(self):
|
||||||
|
try:
|
||||||
|
return PersonTrip.objects.filter(person_expedition__person=self.person_expedition.person, date__gt=self.date)[0]
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
|
||||||
|
def get_persons_previous_trip(self):
|
||||||
|
try:
|
||||||
|
return PersonTrip.objects.filter(person_expedition__person=self.person_expedition.person, date__lt=self.date)[0]
|
||||||
|
except:
|
||||||
|
return
|
||||||
|
|
||||||
|
# def get_persons_previous_trip(self):
|
||||||
#
|
#
|
||||||
# move following classes into models_cave
|
# move following classes into models_cave
|
||||||
#
|
#
|
||||||
|
@ -63,8 +63,8 @@ def person(request, first_name='', last_name=''):
|
|||||||
# person = Person.objects.get(href=name)
|
# person = Person.objects.get(href=name)
|
||||||
#
|
#
|
||||||
|
|
||||||
def personexpedition(request, href, year):
|
def personexpedition(request, first_name='', last_name='', year=''):
|
||||||
person = Person.objects.get(href=href)
|
person = Person.objects.get(first_name = first_name, last_name = last_name)
|
||||||
expedition = Expedition.objects.get(year=year)
|
expedition = Expedition.objects.get(year=year)
|
||||||
personexpedition = person.personexpedition_set.get(expedition=expedition)
|
personexpedition = person.personexpedition_set.get(expedition=expedition)
|
||||||
return render_response(request,'personexpedition.html', {'personexpedition': personexpedition, })
|
return render_response(request,'personexpedition.html', {'personexpedition': personexpedition, })
|
||||||
|
@ -29,8 +29,7 @@ def frontpage(request):
|
|||||||
|
|
||||||
#'randSent':randSent.randomLogbookSentence(),
|
#'randSent':randSent.randomLogbookSentence(),
|
||||||
expeditions = Expedition.objects.order_by("-year")
|
expeditions = Expedition.objects.order_by("-year")
|
||||||
totallogbookentries = LogbookEntry.objects.count()
|
return render_response(request,'index.html', {'expeditions':expeditions, 'all':'all', "message":message})
|
||||||
return render_response(request,'index.html', {'expeditions':expeditions, 'all':'all', 'totallogbookentries':totallogbookentries, "message":message})
|
|
||||||
|
|
||||||
def calendar(request,year):
|
def calendar(request,year):
|
||||||
week=['S','S','M','T','W','T','F']
|
week=['S','S','M','T','W','T','F']
|
||||||
|
@ -198,7 +198,7 @@ def Parseloghtml01(year, expedition, txt):
|
|||||||
|
|
||||||
|
|
||||||
#print ldate, trippeople.strip()
|
#print ldate, trippeople.strip()
|
||||||
# could include the tripid (url link for cross referencing)
|
# could includ the tripid (url link for cross referencing)
|
||||||
EnterLogIntoDbase(date = ldate, place = tripcave, title = triptitle, text = ltriptext, trippeople=trippeople, expedition=expedition, logtime_underground=0)
|
EnterLogIntoDbase(date = ldate, place = tripcave, title = triptitle, text = ltriptext, trippeople=trippeople, expedition=expedition, logtime_underground=0)
|
||||||
|
|
||||||
|
|
||||||
@ -244,10 +244,10 @@ yearlinks = [
|
|||||||
("1999", "1999/log.htm", Parseloghtml01),
|
("1999", "1999/log.htm", Parseloghtml01),
|
||||||
("1998", "1998/log.htm", Parseloghtml01),
|
("1998", "1998/log.htm", Parseloghtml01),
|
||||||
("1997", "1997/log.htm", Parseloghtml01),
|
("1997", "1997/log.htm", Parseloghtml01),
|
||||||
("1996", "1996/log.htm", Parseloghtml01),
|
("1996", "1996/log.htm", Parseloghtml01),
|
||||||
("1995", "1995/log.htm", Parseloghtml01),
|
("1995", "1995/log.htm", Parseloghtml01),
|
||||||
("1994", "1994/log.htm", Parseloghtml01),
|
("1994", "1994/log.htm", Parseloghtml01),
|
||||||
("1993", "1993/log.htm", Parseloghtml01),
|
("1993", "1993/log.htm", Parseloghtml01),
|
||||||
]
|
]
|
||||||
|
|
||||||
def SetDatesFromLogbookEntries(expedition):
|
def SetDatesFromLogbookEntries(expedition):
|
||||||
@ -258,25 +258,22 @@ def SetDatesFromLogbookEntries(expedition):
|
|||||||
personexpedition.save()
|
personexpedition.save()
|
||||||
|
|
||||||
# The below is all unnecessary, just use the built in get_previous_by_date and get_next_by_date
|
# The below is all unnecessary, just use the built in get_previous_by_date and get_next_by_date
|
||||||
# it might be if it f***ing worked! but it doesn't does it!
|
# lprevpersontrip = None
|
||||||
lprevpersontrip = None
|
# for persontrip in persontrips:
|
||||||
for persontrip in persontrips:
|
# persontrip.persontrip_prev = lprevpersontrip
|
||||||
persontrip.persontrip_prev = lprevpersontrip
|
# if lprevpersontrip:
|
||||||
if lprevpersontrip:
|
# lprevpersontrip.persontrip_next = persontrip
|
||||||
lprevpersontrip.persontrip_next = persontrip
|
# lprevpersontrip.save()
|
||||||
lprevpersontrip.save()
|
# persontrip.persontrip_next = None
|
||||||
persontrip.persontrip_next = None
|
# lprevpersontrip = persontrip
|
||||||
lprevpersontrip = persontrip
|
# persontrip.save()
|
||||||
persontrip.save()
|
|
||||||
|
|
||||||
# from trips rather than logbook entries, which may include events outside the expedition (so what?)
|
# 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_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.date_to = max([personexpedition.date_to for personexpedition in expedition.personexpedition_set.all() if personexpedition.date_to] or [None])
|
||||||
expedition.save()
|
expedition.save()
|
||||||
|
|
||||||
# The below has been replaced with the methods get_next_by_id and get_previous_by_id
|
# 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)
|
# # order by appearance in the logbook (done by id)
|
||||||
# lprevlogbookentry = None
|
# lprevlogbookentry = None
|
||||||
# for logbookentry in expedition.logbookentry_set.order_by('id'):
|
# for logbookentry in expedition.logbookentry_set.order_by('id'):
|
||||||
@ -288,9 +285,7 @@ def SetDatesFromLogbookEntries(expedition):
|
|||||||
# logbookentry.save()
|
# logbookentry.save()
|
||||||
# lprevlogbookentry = logbookentry
|
# lprevlogbookentry = logbookentry
|
||||||
|
|
||||||
# This combined date / number key is a weird way of doing things. Use the primary key instead.
|
# 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.
|
||||||
# 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
|
# # order by date for setting the references
|
||||||
# lprevlogbookentry = None
|
# lprevlogbookentry = None
|
||||||
# for logbookentry in expedition.logbookentry_set.order_by('date'):
|
# for logbookentry in expedition.logbookentry_set.order_by('date'):
|
||||||
@ -325,7 +320,7 @@ def LoadLogbooks():
|
|||||||
models.LogbookEntry.objects.all().delete()
|
models.LogbookEntry.objects.all().delete()
|
||||||
expowebbase = os.path.join(settings.EXPOWEB, "years")
|
expowebbase = os.path.join(settings.EXPOWEB, "years")
|
||||||
#yearlinks = [ ("2001", "2001/log.htm", Parseloghtml01), ] #overwrite
|
#yearlinks = [ ("2001", "2001/log.htm", Parseloghtml01), ] #overwrite
|
||||||
#yearlinks = [ ("1993", "1993/log.htm", Parseloghtml01),] # overwrite
|
#yearlinks = [ ("1996", "1996/log.htm", Parseloghtml01),] # overwrite
|
||||||
|
|
||||||
for year, lloc, parsefunc in yearlinks:
|
for year, lloc, parsefunc in yearlinks:
|
||||||
expedition = models.Expedition.objects.filter(year = year)[0]
|
expedition = models.Expedition.objects.filter(year = year)[0]
|
||||||
@ -335,3 +330,4 @@ def LoadLogbooks():
|
|||||||
parsefunc(year, expedition, txt)
|
parsefunc(year, expedition, txt)
|
||||||
SetDatesFromLogbookEntries(expedition)
|
SetDatesFromLogbookEntries(expedition)
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,11 +83,11 @@ def LoadPersonsExpos():
|
|||||||
|
|
||||||
person = models.Person(first_name=mname.group(1), last_name=(mname.group(2) or ""))
|
person = models.Person(first_name=mname.group(1), last_name=(mname.group(2) or ""))
|
||||||
person.is_vfho = personline[header["VfHO member"]]
|
person.is_vfho = personline[header["VfHO member"]]
|
||||||
person.Sethref()
|
#person.Sethref()
|
||||||
#print "NNNN", person.href
|
#print "NNNN", person.href
|
||||||
is_guest = (personline[header["Guest"]] == "1") # this is really a per-expo catagory; not a permanent state
|
is_guest = (personline[header["Guest"]] == "1") # this is really a per-expo catagory; not a permanent state
|
||||||
person.save()
|
person.save()
|
||||||
#parseMugShotAndBlurb(personline=personline, header=header, person=person)
|
parseMugShotAndBlurb(personline=personline, header=header, person=person)
|
||||||
|
|
||||||
# make person expedition from table
|
# make person expedition from table
|
||||||
for year, attended in zip(headers, personline)[5:]:
|
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))
|
persons = list(models.Person.objects.filter(first_name=firstname, last_name=lastname))
|
||||||
if not persons:
|
if not persons:
|
||||||
person = models.Person(first_name=firstname, last_name = lastname, is_vfho = False, mug_shot = "")
|
person = models.Person(first_name=firstname, last_name = lastname, is_vfho = False, mug_shot = "")
|
||||||
person.Sethref()
|
#person.Sethref()
|
||||||
person.save()
|
person.save()
|
||||||
else:
|
else:
|
||||||
person = persons[0]
|
person = persons[0]
|
||||||
|
@ -44,13 +44,13 @@
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
{% if persontrip.persontrip_prev %}
|
{% if persontrip.get_previous_by_date %}
|
||||||
<a href="{{ persontrip.persontrip_prev.logbook_entry.get_absolute_url }}">{{persontrip.persontrip_prev.date}}</a>
|
<a href="{{ persontrip.get_persons_previous_trip.logbook_entry.get_absolute_url }}">{{persontrip.get_persons_previous_trip.date}}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if persontrip.persontrip_next %}
|
{% if persontrip.get_persons_next_trip %}
|
||||||
<a href="{{ persontrip.persontrip_next.logbook_entry.get_absolute_url }}">{{persontrip.persontrip_next.date}}</a>
|
<a href="{{ persontrip.get_persons_next_trip.logbook_entry.get_absolute_url }}">{{persontrip.get_persons_next_trip.date}}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -17,12 +17,11 @@ urlpatterns = patterns('',
|
|||||||
|
|
||||||
|
|
||||||
#(r'^person/(?P<person_id>\d*)/?$', views_logbooks.person),
|
#(r'^person/(?P<person_id>\d*)/?$', views_logbooks.person),
|
||||||
url(r'^person/(?P<first_name>[A-Z]*[a-z\-\']*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-z\-]*)/?', views_logbooks.person, name="person"),
|
url(r'^person/(?P<first_name>[A-Z]*[a-z\-\']*)[^a-zA-Z]*(?P<last_name>[a-z\-\']*[^a-zA-Z]*[A-Z]*[a-z\-]*)/?', views_logbooks.person, name="person"),
|
||||||
#url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"),
|
#url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"),
|
||||||
|
|
||||||
url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"),
|
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'^logbookentry/(.+)$', views_logbooks.logbookentry,name="logbookentry"),
|
||||||
|
|
||||||
url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"),
|
url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"),
|
||||||
@ -78,5 +77,5 @@ urlpatterns = patterns('',
|
|||||||
{'document_root': settings.SURVEYS, 'show_indexes':True}),
|
{'document_root': settings.SURVEYS, 'show_indexes':True}),
|
||||||
|
|
||||||
(r'^photos/(?P<path>.*)$', 'django.views.static.serve',
|
(r'^photos/(?P<path>.*)$', 'django.views.static.serve',
|
||||||
{'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}),
|
{'document_root': settings.PHOTOS, 'show_indexes':True}),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user