diff options
71 files changed, 362 insertions, 210 deletions
diff --git a/core/admin.py b/core/admin.py index 6e9d058..305613c 100644 --- a/core/admin.py +++ b/core/admin.py @@ -4,7 +4,7 @@ from django.forms import ModelForm import django.forms as forms from django.http import HttpResponse from django.core import serializers -from core.views_other import downloadLogbook +from troggle.core.views_other import downloadLogbook #from troggle.reversion.admin import VersionAdmin #django-reversion version control @@ -12,8 +12,8 @@ class TroggleModelAdmin(admin.ModelAdmin): def save_model(self, request, obj, form, change): """overriding admin save to fill the new_since parsing_field""" - obj.new_since_parsing=True - obj.save() + obj.new_since_parsing=True + obj.save() class Media: js = ('jquery/jquery.min.js','js/QM_helper.js') diff --git a/core/context.py b/core/context.py index a77de49..6b3b928 100644 --- a/core/context.py +++ b/core/context.py @@ -1,5 +1,5 @@ from django.conf import settings -from core.models import Expedition +from troggle.core.models import Expedition def troggle_context(request): return { 'settings':settings, 'Expedition':Expedition }
\ No newline at end of file diff --git a/core/forms.py b/core/forms.py index 4530b0e..ae046b5 100644 --- a/core/forms.py +++ b/core/forms.py @@ -62,7 +62,7 @@ class EntranceForm(ModelForm): -CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=('cave')) +CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=('cave',)) class EntranceLetterForm(ModelForm): class Meta: @@ -136,7 +136,7 @@ def getTripForm(expedition): names = ["-----"] + names name = forms.ChoiceField([(n, n) for n in names]) TU = forms.FloatField(required=False) - author = forms.BooleanField(required=False) + author = forms.BooleanField(required=False, default=False) PersonTripFormSet = formset_factory(PersonTripForm, extra=1) diff --git a/core/models.py b/core/models.py index 8527015..a78e49b 100644 --- a/core/models.py +++ b/core/models.py @@ -15,7 +15,7 @@ from django.template import Context, loader import settings getcontext().prec=2 #use 2 significant figures for decimal calculations -from models_survex import * +from troggle.core.models_survex import * def get_related_by_wikilinks(wiki_text): @@ -55,7 +55,7 @@ class TroggleModel(models.Model): return urlparse.urljoin(settings.URL_ROOT, "/admin/core/" + self.object_name().lower() + "/" + str(self.pk)) class Meta: - abstract = True + abstract = True class TroggleImageModel(ImageModel): new_since_parsing = models.BooleanField(default=False, editable=False) @@ -68,7 +68,7 @@ class TroggleImageModel(ImageModel): class Meta: - abstract = True + abstract = True # # single Expedition, usually seen by year @@ -125,7 +125,7 @@ class ExpeditionDay(TroggleModel): class Person(TroggleModel): first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) - is_vfho = models.BooleanField(help_text="VFHO is the Vereines für Höhlenkunde in Obersteier, a nearby Austrian caving club.") + is_vfho = models.BooleanField(help_text="VFHO is the Vereines für Höhlenkunde in Obersteier, a nearby Austrian caving club.", default=False) mug_shot = models.CharField(max_length=100, blank=True,null=True) blurb = models.TextField(blank=True,null=True) @@ -134,13 +134,13 @@ class Person(TroggleModel): #the below have been removed and made methods. I'm not sure what the b in bisnotable stands for. - AC 16 Feb #notability = models.FloatField() # for listing the top 20 people - #bisnotable = models.BooleanField() + #bisnotable = models.BooleanField(default=False) user = models.OneToOneField(User, null=True, blank=True) def get_absolute_url(self): return urlparse.urljoin(settings.URL_ROOT,reverse('person',kwargs={'first_name':self.first_name,'last_name':self.last_name})) class Meta: - verbose_name_plural = "People" + verbose_name_plural = "People" class Meta: ordering = ('orderref',) # "Wookey" makes too complex for: ('last_name', 'first_name') @@ -264,13 +264,13 @@ class LogbookEntry(TroggleModel): if item == "cave": #Allow a logbookentries cave to be directly accessed despite not having a proper foreignkey return CaveSlug.objects.get(slug = self.cave_slug).cave return super(LogbookEntry, self).__getattribute__(item) - + def __init__(self, *args, **kwargs): - if "cave" in kwargs.keys(): - if kwargs["cave"] is not None: - kwargs["cave_slug"] = CaveSlug.objects.get(cave = kwargs["cave"], primary = True).slug - kwargs.pop("cave") - return super(LogbookEntry, self).__init__(*args, **kwargs) + if "cave" in kwargs.keys(): + if kwargs["cave"] is not None: + kwargs["cave_slug"] = CaveSlug.objects.get(cave=kwargs["cave"], primary=True).slug + kwargs.pop("cave") + return super(LogbookEntry, self).__init__(*args, **kwargs) def isLogbookEntry(self): # Function used in templates return True @@ -312,7 +312,7 @@ class PersonTrip(TroggleModel): #date = models.DateField() #MJG wants to KILL THIS (redundant information) time_underground = models.FloatField(help_text="In decimal hours") logbook_entry = models.ForeignKey(LogbookEntry) - is_logbook_entry_author = models.BooleanField() + is_logbook_entry_author = models.BooleanField(default=False) # sequencing by person (difficult to solve locally) @@ -371,7 +371,7 @@ class CaveAndEntrance(models.Model): class CaveSlug(models.Model): cave = models.ForeignKey('Cave') slug = models.SlugField(max_length=50, unique = True) - primary = models.BooleanField() + primary = models.BooleanField(default=False) class Cave(TroggleModel): @@ -520,11 +520,11 @@ class Cave(TroggleModel): areas = self.area.all() lowestareas = list(areas) for area in areas: - if area.parent in areas: - try: - lowestareas.remove(area.parent) - except: - pass + if area.parent in areas: + try: + lowestareas.remove(area.parent) + except: + pass return lowestareas[0] def getCaveByReference(reference): @@ -546,7 +546,7 @@ class OtherCaveName(TroggleModel): class EntranceSlug(models.Model): entrance = models.ForeignKey('Entrance') slug = models.SlugField(max_length=50, unique = True) - primary = models.BooleanField() + primary = models.BooleanField(default=False) class Entrance(TroggleModel): name = models.CharField(max_length=100, blank=True,null=True) @@ -608,21 +608,21 @@ class Entrance(TroggleModel): s = SurvexStation.objects.lookup(self.tag_station) return r + "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z) except: - return r + "%s Tag Station not in dataset" % self.tag_station + return r + "%s Tag Station not in dataset" % self.tag_station if self.exact_station: try: s = SurvexStation.objects.lookup(self.exact_station) return r + "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z) except: - return r + "%s Exact Station not in dataset" % self.tag_station + return r + "%s Exact Station not in dataset" % self.tag_station if self.other_station: try: s = SurvexStation.objects.lookup(self.other_station) return r + "%0.0fE %0.0fN %0.0fAlt %s" % (s.x, s.y, s.z, self.other_description) except: - return r + "%s Other Station not in dataset" % self.tag_station + return r + "%s Other Station not in dataset" % self.tag_station if self.FINDABLE_CHOICES == "S": - r += "ERROR, Entrance has been surveyed but has no survex point" + r += "ERROR, Entrance has been surveyed but has no survex point" if self.bearings: return r + self.bearings return r @@ -657,7 +657,7 @@ class Entrance(TroggleModel): return SurvexStation.objects.lookup(self.tag_station) def needs_surface_work(self): - return self.findability != "S" or not self.has_photo or self.marking != "T" + return self.findability != "S" or not self.has_photo or self.marking != "T" def get_absolute_url(self): @@ -754,10 +754,10 @@ class QM(TroggleModel): comment=models.TextField(blank=True,null=True) def __unicode__(self): - return u"%s %s" % (self.code(), self.grade) + return u"%s %s" % (self.code(), self.grade) def code(self): - return u"%s-%s-%s" % (unicode(self.found_by.cave)[6:], self.found_by.date.year, self.number) + return u"%s-%s-%s" % (unicode(self.found_by.cave)[6:], self.found_by.date.year, 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 @@ -770,7 +770,7 @@ class QM(TroggleModel): return QM.objects.get(id=self.id-1) def wiki_link(self): - return u"%s%s%s" % ('[[QM:',self.code(),']]') + return u"%s%s%s" % ('[[QM:',self.code(),']]') photoFileStorage = FileSystemStorage(location=settings.PHOTOS_ROOT, base_url=settings.PHOTOS_URL) class DPhoto(TroggleImageModel): @@ -825,7 +825,7 @@ class ScannedImage(TroggleImageModel): #This is an ugly hack to deal with the #s in our survey scan paths. The correct thing is to write a custom file storage backend which calls urlencode on the name for making file.url but not file.path. def correctURL(self): - return string.replace(self.file.url,r'#',r'%23') + return string.replace(self.file.url,r'#',r'%23') def __unicode__(self): return get_scan_path(self,'') @@ -852,10 +852,10 @@ class Survey(TroggleModel): return self.expedition.year+"#"+"%02d" % int(self.wallet_number) def notes(self): - return self.scannedimage_set.filter(contents='notes') + return self.scannedimage_set.filter(contents='notes') def plans(self): - return self.scannedimage_set.filter(contents='plan') + return self.scannedimage_set.filter(contents='plan') def elevations(self): - return self.scannedimage_set.filter(contents='elevation') + return self.scannedimage_set.filter(contents='elevation') diff --git a/core/models_survex.py b/core/models_survex.py index 645d851..f6b3284 100644 --- a/core/models_survex.py +++ b/core/models_survex.py @@ -213,7 +213,7 @@ class SurvexScanSingle(models.Model): class TunnelFile(models.Model): tunnelpath = models.CharField(max_length=200) tunnelname = models.CharField(max_length=200) - bfontcolours = models.BooleanField() + bfontcolours = models.BooleanField(default=False) survexscansfolders = models.ManyToManyField("SurvexScansFolder") survexscans = models.ManyToManyField("SurvexScanSingle") survexblocks = models.ManyToManyField("SurvexBlock") diff --git a/core/templatetags/wiki_markup.py b/core/templatetags/wiki_markup.py index 4087b12..3bc5b07 100644 --- a/core/templatetags/wiki_markup.py +++ b/core/templatetags/wiki_markup.py @@ -3,7 +3,7 @@ from django.utils.html import conditional_escape from django.template.defaultfilters import stringfilter from django.utils.safestring import mark_safe from django.conf import settings -from core.models import QM, DPhoto, LogbookEntry, Cave +from troggle.core.models import QM, DPhoto, LogbookEntry, Cave import re, urlparse register = template.Library() diff --git a/core/views_caves.py b/core/views_caves.py index db3e52d..f6a2bcf 100644 --- a/core/views_caves.py +++ b/core/views_caves.py @@ -17,7 +17,8 @@ import re, urlparse from django.shortcuts import get_object_or_404 import settings -import Image, ImageDraw, ImageFont, string, os, sys, subprocess +from PIL import Image, ImageDraw, ImageFont +import string, os, sys def getCave(cave_id): """Returns a cave object when given a cave name or number. It is used by views including cavehref, ent, and qm.""" diff --git a/core/views_other.py b/core/views_other.py index beecc46..67cd01a 100644 --- a/core/views_other.py +++ b/core/views_other.py @@ -9,7 +9,7 @@ import re from django.http import HttpResponse, HttpResponseRedirect from django.core.urlresolvers import reverse from utils import render_with_context -from core.models import * +from troggle.core.models import * from troggle.helper import login_required_if_public def showrequest(request): diff --git a/core/views_survex.py b/core/views_survex.py index 3c53625..28a4370 100644 --- a/core/views_survex.py +++ b/core/views_survex.py @@ -257,7 +257,7 @@ def identifycavedircontents(gcavedir): # perhaps should use the database and have a reload button for it def survexcaveslist(request): cavesdir = os.path.join(settings.SURVEX_DATA, "caves") - cavesdircontents = { } + #cavesdircontents = { } onefilecaves = [ ] multifilecaves = [ ] diff --git a/databaseReset.py b/databaseReset.py index 0964b79..8e2772c 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -8,8 +8,8 @@ from django.db import connection from django.contrib.auth.models import User from django.http import HttpResponse from django.core.urlresolvers import reverse -from core.models import Cave, Entrance -import flatpages.models +from troggle.core.models import Cave, Entrance +import troggle.flatpages.models databasename=settings.DATABASES['default']['NAME'] expouser=settings.EXPOUSER diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..c11a8b0 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,26 @@ +FROM python:2.7-stretch + +#COPY backports.list /etc/apt/sources.list.d/ + +RUN apt-get -y update && apt-get install -y mercurial fonts-freefont-ttf locales survex + +#RUN apt-get -y -t -backports install survex + +# Set the locale +RUN locale-gen en_GB.UTF-8 +ENV LANG en_GB.UTF-8 +ENV LANGUAGE en_GB:en +ENV LC_ALL en_GB.UTF-8 + +WORKDIR /opt/expo/troggle +COPY requirements.txt . + +RUN pip install --upgrade pip + +RUN pip install -r requirements.txt + +EXPOSE 8000 + +WORKDIR /expo/troggle + +#CMD ["python","manage.py","runserver","0.0.0.0:8000"]
\ No newline at end of file diff --git a/docker/Dockerfile-django-1.4.22-wheezy b/docker/Dockerfile-django-1.4.22-wheezy new file mode 100644 index 0000000..f6d5554 --- /dev/null +++ b/docker/Dockerfile-django-1.4.22-wheezy @@ -0,0 +1,18 @@ +FROM python:2.7-wheezy + +RUN apt-get -y update && apt-get install -y mercurial fonts-freefont-ttf survex locales + +# Set the locale +RUN locale-gen en_GB.UTF-8 +ENV LANG en_GB.UTF-8 +ENV LANGUAGE en_GB:en +ENV LC_ALL en_GB.UTF-8 + +WORKDIR /opt/expo/troggle +COPY requirements.txt . + +RUN pip install -r requirements.txt + +EXPOSE 8000 + +#CMD ["python","manage.py","runserver","0.0.0.0:8000"]
\ No newline at end of file diff --git a/docker/Dockerfile-django-1.5.12-jessie b/docker/Dockerfile-django-1.5.12-jessie new file mode 100644 index 0000000..2cf1a51 --- /dev/null +++ b/docker/Dockerfile-django-1.5.12-jessie @@ -0,0 +1,26 @@ +FROM python:2.7-jessie + +COPY backports.list /etc/apt/sources.list.d/ + +RUN apt-get -y update && apt-get install -y mercurial fonts-freefont-ttf locales + +RUN apt-get -y -t jessie-backports install survex + +# Set the locale +RUN locale-gen en_GB.UTF-8 +ENV LANG en_GB.UTF-8 +ENV LANGUAGE en_GB:en +ENV LC_ALL en_GB.UTF-8 + +WORKDIR /opt/expo/troggle +COPY requirements.txt . + +RUN pip install --upgrade pip + +RUN pip install -r requirements.txt + +EXPOSE 8000 + +WORKDIR /expo/troggle + +#CMD ["python","manage.py","runserver","0.0.0.0:8000"]
\ No newline at end of file diff --git a/docker/backports.list b/docker/backports.list new file mode 100644 index 0000000..c29532b --- /dev/null +++ b/docker/backports.list @@ -0,0 +1 @@ +deb http://ftp.debian.org/debian jessie-backports main
\ No newline at end of file diff --git a/docker/docker-cmd b/docker/docker-cmd new file mode 100644 index 0000000..2898a60 --- /dev/null +++ b/docker/docker-cmd @@ -0,0 +1,7 @@ +cd docker + +docker run -it --name expo-mysql -e MYSQL_ROOT_PASSWORD=expo123 mariadb + +docker build -t expo/troggle:django-1.5.12 . + +docker run -it --rm --link expo-mysql:mysql -v /home/sam/expo:/expo expo/troggle:django-1.5.12 /bin/bash
\ No newline at end of file diff --git a/docker/requirements.txt b/docker/requirements.txt new file mode 100644 index 0000000..15ab393 --- /dev/null +++ b/docker/requirements.txt @@ -0,0 +1,7 @@ +Django==1.7.11 +django-registration==2.1.2 +mysql +imagekit +Image +django-tinymce==2.7.0 +smartencoding diff --git a/docker/requirements.txt.dj-1.4.22 b/docker/requirements.txt.dj-1.4.22 new file mode 100644 index 0000000..dac7b30 --- /dev/null +++ b/docker/requirements.txt.dj-1.4.22 @@ -0,0 +1,7 @@ +Django==1.4.22 +django-registration==0.8 +mysql +imagekit +Image +django-tinymce==1.5.3 +smartencoding diff --git a/docker/requirements.txt.dj-1.5.12 b/docker/requirements.txt.dj-1.5.12 new file mode 100644 index 0000000..9f9b5ae --- /dev/null +++ b/docker/requirements.txt.dj-1.5.12 @@ -0,0 +1,7 @@ +Django==1.5.12 +django-registration==1.0 +mysql +imagekit +Image +django-tinymce==1.5.3 +smartencoding diff --git a/docker/requirements.txt.dj-1.6.11 b/docker/requirements.txt.dj-1.6.11 new file mode 100644 index 0000000..b26bc10 --- /dev/null +++ b/docker/requirements.txt.dj-1.6.11 @@ -0,0 +1,7 @@ +Django==1.6.11 +django-registration==1.0 +mysql +imagekit +Image +django-tinymce==1.5.3 +smartencoding diff --git a/flatpages/models.py b/flatpages/models.py index 1c97851..7631881 100644 --- a/flatpages/models.py +++ b/flatpages/models.py @@ -1,5 +1,5 @@ from django.db import models -from core.models import Cave, Entrance +from troggle.core.models import Cave, Entrance class Redirect(models.Model): originalURL = models.CharField(max_length=200, unique=True) diff --git a/flatpages/views.py b/flatpages/views.py index 0b4a8a0..6503d40 100644 --- a/flatpages/views.py +++ b/flatpages/views.py @@ -75,7 +75,7 @@ def flatpage(request, path): body.strip return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'title': title, 'body': body, 'homepage': (path == "index.htm")}) else: - return HttpResponse(o.read(), mimetype=getmimetype(path)) + return HttpResponse(o.read(), content_type=getmimetype(path)) def getmimetype(path): if path.lower().endswith(".png"): return "image/png" diff --git a/localsettingspotatohut.py b/localsettingspotatohut.py index a9c39d5..5346415 100644 --- a/localsettingspotatohut.py +++ b/localsettingspotatohut.py @@ -41,6 +41,9 @@ EXPOWEB_URL = 'http://expo/' SURVEYS_URL = 'http://expo/survey_scans/' MEDIA_URL = '/' + DIR_ROOT + 'site_media/' +STATIC_URL = URL_ROOT +STATIC_ROOT = DIR_ROOT + MEDIA_ROOT = REPOS_ROOT_PATH + '/troggle/media/' MEDIA_ADMIN_DIR = '/usr/lib/python2.7/site-packages/django/contrib/admin/media/' diff --git a/localsettingsserver.py b/localsettingsserver.py index 6edb968..b0cd49d 100644 --- a/localsettingsserver.py +++ b/localsettingsserver.py @@ -43,6 +43,9 @@ EXPOWEB_URL = 'http://expo.survex.com/' SURVEYS_URL = 'http://expo.survex.com/survey_scans/' MEDIA_URL = URL_ROOT + DIR_ROOT + 'site_media/' +STATIC_URL = URL_ROOT +STATIC_ROOT = DIR_ROOT + MEDIA_ROOT = REPOS_ROOT_PATH + '/troggle/media/' MEDIA_ADMIN_DIR = '/usr/lib/python2.7/site-packages/django/contrib/admin/media/' diff --git a/localsettingsubuntu.py b/localsettingsubuntu.py index 9779555..c50a374 100644 --- a/localsettingsubuntu.py +++ b/localsettingsubuntu.py @@ -48,6 +48,9 @@ MEDIA_URL = URL_ROOT + DIR_ROOT + '/site_media/' MEDIA_ROOT = REPOS_ROOT_PATH + '/troggle/media/' MEDIA_ADMIN_DIR = '/usr/lib/python2.4/site-packages/django/contrib/admin/media/' +STATIC_URL = URL_ROOT +STATIC_ROOT = DIR_ROOT + JSLIB_URL = URL_ROOT + 'javascript/' TINY_MCE_MEDIA_ROOT = '/usr/share/tinymce/www/' diff --git a/localsettingswindows.py b/localsettingswindows.py index bb689e6..110bd36 100644 --- a/localsettingswindows.py +++ b/localsettingswindows.py @@ -38,6 +38,9 @@ PYTHON_PATH = 'C:\\expoweb\\troggle\\' MEDIA_ROOT = 'C:/Expo/expoweb/troggle/media/' MEDIA_URL = URL_ROOT + DIR_ROOT + 'site_media/' +STATIC_URL = URL_ROOT +STATIC_ROOT = DIR_ROOT + #FILES = "http://framos.lawoftheland.co.uk/troggle/survey_files/" EMAIL_HOST = "smtp.gmail.com" @@ -1,11 +1,10 @@ #!/usr/bin/env python -from django.core.management import execute_manager -try: - import settings # Assumed to be in the same directory. -except ImportError: - import sys - sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) - sys.exit(1) +import os +import sys if __name__ == "__main__": - execute_manager(settings) + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/middleware.py b/middleware.py index 15dd039..7c27500 100644 --- a/middleware.py +++ b/middleware.py @@ -19,7 +19,7 @@ class SmartAppendSlashMiddleware(object): """ # Check for a redirect based on settings.SMART_APPEND_SLASH - host = http.get_host(request) + host = http.HttpRequest.get_host(request) old_url = [host, request.path] new_url = old_url[:] # Append a slash if SMART_APPEND_SLASH is set and the resulting URL diff --git a/parsers/QMs.py b/parsers/QMs.py index f9a6d89..efc8cd6 100644 --- a/parsers/QMs.py +++ b/parsers/QMs.py @@ -2,7 +2,7 @@ import csv from django.conf import settings -from core.models import QM, LogbookEntry, Cave +from troggle.core.models import QM, LogbookEntry, Cave from datetime import * from utils import save_carefully import re, os @@ -87,7 +87,7 @@ def parseCaveQMs(cave,inputFile): continue def parse_KH_QMs(kh, inputFile): - """import QMs from the 1623-161 (Kaninchenhöhle) html pages + """import QMs from the 1623-161 (Kaninchenh�hle) html pages """ khQMs=open(settings.EXPOWEB+inputFile,'r') khQMs=khQMs.readlines() diff --git a/parsers/cavetab.py b/parsers/cavetab.py index 9f04105..99202d5 100644 --- a/parsers/cavetab.py +++ b/parsers/cavetab.py @@ -4,7 +4,7 @@ from django.conf import settings import csv, time, re, os, logging from utils import save_carefully from django.core.urlresolvers import reverse -import flatpages.models +import troggle.flatpages.models ##format of CAVETAB2.CSV is KatasterNumber = 0 diff --git a/parsers/logbooks.py b/parsers/logbooks.py index 4180345..cb40f58 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -1,7 +1,7 @@ #.-*- coding: utf-8 -*- from django.conf import settings -import core.models as models +import troggle.core.models as models from parsers.people import GetPersonExpeditionNameLookup from parsers.cavetab import GetCaveLookup diff --git a/parsers/people.py b/parsers/people.py index 7898ccd..bc18472 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -1,7 +1,7 @@ #.-*- coding: utf-8 -*- from django.conf import settings -import core.models as models +import troggle.core.models as models import csv, re, datetime, os, shutil from utils import save_carefully diff --git a/parsers/subcaves.py b/parsers/subcaves.py index 6905d0a..739af44 100644 --- a/parsers/subcaves.py +++ b/parsers/subcaves.py @@ -6,7 +6,7 @@ import sys, os import os, re, logging from django.conf import settings -from core.models import Subcave, Cave +from troggle.core.models import Subcave, Cave from utils import save_carefully def getLinksInCaveDescription(cave): diff --git a/parsers/survex.py b/parsers/survex.py index ed70a4b..0c108ac 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -206,7 +206,7 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines): survexblock.MakeSurvexStation(line.split()[0]) else: - if not cmd in [ "sd", "include", "units", "entrance", "data", "flags", "title", "export", "instrument", "calibrate", "set", "infer", "alias" ]: + if not cmd in [ "sd", "include", "units", "entrance", "data", "flags", "title", "export", "instrument", "calibrate", "set", "infer", "alias", "ref" ]: print ("Unrecognised command in line:", cmd, line, survexblock) diff --git a/parsers/surveys.py b/parsers/surveys.py index df73ae0..26e46f9 100644 --- a/parsers/surveys.py +++ b/parsers/surveys.py @@ -3,7 +3,7 @@ import sys, os, types, logging, stat #from troggle import * #os.environ['DJANGO_SETTINGS_MODULE']='troggle.settings' import settings -from core.models import * +from troggle.core.models import * from PIL import Image #import settings #import core.models as models @@ -138,7 +138,7 @@ def parseSurveyScans(expedition, logfile=None): # dead def parseSurveys(logfile=None): - readSurveysFromCSV() + readSurveysFromCSV() for expedition in Expedition.objects.filter(year__gte=2000): #expos since 2000, because paths and filenames were nonstandard before then parseSurveyScans(expedition) @@ -298,7 +298,3 @@ def LoadTunnelFiles(): for tunnelfile in TunnelFile.objects.all(): SetTunnelfileInfo(tunnelfile) - - - - diff --git a/profiles/urls.py b/profiles/urls.py index a703e9b..d10894d 100644 --- a/profiles/urls.py +++ b/profiles/urls.py @@ -22,7 +22,7 @@ redirect. If you don't use that name, remember to explicitly pass """ -from django.conf.urls.defaults import * +from django.conf.urls import * from profiles import views diff --git a/profiles/utils.py b/profiles/utils.py index faacfcb..c2dfd61 100644 --- a/profiles/utils.py +++ b/profiles/utils.py @@ -7,7 +7,13 @@ site-specific user profile model specified in the from django import forms from django.conf import settings -from django.contrib.auth.models import SiteProfileNotAvailable +#from django.contrib.auth.models import SiteProfileNotAvailable + +try: + from django.contrib.auth.models import SiteProfileNotAvailable +except ImportError: # django >= 1.7 + SiteProfileNotAvailable = type('SiteProfileNotAvailable', (Exception,), {}) + from django.db.models import get_model diff --git a/profiles/views.py b/profiles/views.py index dec1172..b5b7143 100644 --- a/profiles/views.py +++ b/profiles/views.py @@ -11,34 +11,34 @@ from django.http import HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.shortcuts import render_to_response from django.template import RequestContext -from django.views.generic.list_detail import object_list +from django.views.generic.list import ListView from django import forms -from core.models import Person +from troggle.core.models import Person from profiles import utils from django.conf import settings class SelectPersonForm(forms.Form): #This and the select_profile view - person = forms.ModelChoiceField(queryset=Person.objects.all()) + person = forms.ModelChoiceField(queryset=Person.objects.all()) def select_profile(request): if request.method == 'POST': - form = SelectPersonForm(request.POST) - if form.is_valid(): - profile_obj=form.cleaned_data['person'] - profile_obj.user=request.user - profile_obj.save() - return HttpResponseRedirect(profile_obj.get_absolute_url()) + form = SelectPersonForm(request.POST) + if form.is_valid(): + profile_obj=form.cleaned_data['person'] + profile_obj.user=request.user + profile_obj.save() + return HttpResponseRedirect(profile_obj.get_absolute_url()) else: form = SelectPersonForm() - context = RequestContext(request) + context = RequestContext(request) return render_to_response('profiles/select_profile.html', { 'form':form,}, - context_instance=context - ) + context_instance=context + ) def create_profile(request, form_class=None, success_url=None, diff --git a/settings.py b/settings.py index ca3011e..1159f4e 100644 --- a/settings.py +++ b/settings.py @@ -2,11 +2,16 @@ from localsettings import * #inital localsettings call so that urljoins work import os import urlparse import django -# Django settings for troggle project. +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + +# Django settings for troggle project. DEBUG = True TEMPLATE_DEBUG = DEBUG +ALLOWED_HOSTS = [] + ADMINS = ( # ('Your Name', 'your_email@domain.com'), ) @@ -18,6 +23,7 @@ MANAGERS = ADMINS # although not all choices may be available on all operating systems. # If running in a Windows environment this must be set to the same as your # system time zone. +USE_TZ = True TIME_ZONE = 'Europe/London' # Language code for this installation. All choices can be found here: @@ -29,6 +35,7 @@ SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True +USE_L10N = True FIX_PERMISSIONS = [] NOTABLECAVESHREFS = [ "161", "204", "258", "76", "107", "264" ] @@ -68,21 +75,6 @@ TEMPLATE_CONTEXT_PROCESSORS = ( authmodule, "core.context.troggle_context", ) LOGIN_REDIRECT_URL = '/' -MIDDLEWARE_CLASSES = ( - 'django.middleware.common.CommonMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.redirects.middleware.RedirectFallbackMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'troggle.middleware.SmartAppendSlashMiddleware' -) - -ROOT_URLCONF = 'troggle.urls' - -ACCOUNT_ACTIVATION_DAYS=3 - -AUTH_PROFILE_MODULE = 'core.person' - INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', @@ -90,19 +82,45 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.redirects', + 'django.contrib.messages', + 'django.contrib.staticfiles', #'troggle.photologue', #'troggle.reversion', #'django_evolution', - 'troggle.registration', + 'tinymce', + 'registration', 'troggle.profiles', 'troggle.core', 'troggle.flatpages', 'troggle.imagekit', ) +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.redirects.middleware.RedirectFallbackMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'troggle.middleware.SmartAppendSlashMiddleware' +) + +ROOT_URLCONF = 'troggle.urls' + +WSGI_APPLICATION = 'troggle.wsgi.application' + +ACCOUNT_ACTIVATION_DAYS=3 + +AUTH_PROFILE_MODULE = 'core.person' + QM_PATTERN="\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]" TINYMCE_JS_URL = 'http://debug.example.org/tiny_mce/tiny_mce_src.js' + +#TINYMCE_JS_URL = os.path.join(MEDIA_URL, "tinybibble_mce.js") + TINYMCE_DEFAULT_CONFIG = { 'plugins': "table,spellchecker,paste,searchreplace", 'theme': "advanced", diff --git a/templates/base.html b/templates/base.html index 8a3977e..11568af 100644 --- a/templates/base.html +++ b/templates/base.html @@ -22,9 +22,9 @@ {% if user.username %} You are logged in as {{ user.username }} {% if user.person %}(<a href="{{ user.person.get_absolute_url }}">{{ user.person }}</a>) - {% else %}<a href={% url profiles_select_profile %}>sort your profile</a> + {% else %}<a href={% url "profiles_select_profile" %}>sort your profile</a> {% endif %}. - | <a href="{% url auth_logout %}">Log out</a> {% else %} <a href="{% url registration_register %}">Sign up</a> | <a href="{% url auth_login %}">Log in</a> {% endif %} + | <a href="{% url "auth_logout" %}">Log out</a> {% else %} <a href="{% url "registration_register" %}">Sign up</a> | <a href="{% url "auth_login" %}">Log in</a> {% endif %} {% endblock%} {% block editLink %} @@ -32,17 +32,17 @@ </div> </div> <div class="toolbarlinks"> - <a href="{% url survexcaveslist %}">All Survex</a> | - <a href="{% url surveyscansfolders %}">Scans</a> | - <a href="{% url tunneldata %}">Tunneldata</a> | - <a href="{% url survexcavessingle 107 %}">107</a> | - <a href="{% url survexcavessingle 161 %}">161</a> | - <a href="{% url survexcavessingle 204 %}">204</a> | - <a href="{% url survexcavessingle 258 %}">258</a> | - <a href="{% url survexcavessingle 264 %}">264</a> | - <a href="{% url expedition 2014 %}">Expo2014</a> | - <a href="{% url expedition 2015 %}">Expo2015</a> | - <a href="{% url expedition 2016 %}">Expo2016</a> | + <a href="{% url "survexcaveslist" %}">All Survex</a> | + <a href="{% url "surveyscansfolders" %}">Scans</a> | + <a href="{% url "tunneldata" %}">Tunneldata</a> | + <a href="{% url "survexcavessingle" 107 %}">107</a> | + <a href="{% url "survexcavessingle" 161 %}">161</a> | + <a href="{% url "survexcavessingle" 204 %}">204</a> | + <a href="{% url "survexcavessingle" 258 %}">258</a> | + <a href="{% url "survexcavessingle" 264 %}">264</a> | + <a href="{% url "expedition" 2014 %}">Expo2014</a> | + <a href="{% url "expedition" 2015 %}">Expo2015</a> | + <a href="{% url "expedition" 2016 %}">Expo2016</a> | <a href="/admin/">Django admin</a> </div> @@ -85,24 +85,24 @@ <li><a id="expoWebsiteLink" href="http://expo.survex.com">Expedition website</a></li> </ul> </li> - <li><a href="{% url frontpage %}">Troggle front page</a></li> - <li><a id="cavesLink" href="{% url caveindex %}">caves</a></li> - <li><a id="caversLink" href="{% url personindex %}">cavers</a></li> + <li><a href="{% url "frontpage" %}">Troggle front page</a></li> + <li><a id="cavesLink" href="{% url "caveindex" %}">caves</a></li> + <li><a id="caversLink" href="{% url "personindex" %}">cavers</a></li> <li><a href="#">expeditions</a> <ul class="sub_menu"> <li><a id="expeditionsLink" href="{{ Expedition.objects.latest.get_absolute_url }}">newest</a></li> - <li><a id="expeditionsLink" href="{% url expeditions %}">list all</a></li> + <li><a id="expeditionsLink" href="{% url "expeditions" %}">list all</a></li> </ul> </li> - <li><a id="surveyBinderLink" href="{% url survey %}">survey binder</a></li> + <li><a id="surveyBinderLink" href="{% url "survey" %}">survey binder</a></li> <li><a href="#">diversions</a> <ul class="sub_menu"> - <li><a href="{% url stats %}">statistics</a></li> + <li><a href="{% url "stats" %}">statistics</a></li> </ul> </li> <li><a href="#">admin</a> <ul class="sub_menu"> - <li><a id="cuccLink" href="{% url controlpanel %}">Import / export data</a></li> + <li><a id="cuccLink" href="{% url "controlpanel" %}">Import / export data</a></li> <li><a id="expoWebsiteLink" href="{{ settings.URL_ROOT }}admin">Troggle administration pages</a></li> </ul> <li class="toggleMenu"><a href="#">hide menu</a></li> diff --git a/templates/cave.html b/templates/cave.html index a8321a8..6589a48 100644 --- a/templates/cave.html +++ b/templates/cave.html @@ -469,7 +469,7 @@ div#scene { {{ ent.entrance_letter|safe }} {% if ent.entrance.name %} {{ ent.entrance.name|safe }} - {% endif %}<a href="{% url editentrance cave.slug ent.entrance.slug %}">Edit</a> + {% endif %}<a href="{% url "editentrance" cave.slug ent.entrance.slug %}">Edit</a> <dl> {% if ent.entrance.marking %} <dt>Marking</dt><dd>{{ ent.entrance.marking_val|safe }}</dd> @@ -529,7 +529,7 @@ div#scene { </ul> {% endif %}</p> -<a href="{% url newentrance cave.slug %}">New Entrance</a> +<a href="{% url "newentrance" cave.slug %}">New Entrance</a> </div> <div id="Description"> diff --git a/templates/cave_entrances.html b/templates/cave_entrances.html index 5b70196..e3a571f 100644 --- a/templates/cave_entrances.html +++ b/templates/cave_entrances.html @@ -7,7 +7,7 @@ {{ ent.entrance_letter|safe }} {% if ent.entrance.name %} {{ ent.entrance.name|safe }} - {% endif %}<a href="{% url editentrance cave.slug ent.entrance.slug %}">Edit</a> + {% endif %}<a href="{% url "editentrance" cave.slug ent.entrance.slug %}">Edit</a> <dl> {% if ent.entrance.marking %} <dt>Marking</dt><dd>{{ ent.entrance.marking_val|safe }}</dd> @@ -67,5 +67,5 @@ </ul> {% endif %}</p> -<a href="{% url newentrance cave.slug %}">New Entrance</a> +<a href="{% url "newentrance" cave.slug %}">New Entrance</a> </div> diff --git a/templates/caveindex.html b/templates/caveindex.html index fe141ed..d99f452 100644 --- a/templates/caveindex.html +++ b/templates/caveindex.html @@ -34,6 +34,6 @@ {% endfor %} </ul> -<a href="{% url newcave %}">New Cave</a> +<a href="{% url "newcave" %}">New Cave</a> {% endblock %} diff --git a/templates/controlPanel.html b/templates/controlPanel.html index 7d37887..327af13 100644 --- a/templates/controlPanel.html +++ b/templates/controlPanel.html @@ -68,7 +68,7 @@ </form> </td> <td> - <form name="export" method="get" action="{% url downloadcavetab %}"> + <form name="export" method="get" action="{% url "downloadcavetab" %}"> <p>Download a CAVETAB2.CSV file which is dynamically generated by Troggle.</p> <input name="download_cavetab" type="submit" value="Download CAVETAB2.CSV" /> </form> @@ -83,7 +83,7 @@ </td> <td> - <form name="export" method="get" action={% url downloadlogbook %}> + <form name="export" method="get" action={% url "downloadlogbook" %}> <p>Download a logbook file which is dynamically generated by Troggle.</p> <p> @@ -120,7 +120,7 @@ </form> </td> <td> - <form name="export" method="get" action={% url downloadsurveys %}> + <form name="export" method="get" action={% url "downloadsurveys" %}> <p>Download a Surveys.csv file which is dynamically generated by Troggle.</p> <input disabled name="download_surveys" type="submit" value="Download Surveys.csv" /> </form> diff --git a/templates/editfile.html b/templates/editfile.html index c420654..64f1fba 100644 --- a/templates/editfile.html +++ b/templates/editfile.html @@ -6,16 +6,16 @@ $(function() { $("#id_date").datepicker({dateFormat: "yy-mm-dd"}); $("#id_cave").change(function() { - $('#id_entrance').load('{% url get_entrances caveslug="" %}' + this.value); + $('#id_entrance').load('{% url "get_entrances" caveslug="" %}' + this.value); }); $("#id_cave").change(function() { - $('#id_qm').load('{% url get_qms caveslug="" %}' + this.value); + $('#id_qm').load('{% url "get_qms" caveslug="" %}' + this.value); }); $("#id_expedition").change(function() { - $('#id_logbookentry').load('{% url get_logbook_entries expeditionslug="" %}' + this.value); + $('#id_logbookentry').load('{% url "get_logbook_entries" expeditionslug="" %}' + this.value); }); $("#id_expedition").change(function() { - $('#id_person').load('{% url get_people expeditionslug="" %}' + this.value); + $('#id_person').load('{% url "get_people" expeditionslug="" %}' + this.value); }); }); diff --git a/templates/expedition.html b/templates/expedition.html index 4fab025..548dc4f 100644 --- a/templates/expedition.html +++ b/templates/expedition.html @@ -51,7 +51,7 @@ an "S" for a survey trip. The colours are the same for people on the same trip. {% endfor %} <br/> {% for survexblock in persondayactivities.survexblocks %} - <a href="{% url svx survexblock.survexfile.path %}" class="dayindexsurvex-{{survexblock.DayIndex}}">S</a> + <a href="{% url "svx" survexblock.survexfile.path %}" class="dayindexsurvex-{{survexblock.DayIndex}}">S</a> {% endfor %} </td> {% else %} @@ -67,7 +67,7 @@ an "S" for a survey trip. The colours are the same for people on the same trip. <form action="" method="GET"><input type="submit" name="reload" value="Reload"></form> <h3>Logbooks and survey trips per day</h3> -<a href="{% url newLogBookEntry expeditionyear=expedition.year %}">New logbook entry</a> +<a href="{% url "newLogBookEntry" expeditionyear=expedition.year %}">New logbook entry</a> <table class="expeditionlogbooks"> <tr><th>Date</th><th>Logged trips</th><th>Surveys</th></tr> {% regroup dateditems|dictsort:"date" by date as dates %} @@ -78,7 +78,7 @@ an "S" for a survey trip. The colours are the same for people on the same trip. {% if item.isLogbookEntry %}<a href="{{ item.get_absolute_url }}">{{item.title|safe}}</a><br/>{% endif %} {% endfor %}</td> <td>{% for item in date.list %} - {% if item.isSurvexBlock %}<a href="{% url svx item.survexfile.path %}">{{item.name}}</a><br/>{% endif %} + {% if item.isSurvexBlock %}<a href="{% url "svx" item.survexfile.path %}">{{item.name}}</a><br/>{% endif %} {% endfor %}</td> </tr> {% endfor %} diff --git a/templates/expowebbase.html b/templates/expowebbase.html index 5d5b424..becdb05 100644 --- a/templates/expowebbase.html +++ b/templates/expowebbase.html @@ -16,14 +16,14 @@ <li><a href="/indxal.htm">Cave index</a></li> {% if cavepage %} <ul> -<li><a href="{% url survexcaveslist %}">All Survex</a></li> -<li><a href="{% url surveyscansfolders %}">Scans</a></li> -<li><a href="{% url tunneldata %}">Tunneldata</a></li> -<li><a href="{% url survexcavessingle 161 %}">161</a></li> -<li><a href="{% url survexcavessingle 204 %}">204</a></li> -<li><a href="{% url survexcavessingle 258 %}">258</a></li> -<li><a href="{% url expedition 2012 %}">Expo2012</a></li> -<li><a href="{% url expedition 2013 %}">Expo2013</a></li> +<li><a href="{% url "survexcaveslist" %}">All Survex</a></li> +<li><a href="{% url "surveyscansfolders" %}">Scans</a></li> +<li><a href="{% url "tunneldata" %}">Tunneldata</a></li> +<li><a href="{% url "survexcavessingle" 161 %}">161</a></li> +<li><a href="{% url "survexcavessingle" 204 %}">204</a></li> +<li><a href="{% url "survexcavessingle" 258 %}">258</a></li> +<li><a href="{% url "expedition" 2012 %}">Expo2012</a></li> +<li><a href="{% url "expedition" 2013 %}">Expo2013</a></li> <li><a href="/admin">Django admin</a></li> </ul> {% endif %} diff --git a/templates/flatpage.html b/templates/flatpage.html index 47863e3..2376159 100644 --- a/templates/flatpage.html +++ b/templates/flatpage.html @@ -3,5 +3,5 @@ {% block bodyattrs %}{% if homepage %} id="homepage"{% endif %}{% endblock %} {% block body %} {{ body|safe }} -{% if homepage %}{% if editable %}<a href="{% url editflatpage path %}">Edit</a>{% endif %}{%else %}{% include "menu.html" %}{% endif %} +{% if homepage %}{% if editable %}<a href="{% url "editflatpage" path %}">Edit</a>{% endif %}{%else %}{% include "menu.html" %}{% endif %} {% endblock %} diff --git a/templates/frontpage.html b/templates/frontpage.html index 2c1456c..bad3ce5 100644 --- a/templates/frontpage.html +++ b/templates/frontpage.html @@ -57,7 +57,7 @@ Everyone is gearing up for the 2009 expedition; please see the link below for th <h3>Troggle development</h3> <p class="indent"> -Troggle is still under development. Check out the <a href="http://troggle.googlecode.com">development page</a> on google code, where you can file bug reports, make suggestions, and help develop the code. There is also an old todo list at <a href="{%url todo%}">here</a>. +Troggle is still under development. Check out the <a href="http://troggle.googlecode.com">development page</a> on google code, where you can file bug reports, make suggestions, and help develop the code. There is also an old todo list at <a href="{%url "todo"%}">here</a>. </p> </div> {% endblock content %} diff --git a/templates/index.html b/templates/index.html index c0974e8..614c180 100644 --- a/templates/index.html +++ b/templates/index.html @@ -8,14 +8,14 @@ <h2>The unfinished front page</h2> <ul> <li><b>About {{totallogbookentries}} logbook entries have been loaded</b></li> - <li><b><a href="{% url personindex %}">List of People</a></b></li> - <li><b><a href="{% url caveindex %}">List of Caves</a></b></li> - <li><a href="{% url jgtfile aaaa %}">JGT list of files</a> (temporary simple file list and tunnel use)</li> - <li><a href="{% url survey %}">Survey files</a></li> - <li><a href="{% url svx all %}">Survex directory</a></li> - <li><a href="{% url expedition 2008 %}">Expedition 2008</a></li> - <li><a href="{% url expedition 2007 %}">Expedition 2007</a></li> - <li><a href="{% url expedition 1992 %}">Expedition 1992</a> (earliest parsed)</li> + <li><b><a href="{% url "personindex" %}">List of People</a></b></li> + <li><b><a href="{% url "caveindex" %}">List of Caves</a></b></li> + <li><a href="{% url "jgtfile" aaaa %}">JGT list of files</a> (temporary simple file list and tunnel use)</li> + <li><a href="{% url "survey" %}">Survey files</a></li> + <li><a href="{% url "svx" all %}">Survex directory</a></li> + <li><a href="{% url "expedition" 2008 %}">Expedition 2008</a></li> + <li><a href="{% url "expedition" 2007 %}">Expedition 2007</a></li> + <li><a href="{% url "expedition" 1992 %}">Expedition 1992</a> (earliest parsed)</li> </ul> <h2>Further work</h2> @@ -50,7 +50,7 @@ <ul id="expeditionlist"> {% for expedition in expeditions %} <li> - <a href="{% url expedition expedition.year %}">{{expedition.name}}</a> + <a href="{% url "expedition" expedition.year %}">{{expedition.name}}</a> - <b>{{expedition.logbookentry_set.count}}</b> logbook entries </li> {% endfor %} diff --git a/templates/listdir.html b/templates/listdir.html index 7f83b5a..d220ea1 100644 --- a/templates/listdir.html +++ b/templates/listdir.html @@ -3,20 +3,20 @@ <h3>Files</h3> <ul> {% for lf in listdirfiles %} -<li><a href="{% url jgtfile lf.0 %}">{{lf.1}}</a> ({{lf.2}} bytes)</li> +<li><a href="{% url "jgtfile" lf.0 %}">{{lf.1}}</a> ({{lf.2}} bytes)</li> {% endfor %} </ul> <h3>Upperdirectories</h3> <ul> {% for lf in upperdirs %} -<li><a href="{% url jgtfile lf.0 %}">{{lf.1}}</a></li> +<li><a href="{% url "jgtfile" lf.0 %}">{{lf.1}}</a></li> {% endfor %} </ul> <h3>Subdirectories</h3> <ul> {% for lf in listdirdirs %} -<li><a href="{% url jgtfile lf.0 %}">{{lf.1}}</a> ({{lf.2}} files)</li> +<li><a href="{% url "jgtfile" lf.0 %}">{{lf.1}}</a> ({{lf.2}} files)</li> {% endfor %} </ul> diff --git a/templates/logbookentry.html b/templates/logbookentry.html index a3ffc3d..93ce32b 100644 --- a/templates/logbookentry.html +++ b/templates/logbookentry.html @@ -71,7 +71,7 @@ </div> </div> -{% if logbookentry.filename %}<a href="{% url editLogBookEntry expeditionyear=logbookentry.expedition.year pdate=logbookentry.date pslug=logbookentry.slug %}">Edit</a> <a href="{% url deleteLogBookEntry expeditionyear=logbookentry.expedition.year date=logbookentry.date slug=logbookentry.slug %}">Delete</a>{%endif%} +{% if logbookentry.filename %}<a href="{% url "editLogBookEntry" expeditionyear=logbookentry.expedition.year pdate=logbookentry.date pslug=logbookentry.slug %}">Edit</a> <a href="{% url "deleteLogBookEntry" expeditionyear=logbookentry.expedition.year date=logbookentry.date slug=logbookentry.slug %}">Delete</a>{%endif%} {% endblock %} diff --git a/templates/menu.html b/templates/menu.html index bea6067..c069de1 100644 --- a/templates/menu.html +++ b/templates/menu.html @@ -7,7 +7,7 @@ <li><a href="/indxal.htm">Caves</a></li> <li><a href="/handbook/index.htm">Handbook</a></li> <li><a href="/pubs.htm">Reports</a></li> -{% if editable %}<li><a href="{% url editflatpage path %}" class="editlink"><strong>Edit this page</strong></a></li>{% endif %} -{% if cave_editable %}<li><a href="{% url edit_cave cave_editable %}" class="editlink"><strong>Edit this cave</strong></a></li>{% endif %} +{% if editable %}<li><a href="{% url "editflatpage" path %}" class="editlink"><strong>Edit this page</strong></a></li>{% endif %} +{% if cave_editable %}<li><a href="{% url "edit_cave" cave_editable %}" class="editlink"><strong>Edit this cave</strong></a></li>{% endif %} </ul> {% endif %} diff --git a/templates/pagenotfound.html b/templates/pagenotfound.html index 03569de..4fdfe2a 100644 --- a/templates/pagenotfound.html +++ b/templates/pagenotfound.html @@ -2,6 +2,6 @@ {% block title %}Page not found {{ path }}{% endblock %} {% block body %} <h1>Page not found {{ path }}</h1> -<a href="{%url editflatpage path %}">Create this page.</a> +<a href="{%url "editflatpage" path %}">Create this page.</a> {% include "menu.html" %} {% endblock %} diff --git a/templates/personexpedition.html b/templates/personexpedition.html index b88f44e..30d071b 100644 --- a/templates/personexpedition.html +++ b/templates/personexpedition.html @@ -39,7 +39,7 @@ {% endif %} {% if persondate.2 %} - <td class="survexblock"><a href="{% url svx persondate.2.survexfile.path %}">{{persondate.2}}</a></td> + <td class="survexblock"><a href="{% url "svx" persondate.2.survexfile.path %}">{{persondate.2}}</a></td> <td class="roles"> {% for survexpersonrole in persondate.2.survexpersonrole_set.all %} {{survexpersonrole.nrole}} diff --git a/templates/registration/activate.html b/templates/registration/activate.html index 3f95a18..cf8e79a 100644 --- a/templates/registration/activate.html +++ b/templates/registration/activate.html @@ -12,11 +12,11 @@ New troggle account registered {% if account %} <p> -Hello, {{ account }}! Your account is now activated. Now you can <a href="{%url auth_login%}">log in</a> with the password you chose. Use the links in the upper right to control this in the future. +Hello, {{ account }}! Your account is now activated. Now you can <a href="{%url "auth_login"%}">log in</a> with the password you chose. Use the links in the upper right to control this in the future. </p> <p> -If you have been on the expedition in the past, you already have a profile in the system; <a href={% url profiles_select_profile %}>click here </a> to find it and link it to your account. Otherwise, please <a href={% url profiles_create_profile %}> create yourself a new profile</a>. +If you have been on the expedition in the past, you already have a profile in the system; <a href={% url "profiles_select_profile" %}>click here </a> to find it and link it to your account. Otherwise, please <a href={% url "profiles_create_profile" %}> create yourself a new profile</a>. </p> {% else %} diff --git a/templates/registration/activation_email.html b/templates/registration/activation_email.html index abb0ad1..3b82c60 100644 --- a/templates/registration/activation_email.html +++ b/templates/registration/activation_email.html @@ -2,7 +2,7 @@ <P>Glad you're joining the CUCC EXPO team! Please go to</P> -<P><a href="{{ site }}{% url registration_activate activation_key %}">{{ site }}{% url registration_activate activation_key %}</a></P> +<P><a href="{{ site }}{% url "registration_activate" activation_key %}">{{ site }}{% url "registration_activate" activation_key %}</a></P> <P>to activate your account. Do this within {{ expiration_days }} days, or else you'll have to sign up again.</P> diff --git a/templates/registration/activation_email.txt b/templates/registration/activation_email.txt index 9b240c2..bce7fbe 100644 --- a/templates/registration/activation_email.txt +++ b/templates/registration/activation_email.txt @@ -2,7 +2,7 @@ Hello {{ form.user }}, Glad you're joining the CUCC EXPO team! Please go to -{{ site }}{% url registration_activate activation_key %} +{{ site }}{% url "registration_activate" activation_key %} to activate your account. Do this within {{ expiration_days }} days, or else you'll have to sign up again. diff --git a/templates/registration/registration_form.html b/templates/registration/registration_form.html index f82c6cb..6c4a7f6 100644 --- a/templates/registration/registration_form.html +++ b/templates/registration/registration_form.html @@ -9,7 +9,7 @@ registration_form.html | {{ block.super }} {% endblock %} {% block content %} -<form action="{% url registration_register %}" method="POST">{% csrf_token %} +<form action="{% url "registration_register" %}" method="POST">{% csrf_token %} {% for error in form.non_field_errors %} <span style="color:red">{{ error }}</span> {% endfor %} diff --git a/templates/survexblock.html b/templates/survexblock.html index c4c1066..b159956 100644 --- a/templates/survexblock.html +++ b/templates/survexblock.html @@ -8,7 +8,7 @@ {% block content %} <h2>Survex Block {{survexblock.survexpath}}</h2> -<p>Link to <a href="{% url svx survexblock.survexfile.path %}">{{survexblock.survexfile.path}}</a></p> +<p>Link to <a href="{% url "svx" survexblock.survexfile.path %}">{{survexblock.survexfile.path}}</a></p> <p>Needs duplicates removed from right hand column</p> <p>Needs links to survex file presentation</p> @@ -18,13 +18,13 @@ {% if survexblock.parent %} <p>Survey block above:</p> - <p class="indent"><a href="{% url survexblock survexblock.parent.survexpath %}">{{survexblock.parent.survexpath}}</a></p> + <p class="indent"><a href="{% url "survexblock" survexblock.parent.survexpath %}">{{survexblock.parent.survexpath}}</a></p> {% endif %} {% if survexblock.survexblock_set.all %} <p>Survey blocks below:</p> {% for survexblockdown in survexblock.survexblock_set.all %} - <p class="indent"><a href="{% url survexblock survexblockdown.survexpath %}">{{survexblockdown.survexpath}}</a></p> + <p class="indent"><a href="{% url "survexblock" survexblockdown.survexpath %}">{{survexblockdown.survexpath}}</a></p> {% endfor %} {% endif %} diff --git a/templates/survexscansfolder.html b/templates/survexscansfolder.html index fe21916..339f639 100644 --- a/templates/survexscansfolder.html +++ b/templates/survexscansfolder.html @@ -25,7 +25,7 @@ <table> {% for survexblock in survexscansfolder.survexblock_set.all %} <tr> - <td><a href="{% url svx survexblock.survexfile.path %}">{{survexblock}}</a></td> + <td><a href="{% url "svx" survexblock.survexfile.path %}">{{survexblock}}</a></td> </tr> {% endfor %} </table> diff --git a/templates/survexscansfolders.html b/templates/survexscansfolders.html index 597bacf..187f3f0 100644 --- a/templates/survexscansfolders.html +++ b/templates/survexscansfolders.html @@ -15,7 +15,7 @@ <td>{{survexscansfolder.survexscansingle_set.all|length}}</td> <td> {% for survexblock in survexscansfolder.survexblock_set.all %} - <a href="{% url svx survexblock.survexfile.path %}">{{survexblock}}</a> + <a href="{% url "svx" survexblock.survexfile.path %}">{{survexblock}}</a> {% endfor %} </td> </tr> diff --git a/templates/survey.html b/templates/survey.html index 9dca0df..13a8800 100644 --- a/templates/survey.html +++ b/templates/survey.html @@ -24,11 +24,11 @@ }); function redirectSurvey(){ - window.location = "{% url survey %}" + '/' + document.getElementById("expeditionChooser").value + "%23" + document.getElementById("surveyChooser").value; + window.location = "{% url "survey" %}" + '/' + document.getElementById("expeditionChooser").value + "%23" + document.getElementById("surveyChooser").value; } function redirectYear(){ - window.location = "{% url survey %}" + '/' + document.getElementById("expeditionChooser").value + "%23"; + window.location = "{% url "survey" %}" + '/' + document.getElementById("expeditionChooser").value + "%23"; } </script> diff --git a/templates/svxcavesingle.html b/templates/svxcavesingle.html index 1d24466..ad5540f 100644 --- a/templates/svxcavesingle.html +++ b/templates/svxcavesingle.html @@ -29,9 +29,9 @@ {% endif %} {% ifequal survexfile survexdirectory.primarysurvexfile %} - <a href="{% url svx survexfile.path %}"><b>{{survexfile.path}}</b></a> + <a href="{% url "svx" survexfile.path %}"><b>{{survexfile.path}}</b></a> {% else %} - <a href="{% url svx survexfile.path %}">{{survexfile.path}}</a> + <a href="{% url "svx" survexfile.path %}">{{survexfile.path}}</a> {% endifequal %} </td> </tr> diff --git a/templates/svxfile.html b/templates/svxfile.html index fbaacdd..e1ed097 100644 --- a/templates/svxfile.html +++ b/templates/svxfile.html @@ -62,7 +62,7 @@ $(document).ready(function() {% if logmessage %} {% if has_3d %} -<p><a href="{% url threed title %}">3d file</a></p> +<p><a href="{% url "threed" title %}">3d file</a></p> {% else %} <p><b>No 3d file</b></p> {% endif %} diff --git a/templates/svxfilecavelist.html b/templates/svxfilecavelist.html index 52c8e83..2f80d46 100644 --- a/templates/svxfilecavelist.html +++ b/templates/svxfilecavelist.html @@ -12,23 +12,23 @@ <h2 id="cdir">Caves with subdirectories</h2> {% for subdircave, cavefiles, subsurvdirs in subdircaves %} -<h3>{{cavefiles.0.1}} - <a href="{% url survexcavessingle cavefiles.0.1 %}">dates and explorers</a></h3> +<h3>{{cavefiles.0.1}} - <a href="{% url "survexcavessingle" cavefiles.0.1 %}">dates and explorers</a></h3> <table> <tr> - <td><b><a href="{% url svx cavefiles.0.0 %}">{{cavefiles.0.1}}</a></b></td> + <td><b><a href="{% url "svx" cavefiles.0.0 %}">{{cavefiles.0.1}}</a></b></td> <td> {% for cavepath, cavename in cavefiles.1 %} - <a href="{% url svx cavepath %}">{{cavename}}</a> + <a href="{% url "svx" cavepath %}">{{cavename}}</a> {% endfor %} </td> </tr> {% for primarycavefile, subcavefiles in subsurvdirs %} <tr> - <td><a href="{% url svx primarycavefile.0 %}">{{primarycavefile.1}}</a></td> + <td><a href="{% url "svx" primarycavefile.0 %}">{{primarycavefile.1}}</a></td> <td> {% for cavepath, cavename in subcavefiles %} - <a href="{% url svx cavepath %}">{{cavename}}</a> + <a href="{% url "svx" cavepath %}">{{cavename}}</a> {% endfor %} </td> </tr> @@ -44,12 +44,12 @@ {% for primarycavefile, subcavefiles in multifilecaves %} <tr> <td> - <a href="{% url survexcavessingle primarycavefile.1 %}">{{primarycavefile.1}}</a> + <a href="{% url "survexcavessingle" primarycavefile.1 %}">{{primarycavefile.1}}</a> </td> <td> - <a href="{% url svx primarycavefile.0 %}">{{primarycavefile.1}}</a> - + <a href="{% url "svx" primarycavefile.0 %}">{{primarycavefile.1}}</a> - {% for cavepath, cavename in subcavefiles %} - <a href="{% url svx cavepath %}">{{cavename}}</a> + <a href="{% url "svx" cavepath %}">{{cavename}}</a> {% endfor %} </td> </tr> @@ -59,7 +59,7 @@ <h2 id="csing">Caves of one file</h2> <p> {% for cavepath, cavename in onefilecaves %} - <a href="{% url svx cavepath %}">{{cavename}}</a> + <a href="{% url "svx" cavepath %}">{{cavename}}</a> {% endfor %} </p> diff --git a/templates/svxfiledifflistonly.html b/templates/svxfiledifflistonly.html index 835125b..7b0367a 100644 --- a/templates/svxfiledifflistonly.html +++ b/templates/svxfiledifflistonly.html @@ -6,7 +6,7 @@ {% if logmessage %} {% if has_3d %} -<p><a href="{% url threed title %}">3d file</a></p> +<p><a href="{% url "threed" title %}">3d file</a></p> {% else %} <p><b>No 3d file</b></p> {% endif %} diff --git a/templates/todo.html b/templates/todo.html index a678f50..7482b72 100644 --- a/templates/todo.html +++ b/templates/todo.html @@ -8,14 +8,14 @@ <h2>The unfinished front page</h2> <ul> <li><b>About {{totallogbookentries}} logbook entries have been loaded</b></li> - <li><b><a href="{% url personindex %}">List of People</a></b></li> - <li><b><a href="{% url caveindex %}">List of Caves</a></b></li> - <li><a href="{% url jgtfile aaaa %}">JGT list of files</a> (temporary simple file list and tunnel use)</li> - <li><a href="{% url survey %}">Survey files</a></li> - <li><a href="{% url survexindex all %}">Survex directory</a></li> - <li><a href="{% url expedition 2008 %}">Expedition 2008</a></li> - <li><a href="{% url expedition 2007 %}">Expedition 2007</a></li> - <li><a href="{% url expedition 1993 %}">Expedition 1993</a> (earliest parsed)</li> + <li><b><a href="{% url "personindex" %}">List of People</a></b></li> + <li><b><a href="{% url "caveindex" %}">List of Caves</a></b></li> + <li><a href="{% url "jgtfile" aaaa %}">JGT list of files</a> (temporary simple file list and tunnel use)</li> + <li><a href="{% url "survey" %}">Survey files</a></li> + <li><a href="{% url "survexindex" all %}">Survex directory</a></li> + <li><a href="{% url "expedition" 2008 %}">Expedition 2008</a></li> + <li><a href="{% url "expedition" 2007 %}">Expedition 2007</a></li> + <li><a href="{% url "expedition" 1993 %}">Expedition 1993</a> (earliest parsed)</li> </ul> <h2>Further work</h2> @@ -52,7 +52,7 @@ <ul id="expeditionlist"> {% for expedition in expeditions %} <li> - <a href="{% url expedition expedition.year %}">{{expedition.name}}</a> + <a href="{% url "expedition" expedition.year %}">{{expedition.name}}</a> - <b>{{expedition.logbookentry_set.count}}</b> logbook entries </li> {% endfor %} diff --git a/templates/tunnelfiles.html b/templates/tunnelfiles.html index caa3895..fbc74ea 100644 --- a/templates/tunnelfiles.html +++ b/templates/tunnelfiles.html @@ -11,7 +11,7 @@ <tr><th>File</th><th>Font</th><th>SurvexBlocks</th><th>Size</th><th>Paths</th><th>Scans folder</th><th>Scan files</th><th>Frames</th></tr> {% for tunnelfile in tunnelfiles %} <tr> - <td><a href="{% url tunnelfile tunnelfile.tunnelpath %}">{{tunnelfile.tunnelpath}}</a></td> + <td><a href="{% url "tunnelfile" tunnelfile.tunnelpath %}">{{tunnelfile.tunnelpath}}</a></td> <td>{{tunnelfile.bfontcolours}}</td> <td></td> <td>{{tunnelfile.filesize}}</td> @@ -31,7 +31,7 @@ <td> {% for rtunnelfile in tunnelfile.tunnelcontains.all %} - <a href="{% url tunnelfile rtunnelfile.tunnelpath %}">{{rtunnelfile.tunnelpath}}</a> + <a href="{% url "tunnelfile" rtunnelfile.tunnelpath %}">{{rtunnelfile.tunnelpath}}</a> {% endfor %} </td> @@ -1,4 +1,4 @@ -from django.conf.urls.defaults import * +from django.conf.urls import * from django.conf import settings from core.views import * # flat import @@ -6,9 +6,9 @@ from core.views_other import * from core.views_caves import * from core.views_survex import * from core.models import * -from django.views.generic.create_update import create_object +from django.views.generic.edit import UpdateView from django.contrib import admin -from django.views.generic.list_detail import object_list +from django.views.generic.list import ListView from django.contrib import admin admin.autodiscover() @@ -30,7 +30,7 @@ actualurlpatterns = patterns('', #url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"), url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"), - url(r'^expeditions/?$', object_list, {'queryset':Expedition.objects.all(),'template_name':'object_list.html'},name="expeditions"), + url(r'^expeditions/?$', ListView, {'queryset':Expedition.objects.all(),'template_name':'object_list.html'},name="expeditions"), url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-z]*)/(?P<year>\d+)/?$', views_logbooks.personexpedition, name="personexpedition"), url(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', views_logbooks.logbookentry,name="logbookentry"), url(r'^newlogbookentry/(?P<expeditionyear>.*)$', views_logbooks.newLogbookEntry, name="newLogBookEntry"), @@ -96,7 +96,7 @@ actualurlpatterns = patterns('', url(r'^troggle/media-admin/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ADMIN_DIR, 'show_indexes':True}), - (r'^accounts/', include('registration.urls')), + (r'^accounts/', include('registration.backends.default.urls')), (r'^profiles/', include('profiles.urls')), @@ -1,14 +1,14 @@ from django.conf import settings import random, re, logging -from core.models import CaveDescription +from troggle.core.models import CaveDescription def weighted_choice(lst): - n = random.uniform(0,1) - for item, weight in lst: - if n < weight: - break - n = n - weight - return item + n = random.uniform(0,1) + for item, weight in lst: + if n < weight: + break + n = n - weight + return item def randomLogbookSentence(): from troggle.core.models import LogbookEntry @@ -0,0 +1,14 @@ +""" +WSGI config for mysite project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ +""" + +import os +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() |