From a2e1882d913baae4c4c5197221826e2be6ef2b7a Mon Sep 17 00:00:00 2001 From: Wookey Date: Mon, 11 Jul 2011 01:49:03 +0100 Subject: [PATCH 1/4] undosify lineends --- urls.py | 298 +++++++++++++++++++++++----------------------- utils.py | 356 +++++++++++++++++++++++++++---------------------------- 2 files changed, 327 insertions(+), 327 deletions(-) diff --git a/urls.py b/urls.py index 9bddbfb47..67c50acab 100644 --- a/urls.py +++ b/urls.py @@ -1,149 +1,149 @@ -from django.conf.urls.defaults import * -from django.conf import settings - -from core.views import * # flat import -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.contrib import admin -from django.views.generic.list_detail import object_list -from django.contrib import admin -admin.autodiscover() - - -# type url probably means it's used. - -actualurlpatterns = patterns('', - - url(r'^$', views_other.frontpage, name="frontpage"), - url(r'^todo/$', views_other.todo, name="todo"), - - url(r'^caves/?$', views_caves.caveindex, name="caveindex"), - url(r'^people/?$', views_logbooks.personindex, name="personindex"), - - url(r'^newqmnumber/?$', views_other.ajax_QM_number, ), - url(r'^lbo_suggestions/?$', logbook_entry_suggestions), - #(r'^person/(?P\d*)/?$', views_logbooks.person), - url(r'^person/(?P[A-Z]*[a-z\-\']*)[^a-zA-Z]*(?P[a-z\-\']*[^a-zA-Z]*[A-Z]*[a-z\-]*)/?', views_logbooks.person, name="person"), - #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'^personexpedition/(?P[A-Z]*[a-z]*)[^a-zA-Z]*(?P[A-Z]*[a-z]*)/(?P\d+)/?$', views_logbooks.personexpedition, name="personexpedition"), - url(r'^logbookentry/(?P.*)/(?P.*)/?$', views_logbooks.logbookentry,name="logbookentry"), - url(r'^newlogbookentry/(?P.*)$', views_logbooks.newLogbookEntry, name="newLogBookEntry"), - url(r'^editlogbookentry/(?P[^/]*)/(?P[^/]*)/(?P[^/]*)/$', views_logbooks.newLogbookEntry, name="editLogBookEntry"), - url(r'^deletelogbookentry/(?P[^/]*)/(?P[^/]*)/(?P[^/]*)/$', views_logbooks.deleteLogbookEntry, name="deleteLogBookEntry"), - url(r'^newfile', views_other.newFile, name="newFile"), - - url(r'^getEntrances/(?P.*)', views_caves.get_entrances, name = "get_entrances"), - url(r'^getQMs/(?P.*)', views_caves.get_qms, name = "get_qms"), - url(r'^getPeople/(?P.*)', views_logbooks.get_people, name = "get_people"), - url(r'^getLogBookEntries/(?P.*)', views_logbooks.get_logbook_entries, name = "get_logbook_entries"), - - url(r'^cave/(?P[^/]+)/?$', views_caves.cave, name="cave"), - url(r'^caveslug/([^/]+)/?$', views_caves.caveSlug, name="caveSlug"), - url(r'^cave/entrance/([^/]+)/?$', views_caves.caveEntrance), - url(r'^cave/description/([^/]+)/?$', views_caves.caveDescription), - url(r'^cave/qms/([^/]+)/?$', views_caves.caveQMs), - url(r'^cave/logbook/([^/]+)/?$', views_caves.caveLogbook), - #url(r'^cavedescription/(?P[^/]+)/?$', views_caves.cave_description, name="cavedescription"), - #url(r'^cavedescription/?$', object_list, {'queryset':CaveDescription.objects.all(),'template_name':'object_list.html'}, name="cavedescriptions"), - #url(r'^cavehref/(.+)$', views_caves.cave, name="cave"),url(r'cave'), - - url(r'^jgtfile/(.*)$', view_surveys.jgtfile, name="jgtfile"), - url(r'^jgtuploadfile$', view_surveys.jgtuploadfile, name="jgtuploadfile"), - - url(r'^cave/(?P[^/]+)/?(?P[^/])$', ent), - #(r'^cave/(?P[^/]+)/edit/$', edit_cave), - #(r'^cavesearch', caveSearch), - - - url(r'^cave/(?P[^/]+)/(?P\d\d\d\d)-(?P\d*)(?P[ABCDX]?)?$', views_caves.qm, name="qm"), - - - url(r'^logbooksearch/(.*)/?$', views_logbooks.logbookSearch), - - - url(r'^statistics/?$', views_other.stats, name="stats"), - - url(r'^survey/?$', surveyindex, name="survey"), - url(r'^survey/(?P\d\d\d\d)\#(?P\d*)$', survey, name="survey"), - - url(r'^controlpanel/?$', views_other.controlPanel, name="controlpanel"), - url(r'^CAVETAB2\.CSV/?$', views_other.downloadCavetab, name="downloadcavetab"), - url(r'^Surveys\.csv/?$', views_other.downloadSurveys, name="downloadsurveys"), - url(r'^logbook(?P\d\d\d\d)\.(?P.*)/?$',views_other.downloadLogbook), - url(r'^logbook/?$',views_other.downloadLogbook, name="downloadlogbook"), - url(r'^cave/(?P[^/]+)/qm\.csv/?$', views_other.downloadQMs, name="downloadqms"), - (r'^downloadqms$', views_other.downloadQMs), - - url(r'^eyecandy$', views_other.eyecandy), - - (r'^admin/doc/?', include('django.contrib.admindocs.urls')), - url(r'^admin/(.*)', admin.site.root, name="admin"), - - # don't know why this needs troggle/ in here. nice to get it out - url(r'^troggle/media-admin/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ADMIN_DIR, 'show_indexes':True}), - - - (r'^accounts/', include('registration.urls')), - (r'^profiles/', include('profiles.urls')), - - -# (r'^personform/(.*)$', personForm), - - (r'^site_media/(?P.*)$', 'django.views.static.serve', - {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), - (r'^tinymce_media/(?P.*)$', 'django.views.static.serve', - {'document_root': settings.TINY_MCE_MEDIA_ROOT, 'show_indexes': True}), - - - url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"), - url(r'^survexfile/(?P.*?)\.svx$', views_survex.svx, name="svx"), - url(r'^survexfile/(?P.*?)\.3d$', views_survex.threed, name="threed"), - url(r'^survexfile/(?P.*?)\.log$', views_survex.svxraw), - url(r'^survexfile/(?P.*?)\.err$', views_survex.err), - - - url(r'^survexfile/caves/$', views_survex.survexcaveslist, name="survexcaveslist"), - url(r'^survexfile/caves/(?P.*)$', views_survex.survexcavesingle, name="survexcavessingle"), - url(r'^survexfileraw/(?P.*?)\.svx$', views_survex.svxraw, name="svxraw"), - - - (r'^survey_files/listdir/(?P.*)$', view_surveys.listdir), - (r'^survey_files/download/(?P.*)$', view_surveys.download), - #(r'^survey_files/upload/(?P.*)$', view_surveys.upload), - - - - #(r'^survey_scans/(?P.*)$', 'django.views.static.serve', {'document_root': settings.SURVEY_SCANS, 'show_indexes':True}), - url(r'^survey_scans/$', view_surveys.surveyscansfolders, name="surveyscansfolders"), - url(r'^survey_scans/(?P[^/]+)/$', view_surveys.surveyscansfolder, name="surveyscansfolder"), - url(r'^survey_scans/(?P[^/]+)/(?P[^/]+(?:png|jpg))$', - view_surveys.surveyscansingle, name="surveyscansingle"), - - url(r'^tunneldata/$', view_surveys.tunneldata, name="tunneldata"), - url(r'^tunneldataraw/(?P.+?\.xml)$', view_surveys.tunnelfile, name="tunnelfile"), - url(r'^tunneldataraw/(?P.+?\.xml)/upload$',view_surveys.tunnelfileupload, name="tunnelfileupload"), - - #url(r'^tunneldatainfo/(?P.+?\.xml)$', view_surveys.tunnelfileinfo, name="tunnelfileinfo"), - - (r'^photos/(?P.*)$', 'django.views.static.serve', - {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}), - - # for those silly ideas - url(r'^experimental.*$', views_logbooks.experimental, name="experimental"), - - #url(r'^trip_report/?$',views_other.tripreport,name="trip_report") - - url(r'^(.*)_edit$', 'flatpages.views.editflatpage', name="editflatpage"), - url(r'^(.*)$', 'flatpages.views.flatpage', name="flatpage"), -) - -#Allow prefix to all urls -urlpatterns = patterns ('', - ('^%s' % settings.DIR_ROOT, include(actualurlpatterns)) -) +from django.conf.urls.defaults import * +from django.conf import settings + +from core.views import * # flat import +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.contrib import admin +from django.views.generic.list_detail import object_list +from django.contrib import admin +admin.autodiscover() + + +# type url probably means it's used. + +actualurlpatterns = patterns('', + + url(r'^$', views_other.frontpage, name="frontpage"), + url(r'^todo/$', views_other.todo, name="todo"), + + url(r'^caves/?$', views_caves.caveindex, name="caveindex"), + url(r'^people/?$', views_logbooks.personindex, name="personindex"), + + url(r'^newqmnumber/?$', views_other.ajax_QM_number, ), + url(r'^lbo_suggestions/?$', logbook_entry_suggestions), + #(r'^person/(?P\d*)/?$', views_logbooks.person), + url(r'^person/(?P[A-Z]*[a-z\-\']*)[^a-zA-Z]*(?P[a-z\-\']*[^a-zA-Z]*[A-Z]*[a-z\-]*)/?', views_logbooks.person, name="person"), + #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'^personexpedition/(?P[A-Z]*[a-z]*)[^a-zA-Z]*(?P[A-Z]*[a-z]*)/(?P\d+)/?$', views_logbooks.personexpedition, name="personexpedition"), + url(r'^logbookentry/(?P.*)/(?P.*)/?$', views_logbooks.logbookentry,name="logbookentry"), + url(r'^newlogbookentry/(?P.*)$', views_logbooks.newLogbookEntry, name="newLogBookEntry"), + url(r'^editlogbookentry/(?P[^/]*)/(?P[^/]*)/(?P[^/]*)/$', views_logbooks.newLogbookEntry, name="editLogBookEntry"), + url(r'^deletelogbookentry/(?P[^/]*)/(?P[^/]*)/(?P[^/]*)/$', views_logbooks.deleteLogbookEntry, name="deleteLogBookEntry"), + url(r'^newfile', views_other.newFile, name="newFile"), + + url(r'^getEntrances/(?P.*)', views_caves.get_entrances, name = "get_entrances"), + url(r'^getQMs/(?P.*)', views_caves.get_qms, name = "get_qms"), + url(r'^getPeople/(?P.*)', views_logbooks.get_people, name = "get_people"), + url(r'^getLogBookEntries/(?P.*)', views_logbooks.get_logbook_entries, name = "get_logbook_entries"), + + url(r'^cave/(?P[^/]+)/?$', views_caves.cave, name="cave"), + url(r'^caveslug/([^/]+)/?$', views_caves.caveSlug, name="caveSlug"), + url(r'^cave/entrance/([^/]+)/?$', views_caves.caveEntrance), + url(r'^cave/description/([^/]+)/?$', views_caves.caveDescription), + url(r'^cave/qms/([^/]+)/?$', views_caves.caveQMs), + url(r'^cave/logbook/([^/]+)/?$', views_caves.caveLogbook), + #url(r'^cavedescription/(?P[^/]+)/?$', views_caves.cave_description, name="cavedescription"), + #url(r'^cavedescription/?$', object_list, {'queryset':CaveDescription.objects.all(),'template_name':'object_list.html'}, name="cavedescriptions"), + #url(r'^cavehref/(.+)$', views_caves.cave, name="cave"),url(r'cave'), + + url(r'^jgtfile/(.*)$', view_surveys.jgtfile, name="jgtfile"), + url(r'^jgtuploadfile$', view_surveys.jgtuploadfile, name="jgtuploadfile"), + + url(r'^cave/(?P[^/]+)/?(?P[^/])$', ent), + #(r'^cave/(?P[^/]+)/edit/$', edit_cave), + #(r'^cavesearch', caveSearch), + + + url(r'^cave/(?P[^/]+)/(?P\d\d\d\d)-(?P\d*)(?P[ABCDX]?)?$', views_caves.qm, name="qm"), + + + url(r'^logbooksearch/(.*)/?$', views_logbooks.logbookSearch), + + + url(r'^statistics/?$', views_other.stats, name="stats"), + + url(r'^survey/?$', surveyindex, name="survey"), + url(r'^survey/(?P\d\d\d\d)\#(?P\d*)$', survey, name="survey"), + + url(r'^controlpanel/?$', views_other.controlPanel, name="controlpanel"), + url(r'^CAVETAB2\.CSV/?$', views_other.downloadCavetab, name="downloadcavetab"), + url(r'^Surveys\.csv/?$', views_other.downloadSurveys, name="downloadsurveys"), + url(r'^logbook(?P\d\d\d\d)\.(?P.*)/?$',views_other.downloadLogbook), + url(r'^logbook/?$',views_other.downloadLogbook, name="downloadlogbook"), + url(r'^cave/(?P[^/]+)/qm\.csv/?$', views_other.downloadQMs, name="downloadqms"), + (r'^downloadqms$', views_other.downloadQMs), + + url(r'^eyecandy$', views_other.eyecandy), + + (r'^admin/doc/?', include('django.contrib.admindocs.urls')), + url(r'^admin/(.*)', admin.site.root, name="admin"), + + # don't know why this needs troggle/ in here. nice to get it out + url(r'^troggle/media-admin/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ADMIN_DIR, 'show_indexes':True}), + + + (r'^accounts/', include('registration.urls')), + (r'^profiles/', include('profiles.urls')), + + +# (r'^personform/(.*)$', personForm), + + (r'^site_media/(?P.*)$', 'django.views.static.serve', + {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}), + (r'^tinymce_media/(?P.*)$', 'django.views.static.serve', + {'document_root': settings.TINY_MCE_MEDIA_ROOT, 'show_indexes': True}), + + + url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"), + url(r'^survexfile/(?P.*?)\.svx$', views_survex.svx, name="svx"), + url(r'^survexfile/(?P.*?)\.3d$', views_survex.threed, name="threed"), + url(r'^survexfile/(?P.*?)\.log$', views_survex.svxraw), + url(r'^survexfile/(?P.*?)\.err$', views_survex.err), + + + url(r'^survexfile/caves/$', views_survex.survexcaveslist, name="survexcaveslist"), + url(r'^survexfile/caves/(?P.*)$', views_survex.survexcavesingle, name="survexcavessingle"), + url(r'^survexfileraw/(?P.*?)\.svx$', views_survex.svxraw, name="svxraw"), + + + (r'^survey_files/listdir/(?P.*)$', view_surveys.listdir), + (r'^survey_files/download/(?P.*)$', view_surveys.download), + #(r'^survey_files/upload/(?P.*)$', view_surveys.upload), + + + + #(r'^survey_scans/(?P.*)$', 'django.views.static.serve', {'document_root': settings.SURVEY_SCANS, 'show_indexes':True}), + url(r'^survey_scans/$', view_surveys.surveyscansfolders, name="surveyscansfolders"), + url(r'^survey_scans/(?P[^/]+)/$', view_surveys.surveyscansfolder, name="surveyscansfolder"), + url(r'^survey_scans/(?P[^/]+)/(?P[^/]+(?:png|jpg))$', + view_surveys.surveyscansingle, name="surveyscansingle"), + + url(r'^tunneldata/$', view_surveys.tunneldata, name="tunneldata"), + url(r'^tunneldataraw/(?P.+?\.xml)$', view_surveys.tunnelfile, name="tunnelfile"), + url(r'^tunneldataraw/(?P.+?\.xml)/upload$',view_surveys.tunnelfileupload, name="tunnelfileupload"), + + #url(r'^tunneldatainfo/(?P.+?\.xml)$', view_surveys.tunnelfileinfo, name="tunnelfileinfo"), + + (r'^photos/(?P.*)$', 'django.views.static.serve', + {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}), + + # for those silly ideas + url(r'^experimental.*$', views_logbooks.experimental, name="experimental"), + + #url(r'^trip_report/?$',views_other.tripreport,name="trip_report") + + url(r'^(.*)_edit$', 'flatpages.views.editflatpage', name="editflatpage"), + url(r'^(.*)$', 'flatpages.views.flatpage', name="flatpage"), +) + +#Allow prefix to all urls +urlpatterns = patterns ('', + ('^%s' % settings.DIR_ROOT, include(actualurlpatterns)) +) diff --git a/utils.py b/utils.py index 1970c7bfb..c26f1d912 100644 --- a/utils.py +++ b/utils.py @@ -1,178 +1,178 @@ -from django.conf import settings -import random, re, logging -from 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 - -def randomLogbookSentence(): - from troggle.core.models import LogbookEntry - randSent={} - - # needs to handle empty logbooks without crashing - - #Choose a random logbook entry - randSent['entry']=LogbookEntry.objects.order_by('?')[0] - - #Choose again if there are no sentances (this happens if it is a placeholder entry) - while len(re.findall('[A-Z].*?\.',randSent['entry'].text))==0: - randSent['entry']=LogbookEntry.objects.order_by('?')[0] - - #Choose a random sentence from that entry. Store the sentence as randSent['sentence'], and the number of that sentence in the entry as randSent['number'] - sentenceList=re.findall('[A-Z].*?\.',randSent['entry'].text) - randSent['number']=random.randrange(0,len(sentenceList)) - randSent['sentence']=sentenceList[randSent['number']] - - return randSent - - -def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}): - """Looks up instance using lookupAttribs and carries out the following: - -if instance does not exist in DB: add instance to DB, return (new instance, True) - -if instance exists in DB and was modified using Troggle: do nothing, return (existing instance, False) - -if instance exists in DB and was not modified using Troggle: overwrite instance, return (instance, False) - - The checking is accomplished using Django's get_or_create and the new_since_parsing boolean field - defined in core.models.TroggleModel. - - """ - - instance, created=objectType.objects.get_or_create(defaults=nonLookupAttribs, **lookupAttribs) - - if not created and not instance.new_since_parsing: - for k, v in nonLookupAttribs.items(): #overwrite the existing attributes from the logbook text (except date and title) - setattr(instance, k, v) - instance.save() - - if created: - logging.info(str(instance) + ' was just added to the database for the first time. \n') - - if not created and instance.new_since_parsing: - logging.info(str(instance) + " has been modified using Troggle, so the current script left it as is. \n") - - if not created and not instance.new_since_parsing: - logging.info(str(instance) + " existed in the database unchanged since last parse. It was overwritten by the current script. \n") - return (instance, created) - -def render_with_context(req, *args, **kwargs): - """this is the snippet from http://www.djangosnippets.org/snippets/3/ - - Django uses Context, not RequestContext when you call render_to_response. - We always want to use RequestContext, so that django adds the context from - settings.TEMPLATE_CONTEXT_PROCESSORS. This way we automatically get - necessary settings variables passed to each template. So we use a custom - method, render_response instead of render_to_response. Hopefully future - Django releases will make this unnecessary.""" - - from django.shortcuts import render_to_response - from django.template import RequestContext - kwargs['context_instance'] = RequestContext(req) - return render_to_response(*args, **kwargs) - -re_body = re.compile(r"\]*\>(.*)\", re.DOTALL) -re_title = re.compile(r"\]*\>(.*)\", re.DOTALL) - -def get_html_body(text): - return get_single_match(re_body, text) - -def get_html_title(text): - return get_single_match(re_title, text) - -def get_single_match(regex, text): - match = regex.search(text) - - if match: - return match.groups()[0] - else: - return None - -def href_to_wikilinks(matchobj): - """ - Given an html link, checks for possible valid wikilinks. - - Returns the first valid wikilink. Valid means the target - object actually exists. - """ - res=CaveDescription.objects.filter(long_name__icontains=matchobj.groupdict()['text']) - if res and res[0]: - return r'[[cavedescription:'+res[0].short_name+'|'+res[0].long_name+']]' - else: - return matchobj.group() - #except: - #print 'fail' - - -re_subs = [(re.compile(r"\]*\>(.*?)\", re.DOTALL), r"'''\1'''"), - (re.compile(r"\(.*?)\", re.DOTALL), r"''\1''"), - (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"=\1="), - (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"==\1=="), - (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"===\1==="), - (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"====\1===="), - (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"=====\1====="), - (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"======\1======"), - (re.compile(r'()?>|\s/>()?)', re.DOTALL),r'[[display:\g photo:\g]]'), # - (re.compile(r"\(.*?)\", re.DOTALL), r"[[subcave:\1|\2]]"), #assumes that all links with id attributes are subcaves. Not great. - #interpage link needed - (re.compile(r"\(.*?)\", re.DOTALL), r"[[cavedescription:\1|\2]]"), #assumes that all links with target ids are cave descriptions. Not great. - (re.compile(r"\[\([^\s]*).*?\\]", re.DOTALL), r"[[qm:\1]]"), - (re.compile(r'.*)"?>(?P.*)'),href_to_wikilinks), - - ] - -def html_to_wiki(text, codec = "utf-8"): - if type(text) == str: - text = unicode(text, codec) - text = re.sub("

", r"", text) - text = re.sub("

$", r"", text) - text = re.sub("

", r"\n\n", text) - out = "" - lists = "" - #lists - while text: - mstar = re.match("^(.*?)]*>\s*]*>(.*?)(.*)$", text, re.DOTALL) - munstar = re.match("^(\s*)(.*)$", text, re.DOTALL) - mhash = re.match("^(.*?)]*>\s*]*>(.*?)(.*)$", text, re.DOTALL) - munhash = re.match("^(\s*)(.*)$", text, re.DOTALL) - mitem = re.match("^(\s*)]*>(.*?)(.*)$", text, re.DOTALL) - ms = [len(m.groups()[0]) for m in [mstar, munstar, mhash, munhash, mitem] if m] - def min_(i, l): - try: - v = i.groups()[0] - l.remove(len(v)) - return len(v) < min(l, 1000000000) - except: - return False - if min_(mstar, ms): - lists += "*" - pre, val, post = mstar.groups() - out += pre + "\n" + lists + " " + val - text = post - elif min_(mhash, ms): - lists += "#" - pre, val, post = mhash.groups() - out += pre + "\n" + lists + " " + val - text = post - elif min_(mitem, ms): - pre, val, post = mitem.groups() - out += "\n" + lists + " " + val - text = post - elif min_(munstar, ms): - lists = lists[:-1] - text = munstar.groups()[1] - elif min_(munhash, ms): - lists.pop() - text = munhash.groups()[1] - else: - out += text - text = "" - #substitutions - for regex, repl in re_subs: - out = regex.sub(repl, out) - return out - - +from django.conf import settings +import random, re, logging +from 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 + +def randomLogbookSentence(): + from troggle.core.models import LogbookEntry + randSent={} + + # needs to handle empty logbooks without crashing + + #Choose a random logbook entry + randSent['entry']=LogbookEntry.objects.order_by('?')[0] + + #Choose again if there are no sentances (this happens if it is a placeholder entry) + while len(re.findall('[A-Z].*?\.',randSent['entry'].text))==0: + randSent['entry']=LogbookEntry.objects.order_by('?')[0] + + #Choose a random sentence from that entry. Store the sentence as randSent['sentence'], and the number of that sentence in the entry as randSent['number'] + sentenceList=re.findall('[A-Z].*?\.',randSent['entry'].text) + randSent['number']=random.randrange(0,len(sentenceList)) + randSent['sentence']=sentenceList[randSent['number']] + + return randSent + + +def save_carefully(objectType, lookupAttribs={}, nonLookupAttribs={}): + """Looks up instance using lookupAttribs and carries out the following: + -if instance does not exist in DB: add instance to DB, return (new instance, True) + -if instance exists in DB and was modified using Troggle: do nothing, return (existing instance, False) + -if instance exists in DB and was not modified using Troggle: overwrite instance, return (instance, False) + + The checking is accomplished using Django's get_or_create and the new_since_parsing boolean field + defined in core.models.TroggleModel. + + """ + + instance, created=objectType.objects.get_or_create(defaults=nonLookupAttribs, **lookupAttribs) + + if not created and not instance.new_since_parsing: + for k, v in nonLookupAttribs.items(): #overwrite the existing attributes from the logbook text (except date and title) + setattr(instance, k, v) + instance.save() + + if created: + logging.info(str(instance) + ' was just added to the database for the first time. \n') + + if not created and instance.new_since_parsing: + logging.info(str(instance) + " has been modified using Troggle, so the current script left it as is. \n") + + if not created and not instance.new_since_parsing: + logging.info(str(instance) + " existed in the database unchanged since last parse. It was overwritten by the current script. \n") + return (instance, created) + +def render_with_context(req, *args, **kwargs): + """this is the snippet from http://www.djangosnippets.org/snippets/3/ + + Django uses Context, not RequestContext when you call render_to_response. + We always want to use RequestContext, so that django adds the context from + settings.TEMPLATE_CONTEXT_PROCESSORS. This way we automatically get + necessary settings variables passed to each template. So we use a custom + method, render_response instead of render_to_response. Hopefully future + Django releases will make this unnecessary.""" + + from django.shortcuts import render_to_response + from django.template import RequestContext + kwargs['context_instance'] = RequestContext(req) + return render_to_response(*args, **kwargs) + +re_body = re.compile(r"\]*\>(.*)\", re.DOTALL) +re_title = re.compile(r"\]*\>(.*)\", re.DOTALL) + +def get_html_body(text): + return get_single_match(re_body, text) + +def get_html_title(text): + return get_single_match(re_title, text) + +def get_single_match(regex, text): + match = regex.search(text) + + if match: + return match.groups()[0] + else: + return None + +def href_to_wikilinks(matchobj): + """ + Given an html link, checks for possible valid wikilinks. + + Returns the first valid wikilink. Valid means the target + object actually exists. + """ + res=CaveDescription.objects.filter(long_name__icontains=matchobj.groupdict()['text']) + if res and res[0]: + return r'[[cavedescription:'+res[0].short_name+'|'+res[0].long_name+']]' + else: + return matchobj.group() + #except: + #print 'fail' + + +re_subs = [(re.compile(r"\]*\>(.*?)\", re.DOTALL), r"'''\1'''"), + (re.compile(r"\(.*?)\", re.DOTALL), r"''\1''"), + (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"=\1="), + (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"==\1=="), + (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"===\1==="), + (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"====\1===="), + (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"=====\1====="), + (re.compile(r"\]*\>(.*?)\", re.DOTALL), r"======\1======"), + (re.compile(r'()?>|\s/>()?)', re.DOTALL),r'[[display:\g photo:\g]]'), # + (re.compile(r"\(.*?)\", re.DOTALL), r"[[subcave:\1|\2]]"), #assumes that all links with id attributes are subcaves. Not great. + #interpage link needed + (re.compile(r"\(.*?)\", re.DOTALL), r"[[cavedescription:\1|\2]]"), #assumes that all links with target ids are cave descriptions. Not great. + (re.compile(r"\[\([^\s]*).*?\\]", re.DOTALL), r"[[qm:\1]]"), + (re.compile(r'.*)"?>(?P.*)'),href_to_wikilinks), + + ] + +def html_to_wiki(text, codec = "utf-8"): + if type(text) == str: + text = unicode(text, codec) + text = re.sub("

", r"", text) + text = re.sub("

$", r"", text) + text = re.sub("

", r"\n\n", text) + out = "" + lists = "" + #lists + while text: + mstar = re.match("^(.*?)]*>\s*]*>(.*?)(.*)$", text, re.DOTALL) + munstar = re.match("^(\s*)(.*)$", text, re.DOTALL) + mhash = re.match("^(.*?)]*>\s*]*>(.*?)(.*)$", text, re.DOTALL) + munhash = re.match("^(\s*)(.*)$", text, re.DOTALL) + mitem = re.match("^(\s*)]*>(.*?)(.*)$", text, re.DOTALL) + ms = [len(m.groups()[0]) for m in [mstar, munstar, mhash, munhash, mitem] if m] + def min_(i, l): + try: + v = i.groups()[0] + l.remove(len(v)) + return len(v) < min(l, 1000000000) + except: + return False + if min_(mstar, ms): + lists += "*" + pre, val, post = mstar.groups() + out += pre + "\n" + lists + " " + val + text = post + elif min_(mhash, ms): + lists += "#" + pre, val, post = mhash.groups() + out += pre + "\n" + lists + " " + val + text = post + elif min_(mitem, ms): + pre, val, post = mitem.groups() + out += "\n" + lists + " " + val + text = post + elif min_(munstar, ms): + lists = lists[:-1] + text = munstar.groups()[1] + elif min_(munhash, ms): + lists.pop() + text = munhash.groups()[1] + else: + out += text + text = "" + #substitutions + for regex, repl in re_subs: + out = regex.sub(repl, out) + return out + + From cc27334193c9ddbef15855863934dab3f73ccdd4 Mon Sep 17 00:00:00 2001 From: Wookey Date: Mon, 11 Jul 2011 01:55:12 +0100 Subject: [PATCH 2/4] Add /index.htm to EXPOWEB root URL in main template so that you get the static stuff --- templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/base.html b/templates/base.html index d3341b242..f6bf36746 100644 --- a/templates/base.html +++ b/templates/base.html @@ -18,7 +18,7 @@

+ +{% if logbookentry.filename %}Edit Delete{%endif%} + + +{% endblock %} diff --git a/templates/newlogbookentry.html b/templates/newlogbookentry.html index 4e8eda611..36e85912f 100644 --- a/templates/newlogbookentry.html +++ b/templates/newlogbookentry.html @@ -1,83 +1,83 @@ -{% extends "base.html" %} -{% load csrffaker %} -{% block title %}Logbook {{logbookentry.id}}{% endblock %} -{% block head %} - - - - - -{{ tripForm.media }} -{% endblock %} -{% block content %} - -
{% csrf_token %} - {{ tripForm.non_field_errors }} -
- {{ tripForm.title.errors }} - - {{ tripForm.title }} -
-
- {{ tripForm.date.errors }} - - {{ tripForm.date }} -
-
- {{ tripForm.caveOrLocation.errors }} - - {{ tripForm.caveOrLocation }} -
-
- {{ tripForm.cave.errors }} - - {{ tripForm.cave }} -
-
- {{ tripForm.location.errors }} - - {{ tripForm.location }} -
- - - - - - - - - {% for form in personTripFormSet.forms %} - - - - - - {{ form.non_field_errors }} - - {% endfor %} - -
PersonTU /hoursAuthor
{{ form.name.errors }}{{ form.name }}{{ form.TU.errors }}{{ form.TU }}{{ form.author.errors }}{{ form.author }}
- {{ personTripFormSet.management_form }} -
- {{ tripForm.html.errors }} - - {{ tripForm.html }} -
-

-
- -{% endblock %} +{% extends "base.html" %} +{% load csrffaker %} +{% block title %}Logbook {{logbookentry.id}}{% endblock %} +{% block head %} + + + + + +{{ tripForm.media }} +{% endblock %} +{% block content %} + +
{% csrf_token %} + {{ tripForm.non_field_errors }} +
+ {{ tripForm.title.errors }} + + {{ tripForm.title }} +
+
+ {{ tripForm.date.errors }} + + {{ tripForm.date }} +
+
+ {{ tripForm.caveOrLocation.errors }} + + {{ tripForm.caveOrLocation }} +
+
+ {{ tripForm.cave.errors }} + + {{ tripForm.cave }} +
+
+ {{ tripForm.location.errors }} + + {{ tripForm.location }} +
+ + + + + + + + + {% for form in personTripFormSet.forms %} + + + + + + {{ form.non_field_errors }} + + {% endfor %} + +
PersonTU /hoursAuthor
{{ form.name.errors }}{{ form.name }}{{ form.TU.errors }}{{ form.TU }}{{ form.author.errors }}{{ form.author }}
+ {{ personTripFormSet.management_form }} +
+ {{ tripForm.html.errors }} + + {{ tripForm.html }} +
+

+
+ +{% endblock %} diff --git a/templates/nonpublic.html b/templates/nonpublic.html index 5befc4c00..5e44abcd4 100644 --- a/templates/nonpublic.html +++ b/templates/nonpublic.html @@ -1,9 +1,9 @@ -{% extends "base.html" %} -{% block title %} -{{instance}} is non-public -{% endblock %} - -{% block content %} -

Non-public object requested by anonymous user

-The object you requested, {{instance}}, is only viewable for logged-in users. This may be due to copyright or privacy concerns. +{% extends "base.html" %} +{% block title %} +{{instance}} is non-public +{% endblock %} + +{% block content %} +

Non-public object requested by anonymous user

+The object you requested, {{instance}}, is only viewable for logged-in users. This may be due to copyright or privacy concerns. {% endblock %} \ No newline at end of file diff --git a/templates/object_list.html b/templates/object_list.html index 7db63e031..803703f66 100644 --- a/templates/object_list.html +++ b/templates/object_list.html @@ -1,15 +1,15 @@ -{% extends "base.html" %} -{% load link %} -{% block title %}Troggle: {{object_list.1.meta.object_name}} objects{%endblock%} - -{% block contentheader %} -

{{object_list.0.object_name}} objects

-{% endblock contentheader %} - -{% block content %} -
    - {% for object in object_list %} - | {{ object|link }} - {% endfor %} | -
+{% extends "base.html" %} +{% load link %} +{% block title %}Troggle: {{object_list.1.meta.object_name}} objects{%endblock%} + +{% block contentheader %} +

{{object_list.0.object_name}} objects

+{% endblock contentheader %} + +{% block content %} +
    + {% for object in object_list %} + | {{ object|link }} + {% endfor %} | +
{% endblock content %} \ No newline at end of file diff --git a/templates/person.html b/templates/person.html index bfc9c5cc1..48dafb737 100644 --- a/templates/person.html +++ b/templates/person.html @@ -1,43 +1,43 @@ -{% extends "base.html" %} -{% load wiki_markup %} - -{% block title %}Person {{person|wiki_to_html_short}}{% endblock %} - -{% block editLink %}| Edit person {{person|wiki_to_html_short}}{% endblock %} - -{% block contentheader %} -

{{person|wiki_to_html_short}}

-{% endblock %} - -{% block content %} -{% if person.blurb %} -{{person.blurb|safe}} -{% endif %} - -{% for pic in person.photo_set.all %} -{% if pic.is_mugshot %} -
-

-

{{ pic.caption }}

-

edit {{pic}} -

-

-
-{% endif %} -{% endfor %} -
- -

{{person|wiki_to_html_short}} has been on expo in the following years:

-

-

-

- - -{% endblock %} +{% extends "base.html" %} +{% load wiki_markup %} + +{% block title %}Person {{person|wiki_to_html_short}}{% endblock %} + +{% block editLink %}| Edit person {{person|wiki_to_html_short}}{% endblock %} + +{% block contentheader %} +

{{person|wiki_to_html_short}}

+{% endblock %} + +{% block content %} +{% if person.blurb %} +{{person.blurb|safe}} +{% endif %} + +{% for pic in person.photo_set.all %} +{% if pic.is_mugshot %} +
+

+

{{ pic.caption }}

+

edit {{pic}} +

+

+
+{% endif %} +{% endfor %} +
+ +

{{person|wiki_to_html_short}} has been on expo in the following years:

+

+

+

+ + +{% endblock %} diff --git a/templates/personForm.html b/templates/personForm.html index 84ee7b79b..457723909 100644 --- a/templates/personForm.html +++ b/templates/personForm.html @@ -1,6 +1,6 @@ -{% extends "base.html" %} -{% block content %} - -{{ form }} - +{% extends "base.html" %} +{% block content %} + +{{ form }} + {% endblock %} \ No newline at end of file diff --git a/templates/personexpedition.html b/templates/personexpedition.html index 78018db4c..b88f44e4d 100644 --- a/templates/personexpedition.html +++ b/templates/personexpedition.html @@ -1,57 +1,57 @@ -{% extends "base.html" %} -{% load wiki_markup %} -{% load link %} - -{% block title %}Person {{personexpedition.person|wiki_to_html_short}} for {{personexpedition.expedition}}{% endblock %} - - -{% block content %} -

- {{personexpedition.person}} : - {{personexpedition.expedition}} -

- -

{{message}}

- -

Other years: -{% for otherpersonexpedition in personexpedition.person.personexpedition_set.all %} - {% ifequal otherpersonexpedition personexpedition %} - | {{otherpersonexpedition.expedition.year}} - {% else %} - | {{ otherpersonexpedition.expedition.year }} - {% endifequal %} -{% endfor %} -

- -

Table of all trips and surveys aligned by date

-
- - -{% for persondate in personchronology %} - - - - {% if persondate.1 %} - - - {% else %} - - {% endif %} - - {% if persondate.2 %} - - - {% else %} - - {% endif %} - - -{% endfor %} -
DateTripsSurveys
{{persondate.0}}{{persondate.1.logbook_entry.title|safe}}{{persondate.1.place|safe}} {{persondate.2}} - {% for survexpersonrole in persondate.2.survexpersonrole_set.all %} - {{survexpersonrole.nrole}} - {% endfor %} -
-
- -{% endblock %} +{% extends "base.html" %} +{% load wiki_markup %} +{% load link %} + +{% block title %}Person {{personexpedition.person|wiki_to_html_short}} for {{personexpedition.expedition}}{% endblock %} + + +{% block content %} +

+ {{personexpedition.person}} : + {{personexpedition.expedition}} +

+ +

{{message}}

+ +

Other years: +{% for otherpersonexpedition in personexpedition.person.personexpedition_set.all %} + {% ifequal otherpersonexpedition personexpedition %} + | {{otherpersonexpedition.expedition.year}} + {% else %} + | {{ otherpersonexpedition.expedition.year }} + {% endifequal %} +{% endfor %} +

+ +

Table of all trips and surveys aligned by date

+
+ + +{% for persondate in personchronology %} + + + + {% if persondate.1 %} + + + {% else %} + + {% endif %} + + {% if persondate.2 %} + + + {% else %} + + {% endif %} + + +{% endfor %} +
DateTripsSurveys
{{persondate.0}}{{persondate.1.logbook_entry.title|safe}}{{persondate.1.place|safe}} {{persondate.2}} + {% for survexpersonrole in persondate.2.survexpersonrole_set.all %} + {{survexpersonrole.nrole}} + {% endfor %} +
+
+ +{% endblock %} diff --git a/templates/personindex.html b/templates/personindex.html index 8daffc087..a6196a668 100644 --- a/templates/personindex.html +++ b/templates/personindex.html @@ -1,44 +1,44 @@ -{% extends "base.html" %} -{% load wiki_markup %} - -{% block title %}Person Index{% endblock %} - -{% block content %} - -

Notable expoers

- - -{% for person in notablepersons %} - - - - - - -{% endfor %} -
PersonFirstLastNotability
{{person|wiki_to_html_short}}{{ person.first.expedition.year }}{{ person.last.expedition.year }}{{person.notability}}
- - -

All expoers

- - -{% for persons in personss %} - -{% endfor %} - -
- - - -{% for person in persons %} - - - - - - -{% endfor %} -
PersonFirstLastSurveyed length
{{person|wiki_to_html_short}}{{person.first.expedition.year}}{{person.last.expedition.year}}{{ person.surveyedleglength }}
-
- -{% endblock %} +{% extends "base.html" %} +{% load wiki_markup %} + +{% block title %}Person Index{% endblock %} + +{% block content %} + +

Notable expoers

+ + +{% for person in notablepersons %} + + + + + + +{% endfor %} +
PersonFirstLastNotability
{{person|wiki_to_html_short}}{{ person.first.expedition.year }}{{ person.last.expedition.year }}{{person.notability}}
+ + +

All expoers

+ + +{% for persons in personss %} + +{% endfor %} + +
+ + + +{% for person in persons %} + + + + + + +{% endfor %} +
PersonFirstLastSurveyed length
{{person|wiki_to_html_short}}{{person.first.expedition.year}}{{person.last.expedition.year}}{{ person.surveyedleglength }}
+
+ +{% endblock %} diff --git a/templates/profiles/create_profile.html b/templates/profiles/create_profile.html index 7e3259799..a14716029 100644 --- a/templates/profiles/create_profile.html +++ b/templates/profiles/create_profile.html @@ -1,13 +1,13 @@ -{% extends "base.html" %} - -{% block content %} - -
-{{ form.as_p }} - -
- -{% if form.errors %} -

Please correct the errors below

-{% endif %} +{% extends "base.html" %} + +{% block content %} + +
+{{ form.as_p }} + +
+ +{% if form.errors %} +

Please correct the errors below

+{% endif %} {% endblock %} \ No newline at end of file diff --git a/templates/profiles/edit_profile.html b/templates/profiles/edit_profile.html index 7e3259799..a14716029 100644 --- a/templates/profiles/edit_profile.html +++ b/templates/profiles/edit_profile.html @@ -1,13 +1,13 @@ -{% extends "base.html" %} - -{% block content %} - -
-{{ form.as_p }} - -
- -{% if form.errors %} -

Please correct the errors below

-{% endif %} +{% extends "base.html" %} + +{% block content %} + +
+{{ form.as_p }} + +
+ +{% if form.errors %} +

Please correct the errors below

+{% endif %} {% endblock %} \ No newline at end of file diff --git a/templates/profiles/profile_detail.html b/templates/profiles/profile_detail.html index baf3fae6b..cf2fb765b 100644 --- a/templates/profiles/profile_detail.html +++ b/templates/profiles/profile_detail.html @@ -1,14 +1,14 @@ -{% extends "base.html" %} - -{% block contentheader %} -

Profile for {{ profile }}

-{% endblock %} - -{% block content %} - -{{ profile }} - -{% if form.errors %} -

Please correct the errors below

-{% endif %} +{% extends "base.html" %} + +{% block contentheader %} +

Profile for {{ profile }}

+{% endblock %} + +{% block content %} + +{{ profile }} + +{% if form.errors %} +

Please correct the errors below

+{% endif %} {% endblock %} \ No newline at end of file diff --git a/templates/profiles/select_profile.html b/templates/profiles/select_profile.html index 810efd264..e18191be0 100644 --- a/templates/profiles/select_profile.html +++ b/templates/profiles/select_profile.html @@ -1,40 +1,40 @@ -{% extends "base.html" %} - -{% block content %} - -

Troggle profile selection page

- -Hello, {{ user }}. - -

- -{% if user.person %} -This is where you go to associate a new user account with a pre-existing profile from old expo data. - -

- -However, you already have a profile- your name should be {{user.person.first_name}} {{user.person.last_name}}. If you don't believe me, go see it at:

{{ user.person.get_absolute_url }}

or edit it at: -

{{ user.person.get_admin_url }} .

- -If your account is associated with the wrong person's profile due to inebriation or incompetance during account setup, click here to dissasociate your profile from your user account. - -{% else %} - -You have an account in the system, but no profile. If you have been on expo before, please choose yourself from the list below. -

- -
-{{ form.as_p }} - -
-
- -Yes, you could choose the wrong person if you want. That would be lame. Instead, do something that's actually funny. For example, fry a random object or maybe take some mac and cheese somewhere it doesn't usually get to go. Perhaps you can start a new tradition of laminating the expo leader. - - -{% endif %} - -{% if form.errors %} -

Please correct the errors below

-{% endif %} +{% extends "base.html" %} + +{% block content %} + +

Troggle profile selection page

+ +Hello, {{ user }}. + +

+ +{% if user.person %} +This is where you go to associate a new user account with a pre-existing profile from old expo data. + +

+ +However, you already have a profile- your name should be {{user.person.first_name}} {{user.person.last_name}}. If you don't believe me, go see it at:

{{ user.person.get_absolute_url }}

or edit it at: +

{{ user.person.get_admin_url }} .

+ +If your account is associated with the wrong person's profile due to inebriation or incompetance during account setup, click here to dissasociate your profile from your user account. + +{% else %} + +You have an account in the system, but no profile. If you have been on expo before, please choose yourself from the list below. +

+ +
+{{ form.as_p }} + +
+
+ +Yes, you could choose the wrong person if you want. That would be lame. Instead, do something that's actually funny. For example, fry a random object or maybe take some mac and cheese somewhere it doesn't usually get to go. Perhaps you can start a new tradition of laminating the expo leader. + + +{% endif %} + +{% if form.errors %} +

Please correct the errors below

+{% endif %} {% endblock %} \ No newline at end of file diff --git a/templates/qm.html b/templates/qm.html index 6e2a2fb5b..f96019776 100644 --- a/templates/qm.html +++ b/templates/qm.html @@ -1,49 +1,49 @@ -{% extends "base.html" %} -{% load wiki_markup %} -{% load link %} - -{% block title %} QM: {{qm|wiki_to_html_short}} {% endblock %} - -{% block editLink %}| Edit QM {{qm|wiki_to_html_short}}{% endblock %} - - - -{% block contentheader %} - - - - - - -
Previous{{qm|wiki_to_html_short}}Next
-{% endblock %} - -{% block related %} - -{% endblock %} -

Related items

- -Parent cave: {{qm.found_by.cave|link}} -(todo: add parent survey and parent subcave) -{% block content %} - -

Location

-{{qm.location_description}} - - -

Creation

-Found by {{qm.found_by}} on {{qm.found_by.date}}. - -

Completion

-{% if ticked_off_by %} -{{qm.completion_description}} -Ticked off by: {{qm.ticked_off_by}}
-Description: {{qm.completion_description}} -{% else %} -None yet- STILL EXTANT. -{% endif %} - -

Comment

-{{qm.comment}} - -{% endblock %} +{% extends "base.html" %} +{% load wiki_markup %} +{% load link %} + +{% block title %} QM: {{qm|wiki_to_html_short}} {% endblock %} + +{% block editLink %}| Edit QM {{qm|wiki_to_html_short}}{% endblock %} + + + +{% block contentheader %} + + + + + + +
Previous{{qm|wiki_to_html_short}}Next
+{% endblock %} + +{% block related %} + +{% endblock %} +

Related items

+ +Parent cave: {{qm.found_by.cave|link}} +(todo: add parent survey and parent subcave) +{% block content %} + +

Location

+{{qm.location_description}} + + +

Creation

+Found by {{qm.found_by}} on {{qm.found_by.date}}. + +

Completion

+{% if ticked_off_by %} +{{qm.completion_description}} +Ticked off by: {{qm.ticked_off_by}}
+Description: {{qm.completion_description}} +{% else %} +None yet- STILL EXTANT. +{% endif %} + +

Comment

+{{qm.comment}} + +{% endblock %} diff --git a/templates/registration/activate.html b/templates/registration/activate.html index ba6be9280..3f95a18ec 100644 --- a/templates/registration/activate.html +++ b/templates/registration/activate.html @@ -1,25 +1,25 @@ -{% extends "base.html" %} - -{% block title %} -New troggle account registered -{% endblock %} - -{% block header %} -

activate.html

-{% endblock %} - -{% block content %} - -{% if account %} -

-Hello, {{ account }}! Your account is now activated. Now you can log in with the password you chose. Use the links in the upper right to control this in the future. -

- -

-If you have been on the expedition in the past, you already have a profile in the system; click here to find it and link it to your account. Otherwise, please create yourself a new profile. -

-{% else %} - -The activation key you entered has already been used or was invalid. -{% endif %} +{% extends "base.html" %} + +{% block title %} +New troggle account registered +{% endblock %} + +{% block header %} +

activate.html

+{% endblock %} + +{% block content %} + +{% if account %} +

+Hello, {{ account }}! Your account is now activated. Now you can log in with the password you chose. Use the links in the upper right to control this in the future. +

+ +

+If you have been on the expedition in the past, you already have a profile in the system; click here to find it and link it to your account. Otherwise, please create yourself a new profile. +

+{% else %} + +The activation key you entered has already been used or was invalid. +{% endif %} {% endblock %} diff --git a/templates/registration/activation_email.html b/templates/registration/activation_email.html index 3d560095f..abb0ad139 100644 --- a/templates/registration/activation_email.html +++ b/templates/registration/activation_email.html @@ -1,10 +1,10 @@ -

Hello {{ form.user }},

- -

Glad you're joining the CUCC EXPO team! Please go to

- -

{{ 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.

- -

Yours,
-The magical troggle

+

Hello {{ form.user }},

+ +

Glad you're joining the CUCC EXPO team! Please go to

+ +

{{ 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.

+ +

Yours,
+The magical troggle

diff --git a/templates/registration/activation_email.txt b/templates/registration/activation_email.txt index 20aad5f8a..9b240c2e1 100644 --- a/templates/registration/activation_email.txt +++ b/templates/registration/activation_email.txt @@ -1,10 +1,10 @@ -Hello {{ form.user }}, - -Glad you're joining the CUCC EXPO team! Please go to - -{{ 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. - -Yours, +Hello {{ form.user }}, + +Glad you're joining the CUCC EXPO team! Please go to + +{{ 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. + +Yours, The magical troggle \ No newline at end of file diff --git a/templates/registration/login.html b/templates/registration/login.html index b93e4d8f9..388d41b5e 100644 --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -1,20 +1,20 @@ -{% extends "base.html" %} -{% load csrffaker %} - -{% block content %} - -{% if form.errors %} -

Your username and password didn't match. Please try again.

-{% endif %} - -
{% csrf_token %} - - - -
{{ form.username.label_tag }}{{ form.username }}
{{ form.password.label_tag }}{{ form.password }}
- - - -
- -{% endblock %} +{% extends "base.html" %} +{% load csrffaker %} + +{% block content %} + +{% if form.errors %} +

Your username and password didn't match. Please try again.

+{% endif %} + +
{% csrf_token %} + + + +
{{ form.username.label_tag }}{{ form.username }}
{{ form.password.label_tag }}{{ form.password }}
+ + + +
+ +{% endblock %} diff --git a/templates/registration/logout.html b/templates/registration/logout.html index 9e40c20d3..ef2a3b253 100644 --- a/templates/registration/logout.html +++ b/templates/registration/logout.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} -{% block content %} - You have been logged out. +{% extends "base.html" %} +{% block content %} + You have been logged out. {% endblock %} \ No newline at end of file diff --git a/templates/registration/registration_activate.html b/templates/registration/registration_activate.html index cbd540e52..6566bf445 100644 --- a/templates/registration/registration_activate.html +++ b/templates/registration/registration_activate.html @@ -1,6 +1,6 @@ -{% extends “base.html” %} -{% block body %} -Hello {{ account }}! - -Check your email to confirm the activation. There are {{ expiration_days }} days left to do it. +{% extends “base.html” %} +{% block body %} +Hello {{ account }}! + +Check your email to confirm the activation. There are {{ expiration_days }} days left to do it. {% endblock %} \ No newline at end of file diff --git a/templates/registration/registration_complete.html b/templates/registration/registration_complete.html index 78684fe86..4dac94bd8 100644 --- a/templates/registration/registration_complete.html +++ b/templates/registration/registration_complete.html @@ -1,13 +1,13 @@ -{% extends "base.html" %} - -{% block title %} -{{ block.super }}: registration complete -{% endblock %} - -{% block contentheader %} -

Registration Complete

-{% endblock %} - -{% block content %} -

Thank you for signing up. An email with the activation code has been sent to your inbox.

+{% extends "base.html" %} + +{% block title %} +{{ block.super }}: registration complete +{% endblock %} + +{% block contentheader %} +

Registration Complete

+{% endblock %} + +{% block content %} +

Thank you for signing up. An email with the activation code has been sent to your inbox.

{% endblock %} \ No newline at end of file diff --git a/templates/statistics.html b/templates/statistics.html index 1fddd674d..daca75284 100644 --- a/templates/statistics.html +++ b/templates/statistics.html @@ -1,8 +1,8 @@ -{% extends "base.html" %} -{% load wiki_markup %} - -{% block title %}Database statistics{% endblock %} - -{% block content %} -Over the course of {{ expoCount }} expeditions, {{ personCount }} people have contributed {{ caveCount }} caves and {{ logbookEntryCount }} logbook entries. +{% extends "base.html" %} +{% load wiki_markup %} + +{% block title %}Database statistics{% endblock %} + +{% block content %} +Over the course of {{ expoCount }} expeditions, {{ personCount }} people have contributed {{ caveCount }} caves and {{ logbookEntryCount }} logbook entries. {% endblock %} \ No newline at end of file diff --git a/templates/subcave.html b/templates/subcave.html index fbb8d1d64..41fb2d047 100644 --- a/templates/subcave.html +++ b/templates/subcave.html @@ -1,59 +1,59 @@ -{% extends "cavebase.html" %} -{% load wiki_markup %} -{% load mptt_tags %} -{% block title %} Subcave {{subcave}} {% endblock title %} -{% block editLink %}Edit subcave {{subcave|wiki_to_html_short}}{% endblock %} - -{% block contentheader %} - {{subcave.title}} -{% endblock contentheader %} - - - -{% block content %} -{% block related %} - -

Related places

- -

Parent

- - - -

Connected subareas

- -
    - {% for sibling in subcave.adjoining.all%} -
  • {{silbling}}
  • - {% endfor %} -
- -

Children

- -
    - {% for child in subcave.children.all %} -
  • {{child}}
  • - {% endfor %} -
- - -{% endblock %} - -ok here comes the drilldown
-{% drilldown_tree_for_node subcave as drilldown %} -{% for each in drilldown %} -{{ each }}> -{% endfor %} - - -

{{subcave}}

-

- {{subcave.description}} -

- +{% extends "cavebase.html" %} +{% load wiki_markup %} +{% load mptt_tags %} +{% block title %} Subcave {{subcave}} {% endblock title %} +{% block editLink %}Edit subcave {{subcave|wiki_to_html_short}}{% endblock %} + +{% block contentheader %} + {{subcave.title}} +{% endblock contentheader %} + + + +{% block content %} +{% block related %} + +

Related places

+ +

Parent

+ + + +

Connected subareas

+ +
    + {% for sibling in subcave.adjoining.all%} +
  • {{silbling}}
  • + {% endfor %} +
+ +

Children

+ +
    + {% for child in subcave.children.all %} +
  • {{child}}
  • + {% endfor %} +
+ + +{% endblock %} + +ok here comes the drilldown
+{% drilldown_tree_for_node subcave as drilldown %} +{% for each in drilldown %} +{{ each }}> +{% endfor %} + + +

{{subcave}}

+

+ {{subcave.description}} +

+ {% endblock content %} \ No newline at end of file diff --git a/templates/survexblock.html b/templates/survexblock.html index 31958c066..c4c1066dc 100644 --- a/templates/survexblock.html +++ b/templates/survexblock.html @@ -1,49 +1,49 @@ -{% extends "base.html" %} -{% load wiki_markup %} -{% load survex_markup %} - - -{% block title %}Survex Block{% endblock %} - -{% block content %} -

Survex Block {{survexblock.survexpath}}

- -

Link to {{survexblock.survexfile.path}}

- -

Needs duplicates removed from right hand column

-

Needs links to survex file presentation

-

Needs to start dealing with misspellings of names (prob by editing the originals)

- -
- -{% if survexblock.parent %} -

Survey block above:

-

{{survexblock.parent.survexpath}}

-{% endif %} - -{% if survexblock.survexblock_set.all %} -

Survey blocks below:

- {% for survexblockdown in survexblock.survexblock_set.all %} -

{{survexblockdown.survexpath}}

- {% endfor %} -{% endif %} - -

Date: {{survexblock.date}}

- - -{% for personrole in survexblock.GetPersonroles %} - - - - -{% endfor %} -
{{personrole.person}}{{personrole.roles}}
- - -
- -
- {{ftext|survex_to_html}} -
- -{% endblock %} +{% extends "base.html" %} +{% load wiki_markup %} +{% load survex_markup %} + + +{% block title %}Survex Block{% endblock %} + +{% block content %} +

Survex Block {{survexblock.survexpath}}

+ +

Link to {{survexblock.survexfile.path}}

+ +

Needs duplicates removed from right hand column

+

Needs links to survex file presentation

+

Needs to start dealing with misspellings of names (prob by editing the originals)

+ +
+ +{% if survexblock.parent %} +

Survey block above:

+

{{survexblock.parent.survexpath}}

+{% endif %} + +{% if survexblock.survexblock_set.all %} +

Survey blocks below:

+ {% for survexblockdown in survexblock.survexblock_set.all %} +

{{survexblockdown.survexpath}}

+ {% endfor %} +{% endif %} + +

Date: {{survexblock.date}}

+ + +{% for personrole in survexblock.GetPersonroles %} + + + + +{% endfor %} +
{{personrole.person}}{{personrole.roles}}
+ + +
+ +
+ {{ftext|survex_to_html}} +
+ +{% endblock %} diff --git a/templates/survexscansfolder.html b/templates/survexscansfolder.html index 6f8bd3aff..fe2191662 100644 --- a/templates/survexscansfolder.html +++ b/templates/survexscansfolder.html @@ -1,33 +1,33 @@ -{% extends "base.html" %} -{% load wiki_markup %} -{% load survex_markup %} - -{% block title %}Survex Scans Folder{% endblock %} - -{% block content %} - -

Survex Scans in: {{survexscansfolder.walletname}}

- -{% for survexscansingle in survexscansfolder.survexscansingle_set.all %} - - - - -{% endfor %} -
{{survexscansingle.name}} - {% for survexblock in survexscansingle.survexblock_set.all %} - {{survexblock}} - {% endfor %} -
- -

Surveys referring to this wallet

- - -{% for survexblock in survexscansfolder.survexblock_set.all %} - - - -{% endfor %} -
{{survexblock}}
- -{% endblock %} +{% extends "base.html" %} +{% load wiki_markup %} +{% load survex_markup %} + +{% block title %}Survex Scans Folder{% endblock %} + +{% block content %} + +

Survex Scans in: {{survexscansfolder.walletname}}

+ +{% for survexscansingle in survexscansfolder.survexscansingle_set.all %} + + + + +{% endfor %} +
{{survexscansingle.name}} + {% for survexblock in survexscansingle.survexblock_set.all %} + {{survexblock}} + {% endfor %} +
+ +

Surveys referring to this wallet

+ + +{% for survexblock in survexscansfolder.survexblock_set.all %} + + + +{% endfor %} +
{{survexblock}}
+ +{% endblock %} diff --git a/templates/survexscansfolders.html b/templates/survexscansfolders.html index 195b8982b..597bacfe6 100644 --- a/templates/survexscansfolders.html +++ b/templates/survexscansfolders.html @@ -1,25 +1,25 @@ -{% extends "base.html" %} -{% load wiki_markup %} -{% load survex_markup %} - -{% block title %}All Survex scans folders{% endblock %} - -{% block content %} - -

All Survex scans folders

- - -{% for survexscansfolder in survexscansfolders %} - - - - - -{% endfor %} -
Scans folderFilesSurvex blocks
{{survexscansfolder.walletname}}{{survexscansfolder.survexscansingle_set.all|length}} - {% for survexblock in survexscansfolder.survexblock_set.all %} - {{survexblock}} - {% endfor %} -
- +{% extends "base.html" %} +{% load wiki_markup %} +{% load survex_markup %} + +{% block title %}All Survex scans folders{% endblock %} + +{% block content %} + +

All Survex scans folders

+ + +{% for survexscansfolder in survexscansfolders %} + + + + + +{% endfor %} +
Scans folderFilesSurvex blocks
{{survexscansfolder.walletname}}{{survexscansfolder.survexscansingle_set.all|length}} + {% for survexblock in survexscansfolder.survexblock_set.all %} + {{survexblock}} + {% endfor %} +
+ {% endblock %} \ No newline at end of file diff --git a/templates/survey.html b/templates/survey.html index 37b2dfe9a..9dca0dfba 100644 --- a/templates/survey.html +++ b/templates/survey.html @@ -1,193 +1,193 @@ -{% extends "base.html" %} -{% load wiki_markup %} - - -{% block title %}CUCC Virtual Survey Binder: {{ current_expedition }}{{ current_survey }}{%endblock%} -{% block head %} - - - - - -{% endblock %} - -
- CUCC Expo virtual survey binder: - {% if current_survey %} - {{current_survey}} - {% else %} - {{current_expedition}} - {% endif %} -
- -{% block nav %} -
- -

Choose a year

-
- -
- -
- - -
-{% if current_expedition %} -

Choose a wallet number

-
- - -
-

Click to toggle:

-
- - - - - - -
- -{% endif %} -{% endblock %} - - -{% block content %} -
- -
-

Survey progress table for {{ current_expedition }}

- {% if current_expedition.survey_set.all %} - - - - {% for survey in current_expedition.survey_set.all %} - - {% endfor %} - - - {% for survey in current_expedition.survey_set.all %} - - {% endfor %} - - - {% for survey in current_expedition.survey_set.all %} - - {% endfor %} - - - {% for survey in current_expedition.survey_set.all %} - - {% endfor %} - - - {% for survey in current_expedition.survey_set.all %} - - {% endfor %} -
{{ survey.wallet_number }}
Notes {% if survey.notes %} - ✓ - {% endif %}
Survex file {% if survey.survex_file %} - ✓ - {% endif %}
Plans {% if survey.plans %} - ✓ - {% endif %}
Elevations {% if survey.elevations %} - ✓ - {% endif %}
- {% else %} -
[ There are no surveys in the database for this year. Put link in to add one. ]
- {% endif %} -
-
-

Scanned notes for {{ current_survey }}.

- {% for noteItem in notes %} -
-

-

File at: {{ noteItem.file.name }}
- Scanned by: {{ noteItem.scanned_by }}
- On: {{ noteItem.scanned_on }}
-

-

-
- {% endfor %} - -
-
-
survex file editor, keeping file in original structure
- who entered by
-
centreline
-
-

Scanned plan sketch files for {{ current_survey }}.

- {% for sketchItem in planSketches %} -
-

-

File at: {{ sketchItem.file.name }}
- Scanned by: {{ sketchItem.scanned_by }}
- On: {{ sketchItem.scanned_on }}
-

-

-
- {% endfor %} - -
-
link to tunnel xml file. potentially instance of tunnel applet...
-
link to main sketch file
- -
-
- -{% endblock %} +{% extends "base.html" %} +{% load wiki_markup %} + + +{% block title %}CUCC Virtual Survey Binder: {{ current_expedition }}{{ current_survey }}{%endblock%} +{% block head %} + + + + + +{% endblock %} + +
+ CUCC Expo virtual survey binder: + {% if current_survey %} + {{current_survey}} + {% else %} + {{current_expedition}} + {% endif %} +
+ +{% block nav %} +
+ +

Choose a year

+
+ +
+ +
+ + +
+{% if current_expedition %} +

Choose a wallet number

+
+ + +
+

Click to toggle:

+
+ + + + + + +
+ +{% endif %} +{% endblock %} + + +{% block content %} +
+ +
+

Survey progress table for {{ current_expedition }}

+ {% if current_expedition.survey_set.all %} + + + + {% for survey in current_expedition.survey_set.all %} + + {% endfor %} + + + {% for survey in current_expedition.survey_set.all %} + + {% endfor %} + + + {% for survey in current_expedition.survey_set.all %} + + {% endfor %} + + + {% for survey in current_expedition.survey_set.all %} + + {% endfor %} + + + {% for survey in current_expedition.survey_set.all %} + + {% endfor %} +
{{ survey.wallet_number }}
Notes {% if survey.notes %} + ✓ + {% endif %}
Survex file {% if survey.survex_file %} + ✓ + {% endif %}
Plans {% if survey.plans %} + ✓ + {% endif %}
Elevations {% if survey.elevations %} + ✓ + {% endif %}
+ {% else %} +
[ There are no surveys in the database for this year. Put link in to add one. ]
+ {% endif %} +
+
+

Scanned notes for {{ current_survey }}.

+ {% for noteItem in notes %} +
+

+

File at: {{ noteItem.file.name }}
+ Scanned by: {{ noteItem.scanned_by }}
+ On: {{ noteItem.scanned_on }}
+

+

+
+ {% endfor %} + +
+
+
survex file editor, keeping file in original structure
+ who entered by
+
centreline
+
+

Scanned plan sketch files for {{ current_survey }}.

+ {% for sketchItem in planSketches %} +
+

+

File at: {{ sketchItem.file.name }}
+ Scanned by: {{ sketchItem.scanned_by }}
+ On: {{ sketchItem.scanned_on }}
+

+

+
+ {% endfor %} + +
+
link to tunnel xml file. potentially instance of tunnel applet...
+
link to main sketch file
+ +
+
+ +{% endblock %} diff --git a/templates/svxcavesingle.html b/templates/svxcavesingle.html index 123e92ad1..1d24466f4 100644 --- a/templates/svxcavesingle.html +++ b/templates/svxcavesingle.html @@ -1,81 +1,81 @@ -{% extends "base.html" %} -{% load wiki_markup %} -{% load link %} - -{% block title %}List of survex files{% endblock %} - -{% block content %} - -

Surveys for {{cave}}

- -

-{% for survexdirectory in cave.survexdirectory_set.all %} - {{survexdirectory.path}} -{% endfor %} -

- -{% for survexdirectory in cave.survexdirectory_set.all %} -

{{survexdirectory.path}}

- - - - -{% for survexfile in survexdirectory.survexfile_set.all %} - - {% if survexfile.exists %} - - - -{% for survexblock in survexfile.survexblock_set.all %} - - - - - - - - - - - - -{% endfor %} -{% endfor %} -
Survex fileBlockDateExplorerslengthTitlesScans
- {% else %} - - {% endif %} - - {% ifequal survexfile survexdirectory.primarysurvexfile %} - {{survexfile.path}} - {% else %} - {{survexfile.path}} - {% endifequal %} -
{{survexblock.name}} - {% if survexblock.expedition %} - {{survexblock.date}} - {% else %} - {{survexblock.date}} - {% endif %} - - {% for personrole in survexblock.personrole_set.all %} - {% if personrole.personexpedition %} - {{personrole.personname}} - {% else %} - {{personrole.personname}} - {% endif %} - {% endfor %} - {{survexblock.totalleglength}} - {% for survextitle in survexblock.survextitle_set.all %} - {{survextitle.title}} - {% endfor %} - - {% if survexblock.survexscansfolder %} - {{survexblock.survexscansfolder.walletname}} - {% endif %} -
- -{% endfor %} - -{% endblock %} - +{% extends "base.html" %} +{% load wiki_markup %} +{% load link %} + +{% block title %}List of survex files{% endblock %} + +{% block content %} + +

Surveys for {{cave}}

+ +

+{% for survexdirectory in cave.survexdirectory_set.all %} + {{survexdirectory.path}} +{% endfor %} +

+ +{% for survexdirectory in cave.survexdirectory_set.all %} +

{{survexdirectory.path}}

+ + + + +{% for survexfile in survexdirectory.survexfile_set.all %} + + {% if survexfile.exists %} + + + +{% for survexblock in survexfile.survexblock_set.all %} + + + + + + + + + + + + +{% endfor %} +{% endfor %} +
Survex fileBlockDateExplorerslengthTitlesScans
+ {% else %} + + {% endif %} + + {% ifequal survexfile survexdirectory.primarysurvexfile %} + {{survexfile.path}} + {% else %} + {{survexfile.path}} + {% endifequal %} +
{{survexblock.name}} + {% if survexblock.expedition %} + {{survexblock.date}} + {% else %} + {{survexblock.date}} + {% endif %} + + {% for personrole in survexblock.personrole_set.all %} + {% if personrole.personexpedition %} + {{personrole.personname}} + {% else %} + {{personrole.personname}} + {% endif %} + {% endfor %} + {{survexblock.totalleglength}} + {% for survextitle in survexblock.survextitle_set.all %} + {{survextitle.title}} + {% endfor %} + + {% if survexblock.survexscansfolder %} + {{survexblock.survexscansfolder.walletname}} + {% endif %} +
+ +{% endfor %} + +{% endblock %} + diff --git a/templates/svxfile.html b/templates/svxfile.html index ed4318dd2..bf9f1c3b6 100644 --- a/templates/svxfile.html +++ b/templates/svxfile.html @@ -1,76 +1,76 @@ -{% extends "base.html" %} -{% load survex_markup %} - -{% block title %}{{ title }}{% endblock %} - -{% block head %} - - - - - -{% endblock %} - -{% block content %} -

Survex File: {{ title }}

- -{% if svxincludes %} -

Included files: -{% for svxinclude in svxincludes %} - {{svxinclude}} -{% endfor %} -

-{% endif %} - -
-
{{form.code}}
-
{{form.filename}} {{form.dirname}} {{form.datetime}} {{form.outputtype}}
- - - -
- -
-
-{% for diffline in difflist %}{{diffline}}
-{% endfor %}
-
- -{% if logmessage %} -{% if has_3d %} -

3d file

-{% else %} -

No 3d file

-{% endif %} -
-LOGMESSAGES
-{{logmessage}}
-
-{% endif %} -
- -{% endblock %} +{% extends "base.html" %} +{% load survex_markup %} + +{% block title %}{{ title }}{% endblock %} + +{% block head %} + + + + + +{% endblock %} + +{% block content %} +

Survex File: {{ title }}

+ +{% if svxincludes %} +

Included files: +{% for svxinclude in svxincludes %} + {{svxinclude}} +{% endfor %} +

+{% endif %} + +
+
{{form.code}}
+
{{form.filename}} {{form.dirname}} {{form.datetime}} {{form.outputtype}}
+ + + +
+ +
+
+{% for diffline in difflist %}{{diffline}}
+{% endfor %}
+
+ +{% if logmessage %} +{% if has_3d %} +

3d file

+{% else %} +

No 3d file

+{% endif %} +
+LOGMESSAGES
+{{logmessage}}
+
+{% endif %} +
+ +{% endblock %} diff --git a/templates/svxfilecavelist.html b/templates/svxfilecavelist.html index a0db893d7..52c8e83bb 100644 --- a/templates/svxfilecavelist.html +++ b/templates/svxfilecavelist.html @@ -1,66 +1,66 @@ -{% extends "base.html" %} -{% load wiki_markup %} -{% load link %} - -{% block title %}List of survex files{% endblock %} - -{% block content %} -

caves with subdirectories | caves with multiple files | caves with single files

- -

Link to all.svx for processing

- -

Caves with subdirectories

- -{% for subdircave, cavefiles, subsurvdirs in subdircaves %} -

{{cavefiles.0.1}} - dates and explorers

- - - - - - -{% for primarycavefile, subcavefiles in subsurvdirs %} - - - - -{% endfor %} -
{{cavefiles.0.1}} - {% for cavepath, cavename in cavefiles.1 %} - {{cavename}} - {% endfor %} -
{{primarycavefile.1}} - {% for cavepath, cavename in subcavefiles %} - {{cavename}} - {% endfor %} -
- -{% endfor %} - - -

Caves of multiple files

- - -{% for primarycavefile, subcavefiles in multifilecaves %} - - - - -{% endfor %} -
Dates and explorersSurvex files
- {{primarycavefile.1}} - - {{primarycavefile.1}} - - {% for cavepath, cavename in subcavefiles %} - {{cavename}} - {% endfor %} -
- -

Caves of one file

-

-{% for cavepath, cavename in onefilecaves %} - {{cavename}} -{% endfor %} -

- -{% endblock %} +{% extends "base.html" %} +{% load wiki_markup %} +{% load link %} + +{% block title %}List of survex files{% endblock %} + +{% block content %} +

caves with subdirectories | caves with multiple files | caves with single files

+ +

Link to all.svx for processing

+ +

Caves with subdirectories

+ +{% for subdircave, cavefiles, subsurvdirs in subdircaves %} +

{{cavefiles.0.1}} - dates and explorers

+ + + + + + +{% for primarycavefile, subcavefiles in subsurvdirs %} + + + + +{% endfor %} +
{{cavefiles.0.1}} + {% for cavepath, cavename in cavefiles.1 %} + {{cavename}} + {% endfor %} +
{{primarycavefile.1}} + {% for cavepath, cavename in subcavefiles %} + {{cavename}} + {% endfor %} +
+ +{% endfor %} + + +

Caves of multiple files

+ + +{% for primarycavefile, subcavefiles in multifilecaves %} + + + + +{% endfor %} +
Dates and explorersSurvex files
+ {{primarycavefile.1}} + + {{primarycavefile.1}} - + {% for cavepath, cavename in subcavefiles %} + {{cavename}} + {% endfor %} +
+ +

Caves of one file

+

+{% for cavepath, cavename in onefilecaves %} + {{cavename}} +{% endfor %} +

+ +{% endblock %} diff --git a/templates/svxfiledifflistonly.html b/templates/svxfiledifflistonly.html index f51744ee2..835125bea 100644 --- a/templates/svxfiledifflistonly.html +++ b/templates/svxfiledifflistonly.html @@ -1,18 +1,18 @@ -
- using difflistonly.html
-{% for diffline in difflist %}{{diffline}}
-{% endfor %}
-
- -{% if logmessage %} -{% if has_3d %} -

3d file

-{% else %} -

No 3d file

-{% endif %} -
-LOGMESSAGES
-{{logmessage}}
-
-{% endif %} - +
+ using difflistonly.html
+{% for diffline in difflist %}{{diffline}}
+{% endfor %}
+
+ +{% if logmessage %} +{% if has_3d %} +

3d file

+{% else %} +

No 3d file

+{% endif %} +
+LOGMESSAGES
+{{logmessage}}
+
+{% endif %} + diff --git a/templates/tasks.html b/templates/tasks.html index a429bd5df..36d35f415 100644 --- a/templates/tasks.html +++ b/templates/tasks.html @@ -1,39 +1,39 @@ -{% extends "base.html" %} -{% load wiki_markup %} -{% load link %} - -{% block title %}Cambridge Expeditions to Austria{% endblock %} - -{% block content %} -

Expo member tasks

- -

Add new data

- -
  • Upload a photo
  • -
  • Record a new trip
  • - -

    Your unfinished business

    - {% for survey in surveys_unfinished %} -
  • {{survey|link}}
  • - {% endfor %} - -

    General unfinished business

    -add wikilinks - -

    Caving recommendations

    - {% for qm in qms_recommended %} -
  • {{qm|link}}
  • - {% endfor %} - -

    Profile tasks

    - -
  • Dates present on expo
  • -
  • Mugshot
  • -
  • Blurb
  • - -{% endblock content %} - -{% block margins %} - - -{% endblock margins %} +{% extends "base.html" %} +{% load wiki_markup %} +{% load link %} + +{% block title %}Cambridge Expeditions to Austria{% endblock %} + +{% block content %} +

    Expo member tasks

    + +

    Add new data

    + +
  • Upload a photo
  • +
  • Record a new trip
  • + +

    Your unfinished business

    + {% for survey in surveys_unfinished %} +
  • {{survey|link}}
  • + {% endfor %} + +

    General unfinished business

    +add wikilinks + +

    Caving recommendations

    + {% for qm in qms_recommended %} +
  • {{qm|link}}
  • + {% endfor %} + +

    Profile tasks

    + +
  • Dates present on expo
  • +
  • Mugshot
  • +
  • Blurb
  • + +{% endblock content %} + +{% block margins %} + + +{% endblock margins %} diff --git a/templates/todo.html b/templates/todo.html index 0aafadb46..a678f50d2 100644 --- a/templates/todo.html +++ b/templates/todo.html @@ -1,61 +1,61 @@ -{% extends "base.html" %} -{% load wiki_markup %} - -{% block title %}Cambridge Expeditions to Austria{% endblock %} - -{% block content %} - -

    The unfinished front page

    - - -

    Further work

    - -

    Please see the issues tracker on google code. You can contribute new feature requests and bug reports.

    - -

    Julian's work: -

    parse 1992-1976 logbooks; (esp top 161)

    -

    detect T/U on log entries;

    -

    name matching and spelling in survex files;

    -

    Improve logbook wikihtml text

    - -

    Other work:

    -

    surf through the tunnel sketches and images

    -

    bugs with all.svx block (double dot) -

    render bitmap view of every survex block as a thumbnail

    -

    upload tunnel images and tunnel sketches

    -

    where are the subcaves;

    -

    cave section entrance match for logbook entries

    -

    simplify the survex parsing code (if necessary);

    -

    wiki survex stop linegap between comment lins

    -

    links between logbooks and survex blocks to cave things;

    -

    mini-tree of survexblocks;

    -

    connect sketches to caves to survey blocks and render thumbnailwise;

    -

    all images to start appearing in pages; and so on

    - -

    {{message}}

    - -
    - - -
    - -
      -{% for expedition in expeditions %} -
    • - {{expedition.name}} - - {{expedition.logbookentry_set.count}} logbook entries -
    • -{% endfor %} -
    - -{% endblock %} +{% extends "base.html" %} +{% load wiki_markup %} + +{% block title %}Cambridge Expeditions to Austria{% endblock %} + +{% block content %} + +

    The unfinished front page

    + + +

    Further work

    + +

    Please see the issues tracker on google code. You can contribute new feature requests and bug reports.

    + +

    Julian's work: +

    parse 1992-1976 logbooks; (esp top 161)

    +

    detect T/U on log entries;

    +

    name matching and spelling in survex files;

    +

    Improve logbook wikihtml text

    + +

    Other work:

    +

    surf through the tunnel sketches and images

    +

    bugs with all.svx block (double dot) +

    render bitmap view of every survex block as a thumbnail

    +

    upload tunnel images and tunnel sketches

    +

    where are the subcaves;

    +

    cave section entrance match for logbook entries

    +

    simplify the survex parsing code (if necessary);

    +

    wiki survex stop linegap between comment lins

    +

    links between logbooks and survex blocks to cave things;

    +

    mini-tree of survexblocks;

    +

    connect sketches to caves to survey blocks and render thumbnailwise;

    +

    all images to start appearing in pages; and so on

    + +

    {{message}}

    + +
    + + +
    + +
      +{% for expedition in expeditions %} +
    • + {{expedition.name}} + - {{expedition.logbookentry_set.count}} logbook entries +
    • +{% endfor %} +
    + +{% endblock %} diff --git a/templates/tunnelfiles.html b/templates/tunnelfiles.html index 3d49e5d21..caa389579 100644 --- a/templates/tunnelfiles.html +++ b/templates/tunnelfiles.html @@ -1,43 +1,43 @@ -{% extends "base.html" %} -{% load wiki_markup %} -{% load survex_markup %} - -{% block title %}Tunnel files{% endblock %} - -{% block content %} - -

    All Tunnel files

    - - -{% for tunnelfile in tunnelfiles %} - - - - - - - - - - - - - - - -{% endfor %} -
    FileFontSurvexBlocksSizePathsScans folderScan filesFrames
    {{tunnelfile.tunnelpath}}{{tunnelfile.bfontcolours}}{{tunnelfile.filesize}}{{tunnelfile.npaths}} - {% for survexscansfolder in tunnelfile.survexscansfolders.all %} - {{survexscansfolder.walletname}} - {% endfor %} - - {% for survexscansingle in tunnelfile.survexscans.all %} - {{survexscansingle.name}} - {% endfor %} - - {% for rtunnelfile in tunnelfile.tunnelcontains.all %} - {{rtunnelfile.tunnelpath}} - {% endfor %} -
    - +{% extends "base.html" %} +{% load wiki_markup %} +{% load survex_markup %} + +{% block title %}Tunnel files{% endblock %} + +{% block content %} + +

    All Tunnel files

    + + +{% for tunnelfile in tunnelfiles %} + + + + + + + + + + + + + + + +{% endfor %} +
    FileFontSurvexBlocksSizePathsScans folderScan filesFrames
    {{tunnelfile.tunnelpath}}{{tunnelfile.bfontcolours}}{{tunnelfile.filesize}}{{tunnelfile.npaths}} + {% for survexscansfolder in tunnelfile.survexscansfolders.all %} + {{survexscansfolder.walletname}} + {% endfor %} + + {% for survexscansingle in tunnelfile.survexscans.all %} + {{survexscansingle.name}} + {% endfor %} + + {% for rtunnelfile in tunnelfile.tunnelcontains.all %} + {{rtunnelfile.tunnelpath}} + {% endfor %} +
    + {% endblock %} \ No newline at end of file From b6a1503c7a00a582fa08cb5cfb97490f8bfa07aa Mon Sep 17 00:00:00 2001 From: Wookey Date: Mon, 11 Jul 2011 23:19:48 +0100 Subject: [PATCH 4/4] Add changes from martin --- flatpages/views.py | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/flatpages/views.py b/flatpages/views.py index 5f7b57991..11cb45743 100644 --- a/flatpages/views.py +++ b/flatpages/views.py @@ -15,6 +15,7 @@ import os import re def flatpage(request, path): + print "gggggg", path try: r = Redirect.objects.get(originalURL = path) return HttpResponseRedirect(r.newURL) # Redirect after POST @@ -36,10 +37,22 @@ def flatpage(request, path): if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated(): return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path) - try: - o = open(os.path.normpath(settings.EXPOWEB + path), "rb") - except IOError: - raise Http404 + + if path.endswith("/") or path == "": + try: + o = open(os.path.normpath(settings.EXPOWEB + path + "index.html"), "rb") + path = path + "index.html" + except IOError: + try: + o = open(os.path.normpath(settings.EXPOWEB + path + "index.htm"), "rb") + path = path + "index.html" + except IOError: + raise Http404 + else: + try: + o = open(os.path.normpath(settings.EXPOWEB + path), "rb") + except IOError: + raise Http404 if path.endswith(".htm") or path.endswith(".html"): html = o.read() @@ -56,14 +69,29 @@ def flatpage(request, path): body = unicode(body, "iso-8859-1") return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'head': head, 'body': body, "bodyid": bodyid}) else: - return HttpResponse(o.read()) + return HttpResponse(o.read(), mimetype=getmimetype(path)) + +def getmimetype(path): + if path.endswith(".png"): return "image/png" + if path.endswith(".tif"): return "image/tif" + if path.endswith(".gif"): return "image/gif" + if path.endswith(".jpeg"): return "image/jpeg" + if path.endswith(".jpg"): return "image/jpeg" + if path.endswith("svg"): return "image/svg+xml" + if path.endswith(".pdf"): return "application/pdf" + if path.endswith(".ps"): return "application/postscript" + if path.endswith(".svx"): return "application/x-survex-svx" + if path.endswith(".3d"): return "application/x-survex-3d" + if path.endswith(".pos"): return "application/x-survex-pos" + if path.endswith(".err"): return "application/x-survex-err" + return "" @login_required_if_public def editflatpage(request, path): try: - r = CaveRedirect.objects.get(originalURL = path) + r = Cave.objects.get(url = path) return troggle.core.views_caves.editCave(request, r.cave.slug) - except CaveRedirect.DoesNotExist: + except Cave.DoesNotExist: pass