2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-26 01:01:53 +00:00

Add odt and ods mime types to our list.

Maybe this should just be read in from the real list...
This commit is contained in:
Wookey 2011-07-12 00:57:48 +01:00
parent 0a70039dee
commit b4b060a962
3 changed files with 18 additions and 16 deletions

View File

@ -84,6 +84,8 @@ def getmimetype(path):
if path.endswith(".3d"): return "application/x-survex-3d" if path.endswith(".3d"): return "application/x-survex-3d"
if path.endswith(".pos"): return "application/x-survex-pos" if path.endswith(".pos"): return "application/x-survex-pos"
if path.endswith(".err"): return "application/x-survex-err" if path.endswith(".err"): return "application/x-survex-err"
if path.endswith(".odt"): return "application/vnd.oasis.opendocument.text"
if path.endswith(".ods"): return "application/vnd.oasis.opendocument.spreadsheet"
return "" return ""
@login_required_if_public @login_required_if_public

View File

@ -55,7 +55,7 @@ Findability = 44
FindabilityComment = 45 FindabilityComment = 45
def LoadCaveTab(): def LoadCaveTab():
cavetab = open(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV"),'rU') cavetab = open(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV"),'rU')
caveReader = csv.reader(cavetab) caveReader = csv.reader(cavetab)
caveReader.next() # Strip out column headers caveReader.next() # Strip out column headers
@ -69,7 +69,7 @@ def LoadCaveTab():
logging.info("Added area "+str(newArea.short_name)+"\n") logging.info("Added area "+str(newArea.short_name)+"\n")
area1626 = models.Area.objects.filter(short_name = '1626')[0] area1626 = models.Area.objects.filter(short_name = '1626')[0]
area1623 = models.Area.objects.filter(short_name = '1623')[0] area1623 = models.Area.objects.filter(short_name = '1623')[0]
counter=0 counter=0
for line in caveReader : for line in caveReader :
if line[Area] == 'nonexistent': if line[Area] == 'nonexistent':
@ -82,11 +82,11 @@ def LoadCaveTab():
def addToArgs(CSVname, modelName): def addToArgs(CSVname, modelName):
if line[CSVname]: if line[CSVname]:
args[modelName] = line[CSVname] args[modelName] = line[CSVname]
def addToDefaultArgs(CSVname, modelName): #This has to do with the non-destructive import. These arguments will be passed as the "default" dictionary in a get_or_create def addToDefaultArgs(CSVname, modelName): #This has to do with the non-destructive import. These arguments will be passed as the "default" dictionary in a get_or_create
if line[CSVname]: if line[CSVname]:
defaultArgs[modelName] = line[CSVname] defaultArgs[modelName] = line[CSVname]
# The attributes added using "addToArgs" will be used to look up an existing cave. Those added using "addToDefaultArgs" will not. # The attributes added using "addToArgs" will be used to look up an existing cave. Those added using "addToDefaultArgs" will not.
addToArgs(KatasterNumber, "kataster_number") addToArgs(KatasterNumber, "kataster_number")
addToDefaultArgs(KatStatusCode, "kataster_code") addToDefaultArgs(KatStatusCode, "kataster_code")
@ -121,6 +121,7 @@ def LoadCaveTab():
if line[header]: if line[header]:
addToDefaultArgs(header,"description_file") addToDefaultArgs(header,"description_file")
break break
#The following checks if this cave is non-public i.e. we don't have rights to display it online. #The following checks if this cave is non-public i.e. we don't have rights to display it online.
#Noinfo was the name of the old password protected directory, so if it has that then we will #Noinfo was the name of the old password protected directory, so if it has that then we will
@ -147,7 +148,7 @@ def LoadCaveTab():
newCave.area.add(area1623) newCave.area.add(area1623)
newCave.save() newCave.save()
logging.info("Added area "+line[Area]+" to cave "+str(newCave)+"\n") logging.info("Added area "+line[Area]+" to cave "+str(newCave)+"\n")
if created and line[UnofficialName]: if created and line[UnofficialName]:
@ -155,13 +156,13 @@ def LoadCaveTab():
newUnofficialName.save() newUnofficialName.save()
logging.info("Added unofficial name "+str(newUnofficialName)+" to cave "+str(newCave)+"\n") logging.info("Added unofficial name "+str(newUnofficialName)+" to cave "+str(newCave)+"\n")
if created and line[MultipleEntrances] == '' or \ if created and line[MultipleEntrances] == '' or \
line[MultipleEntrances] == 'entrance' or \ line[MultipleEntrances] == 'entrance' or \
line[MultipleEntrances] == 'last entrance': line[MultipleEntrances] == 'last entrance':
args = {} args = {}
if line[Entrances]: if line[Entrances]:
entrance_letter = line[Entrances] entrance_letter = line[Entrances]
else: else:
@ -222,14 +223,13 @@ def LoadCaveTab():
logging.info("Added entrance "+str(newEntrance)+"\n") logging.info("Added entrance "+str(newEntrance)+"\n")
newCaveAndEntrance = models.CaveAndEntrance(cave = newCave, entrance = newEntrance, entrance_letter = entrance_letter) newCaveAndEntrance = models.CaveAndEntrance(cave = newCave, entrance = newEntrance, entrance_letter = entrance_letter)
newCaveAndEntrance.save() newCaveAndEntrance.save()
logging.info("Added CaveAndEntrance "+str(newCaveAndEntrance)+"\n") logging.info("Added CaveAndEntrance "+str(newCaveAndEntrance)+"\n")
if line[AutogenFile] != "": f = flatpages.models.EntranceRedirect(originalURL = line[AutogenFile], entrance = newEntrance)
f = flatpages.models.EntranceRedirect(originalURL = line[AutogenFile], entrance = newEntrance) f.save()
f.save()
# lookup function modelled on GetPersonExpeditionNameLookup # lookup function modelled on GetPersonExpeditionNameLookup
@ -245,9 +245,9 @@ def GetCaveLookup():
Gcavelookup[cave.kataster_number] = cave Gcavelookup[cave.kataster_number] = cave
if cave.unofficial_number: if cave.unofficial_number:
Gcavelookup[cave.unofficial_number] = cave Gcavelookup[cave.unofficial_number] = cave
Gcavelookup["tunnocks"] = Gcavelookup["258"] Gcavelookup["tunnocks"] = Gcavelookup["258"]
Gcavelookup["hauchhole"] = Gcavelookup["234"] Gcavelookup["hauchhole"] = Gcavelookup["234"]
return Gcavelookup return Gcavelookup

View File

@ -17,7 +17,7 @@ admin.autodiscover()
actualurlpatterns = patterns('', actualurlpatterns = patterns('',
url(r'^troggle$', views_other.frontpage, name="frontpage"), url(r'^$', views_other.frontpage, name="frontpage"),
url(r'^todo/$', views_other.todo, name="todo"), url(r'^todo/$', views_other.todo, name="todo"),
url(r'^caves/?$', views_caves.caveindex, name="caveindex"), url(r'^caves/?$', views_caves.caveindex, name="caveindex"),