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

Moved notable caves to settings.py, link to a script to fix permissions

This commit is contained in:
expo 2015-06-21 15:08:09 +01:00
parent 9fd6163704
commit 087a028388
3 changed files with 22 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import urllib, urlparse, string, os, datetime, logging, re import urllib, urlparse, string, os, datetime, logging, re
import subprocess
from django.forms import ModelForm from django.forms import ModelForm
from django.db import models from django.db import models
from django.contrib import admin from django.contrib import admin
@ -33,7 +34,13 @@ def get_related_by_wikilinks(wiki_text):
return res return res
logging.basicConfig(level=logging.DEBUG, try:
logging.basicConfig(level=logging.DEBUG,
filename=settings.LOGFILE,
filemode='w')
except:
subprocess.call(settings.FIX_PERMISSIONS)
logging.basicConfig(level=logging.DEBUG,
filename=settings.LOGFILE, filename=settings.LOGFILE,
filemode='w') filemode='w')
@ -447,7 +454,7 @@ class Cave(TroggleModel):
return unicode(self.slug()) return unicode(self.slug())
def get_QMs(self): def get_QMs(self):
return QM.objects.filter(found_by__cave=self) return QM.objects.filter(found_by__cave_slug=self.caveslug_set.all())
def new_QM_number(self, year=datetime.date.today().year): def new_QM_number(self, year=datetime.date.today().year):
"""Given a cave and the current year, returns the next QM number.""" """Given a cave and the current year, returns the next QM number."""
@ -497,6 +504,10 @@ class Cave(TroggleModel):
return res return res
def writeDataFile(self): def writeDataFile(self):
try:
f = open(os.path.join(settings.CAVEDESCRIPTIONS, self.filename), "w")
except:
subprocess.call(settings.FIX_PERMISSIONS)
f = open(os.path.join(settings.CAVEDESCRIPTIONS, self.filename), "w") f = open(os.path.join(settings.CAVEDESCRIPTIONS, self.filename), "w")
t = loader.get_template('dataformat/cave.xml') t = loader.get_template('dataformat/cave.xml')
c = Context({'cave': self}) c = Context({'cave': self})
@ -673,6 +684,10 @@ class Entrance(TroggleModel):
return self.cached_primary_slug return self.cached_primary_slug
def writeDataFile(self): def writeDataFile(self):
try:
f = open(os.path.join(settings.ENTRANCEDESCRIPTIONS, self.filename), "w")
except:
subprocess.call(settings.FIX_PERMISSIONS)
f = open(os.path.join(settings.ENTRANCEDESCRIPTIONS, self.filename), "w") f = open(os.path.join(settings.ENTRANCEDESCRIPTIONS, self.filename), "w")
t = loader.get_template('dataformat/entrance.xml') t = loader.get_template('dataformat/entrance.xml')
c = Context({'entrance': self}) c = Context({'entrance': self})

View File

@ -50,7 +50,7 @@ def caveCmp(x, y):
def caveindex(request): def caveindex(request):
caves = Cave.objects.all() caves = Cave.objects.all()
notablecavehrefs = [ "161", "204", "258", "76", "107" ] # could detect notability by trips and notability of people who have been down them notablecavehrefs = settings.NOTABLECAVESHREFS
notablecaves = [Cave.objects.get(kataster_number=kataster_number) for kataster_number in notablecavehrefs ] notablecaves = [Cave.objects.get(kataster_number=kataster_number) for kataster_number in notablecavehrefs ]
caves1623 = list(Cave.objects.filter(area__short_name = "1623")) caves1623 = list(Cave.objects.filter(area__short_name = "1623"))
caves1626 = list(Cave.objects.filter(area__short_name = "1626")) caves1626 = list(Cave.objects.filter(area__short_name = "1626"))

View File

@ -30,6 +30,8 @@ SITE_ID = 1
# to load the internationalization machinery. # to load the internationalization machinery.
USE_I18N = True USE_I18N = True
FIX_PERMISSIONS = []
NOTABLECAVESHREFS = [ "161", "204", "258", "76", "107", "264" ]
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash. # trailing slash.