mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-21 23:01:52 +00:00
Fixed QMs in Admin control panel &remv. OtherCave
This commit is contained in:
parent
64727e0d3a
commit
809633bdd3
@ -45,7 +45,7 @@ class SimpleTest(SimpleTestCase):
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils.timezone import get_current_timezone, make_aware
|
||||
from troggle.core.models import DataIssue, Expedition
|
||||
from troggle.core.models_caves import Cave, OtherCaveName, LogbookEntry, PersonTrip
|
||||
from troggle.core.models_caves import Cave, LogbookEntry, PersonTrip
|
||||
from parsers.people import GetPersonExpeditionNameLookup
|
||||
def test_import_core_views_caves(self):
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
|
@ -6,7 +6,7 @@ from django.core import serializers
|
||||
|
||||
from troggle.core.views_other import downloadLogbook
|
||||
from troggle.core.models import Person, PersonExpedition, Expedition, DataIssue
|
||||
from troggle.core.models_caves import Cave, Area, Entrance, CaveAndEntrance, OtherCaveName, LogbookEntry, PersonTrip, QM
|
||||
from troggle.core.models_caves import Cave, Area, Entrance, CaveAndEntrance, LogbookEntry, PersonTrip, QM
|
||||
from troggle.core.models_survex import SurvexBlock, SurvexPersonRole, SurvexStation, ScansFolder, SingleScan
|
||||
|
||||
|
||||
@ -30,9 +30,9 @@ class SurvexBlockAdmin(TroggleModelAdmin):
|
||||
inlines = (RoleInline,)
|
||||
|
||||
|
||||
class OtherCaveInline(admin.TabularInline):
|
||||
model = OtherCaveName
|
||||
extra = 1
|
||||
# class OtherCaveInline(admin.TabularInline):
|
||||
# model = OtherCaveName
|
||||
# extra = 1
|
||||
|
||||
|
||||
class SurveyAdmin(TroggleModelAdmin):
|
||||
@ -98,7 +98,7 @@ class PersonExpeditionAdmin(TroggleModelAdmin):
|
||||
|
||||
class CaveAdmin(TroggleModelAdmin):
|
||||
search_fields = ('official_name','kataster_number','unofficial_number')
|
||||
inlines = (OtherCaveInline,)
|
||||
#inlines = (OtherCaveInline,)
|
||||
extra = 4
|
||||
|
||||
|
||||
|
@ -202,11 +202,11 @@ class Cave(TroggleModel):
|
||||
pass
|
||||
return lowestareas[0]
|
||||
|
||||
class OtherCaveName(TroggleModel):
|
||||
name = models.CharField(max_length=160)
|
||||
cave = models.ForeignKey(Cave,on_delete=models.CASCADE)
|
||||
def __str__(self):
|
||||
return str(self.name)
|
||||
# class OtherCaveName(TroggleModel):
|
||||
# name = models.CharField(max_length=160)
|
||||
# cave = models.ForeignKey(Cave,on_delete=models.CASCADE)
|
||||
# def __str__(self):
|
||||
# return str(self.name)
|
||||
|
||||
class EntranceSlug(models.Model):
|
||||
entrance = models.ForeignKey('Entrance',on_delete=models.CASCADE)
|
||||
@ -503,7 +503,10 @@ class QM(TroggleModel):
|
||||
return "%s %s" % (self.code(), self.grade)
|
||||
|
||||
def code(self):
|
||||
return "%s-%s-%s" % (str(self.found_by.cave)[6:], self.found_by.date.year, self.number)
|
||||
if self.found_by:
|
||||
return "%s-%s-%s" % (str(self.found_by.cave)[6:], self.found_by.date.year, self.number)
|
||||
else:
|
||||
return "%s" % (self.number)
|
||||
|
||||
def get_absolute_url(self):
|
||||
#return settings.URL_ROOT + '/cave/' + self.found_by.cave.kataster_number + '/' + str(self.found_by.date.year) + '-' + '%02d' %self.number
|
||||
|
@ -11,7 +11,7 @@ from django.template.defaultfilters import slugify
|
||||
from django.utils.timezone import get_current_timezone, make_aware
|
||||
|
||||
from troggle.core.models import DataIssue, Expedition
|
||||
from troggle.core.models_caves import Cave, OtherCaveName, LogbookEntry, PersonTrip, GetCaveLookup
|
||||
from troggle.core.models_caves import Cave, LogbookEntry, PersonTrip, GetCaveLookup
|
||||
from parsers.people import GetPersonExpeditionNameLookup
|
||||
from utils import save_carefully
|
||||
|
||||
@ -50,35 +50,31 @@ def GetTripPersons(trippeople, expedition, logtime_underground):
|
||||
return res, author
|
||||
|
||||
def GetTripCave(place):
|
||||
#need to be fuzzier about matching here. Already a very slow function...
|
||||
# print "Getting cave for " , place
|
||||
try:
|
||||
katastNumRes=[]
|
||||
katastNumRes=list(Cave.objects.filter(kataster_number=int(place)))
|
||||
except ValueError:
|
||||
pass
|
||||
message = " ! - ValueError on finding place " + str(place) + " entered. " + tripdate + " - " + year
|
||||
DataIssue.objects.create(parser='logbooks', message=message)
|
||||
logdataissues["author"]=message
|
||||
officialNameRes=list(Cave.objects.filter(official_name=place))
|
||||
tripCaveRes=officialNameRes+katastNumRes
|
||||
|
||||
if len(tripCaveRes)==1:
|
||||
# print "Place " , place , "entered as" , tripCaveRes[0]
|
||||
return tripCaveRes[0]
|
||||
|
||||
elif OtherCaveName.objects.filter(name=place):
|
||||
tripCaveRes=OtherCaveName.objects.filter(name__icontains=place)[0].cave
|
||||
# print "Place " , place , "entered as" , tripCaveRes
|
||||
return tripCaveRes
|
||||
|
||||
elif len(tripCaveRes)>1:
|
||||
print(("Ambiguous place " + str(place) + " entered. Choose from " + str(tripCaveRes)))
|
||||
correctIndex=eval(input("type list index of correct cave"))
|
||||
return tripCaveRes[correctIndex]
|
||||
message = " ! - Ambiguous place " + str(place) + " entered. " + tripdate + " - " + year + " " + str(tripCaveRes)
|
||||
DataIssue.objects.create(parser='logbooks', message=message)
|
||||
logdataissues["author"]=message
|
||||
return tripCaveRes[0]
|
||||
else:
|
||||
print(("No cave found for place " , place))
|
||||
print((" " , place))
|
||||
message = " ! - No cave found for place:" + str(place) + tripdate + " - " + year
|
||||
DataIssue.objects.create(parser='logbooks', message=message)
|
||||
logdataissues["author"]=message
|
||||
return None
|
||||
|
||||
|
||||
|
||||
logentries = [] # the entire logbook for one year is a single object: a list of entries
|
||||
noncaveplaces = [ "QMplaceholder", "Journey", "Loser Plateau", "UNKNOWN", 'plateau',
|
||||
'base camp', 'basecamp', 'top camp', 'topcamp' ]
|
||||
|
Loading…
Reference in New Issue
Block a user