2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +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 subprocess
from django.forms import ModelForm
from django.db import models
from django.contrib import admin
@ -33,7 +34,13 @@ def get_related_by_wikilinks(wiki_text):
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,
filemode='w')
@ -447,7 +454,7 @@ class Cave(TroggleModel):
return unicode(self.slug())
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):
"""Given a cave and the current year, returns the next QM number."""
@ -497,7 +504,11 @@ class Cave(TroggleModel):
return res
def writeDataFile(self):
f = open(os.path.join(settings.CAVEDESCRIPTIONS, self.filename), "w")
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")
t = loader.get_template('dataformat/cave.xml')
c = Context({'cave': self})
u = t.render(c)
@ -673,7 +684,11 @@ class Entrance(TroggleModel):
return self.cached_primary_slug
def writeDataFile(self):
f = open(os.path.join(settings.ENTRANCEDESCRIPTIONS, self.filename), "w")
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")
t = loader.get_template('dataformat/entrance.xml')
c = Context({'entrance': self})
u = t.render(c)

View File

@ -50,7 +50,7 @@ def caveCmp(x, y):
def caveindex(request):
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 ]
caves1623 = list(Cave.objects.filter(area__short_name = "1623"))
caves1626 = list(Cave.objects.filter(area__short_name = "1626"))

View File

@ -30,6 +30,8 @@ SITE_ID = 1
# to load the internationalization machinery.
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
# trailing slash.