mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-11-27 01:32:03 +00:00
[svn r8307] Up to late programming last night and forgot that not all logbookentries will have caves attached. The function I wrote for making the "add a qm link" was breaking stuff.
Fixed now.
This commit is contained in:
parent
5c84cc7674
commit
6f62771552
@ -69,20 +69,28 @@ def personexpedition(request, first_name='', last_name='', 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, })
|
||||||
|
|
||||||
def logbookentry(request, logbookentry_pk):
|
def newQMlink(logbookentry):
|
||||||
logbookentry = LogbookEntry.objects.get(pk = logbookentry_pk)
|
|
||||||
logsforcave=logbookentry.cave.logbookentry_set.all()
|
|
||||||
biggestQMnumber=0
|
biggestQMnumber=0
|
||||||
for log in logsforcave:
|
if logbookentry.cave:
|
||||||
|
for log in logbookentry.cave.logbookentry_set.all():
|
||||||
try:
|
try:
|
||||||
biggestQMnumberInLog = logbookentry.QMs_found.order_by('-number')[0].number
|
biggestQMnumberInLog = logbookentry.QMs_found.order_by('-number')[0].number
|
||||||
except IndexError:
|
except IndexError:
|
||||||
biggestQMnumberInLog = 0
|
biggestQMnumberInLog = 0
|
||||||
if biggestQMnumberInLog > biggestQMnumber:
|
if biggestQMnumberInLog > biggestQMnumber:
|
||||||
biggestQMnumber = biggestQMnumberInLog
|
biggestQMnumber = biggestQMnumberInLog
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
nextQMnumber=biggestQMnumber+1
|
nextQMnumber=biggestQMnumber+1
|
||||||
newQMlink=settings.URL_ROOT + r'/admin/expo/qm/add/?' + r'found_by=' + str(logbookentry.pk) +'&number=' + str(nextQMnumber)
|
return settings.URL_ROOT + r'/admin/expo/qm/add/?' + r'found_by=' + str(logbookentry.pk) +'&number=' + str(nextQMnumber)
|
||||||
return render_response(request, 'logbookentry.html', {'logbookentry': logbookentry, 'newQMlink':newQMlink})
|
|
||||||
|
def logbookentry(request, logbookentry_pk):
|
||||||
|
logbookentry = LogbookEntry.objects.get(pk = logbookentry_pk)
|
||||||
|
|
||||||
|
return render_response(request, 'logbookentry.html', {'logbookentry': logbookentry, 'newQMlink':newQMlink(logbookentry)})
|
||||||
|
|
||||||
def logbookSearch(request, extra):
|
def logbookSearch(request, extra):
|
||||||
query_string = ''
|
query_string = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user