2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

[svn] Weeks of local changes.

- Import is now non-destructive
- Parsers write output to a log file (path be specified in settings)
- databaseReset.py content been divided into separate functions which can be called for varying levels of deletion and importing
- control panel (view, template, urlpattern) added for deleting and importing
- Logins and signup fixed
- CaveArea model updated, view, hierarchical url patterns, and beginning of template added
- New site style
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8324 by cucc @ 5/3/2009 5:56 AM
This commit is contained in:
substantialnoninfringinguser 2009-05-13 06:15:48 +01:00
parent 1a36856b40
commit 625b2156e3
25 changed files with 544 additions and 270 deletions

View File

@ -1,33 +1,58 @@
import os import os
import time
import settings import settings
os.environ['PYTHONPATH'] = settings.PYTHON_PATH os.environ['PYTHONPATH'] = settings.PYTHON_PATH
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from django.core import management from django.core import management
from django.db import connection from django.db import connection
cursor = connection.cursor()
cursor.execute("drop database %s" % settings.DATABASE_NAME)
cursor.execute("create database %s" % settings.DATABASE_NAME)
cursor.execute("ALTER DATABASE %s CHARACTER SET=utf8" % settings.DATABASE_NAME)
cursor.execute("USE %s" % settings.DATABASE_NAME)
management.call_command('syncdb')
from django.contrib.auth.models import User from django.contrib.auth.models import User
user = User.objects.create_user('m', 'm@m.com', 'm')
user.is_staff = True
user.is_superuser = True
user.save()
#Make directories that troggle requires def reload_db():
if not os.path.isdir(settings.PHOTOS_ROOT): cursor = connection.cursor()
os.mkdir(settings.PHOTOS_ROOT) cursor.execute("drop database %s" % settings.DATABASE_NAME)
cursor.execute("create database %s" % settings.DATABASE_NAME)
cursor.execute("ALTER DATABASE %s CHARACTER SET=utf8" % settings.DATABASE_NAME)
cursor.execute("USE %s" % settings.DATABASE_NAME)
management.call_command('syncdb')
user = User.objects.create_user('m', 'm@m.com', 'm')
user.is_staff = True
user.is_superuser = True
user.save()
import parsers.cavetab def make_dirs():
parsers.cavetab.LoadCaveTab() """Make directories that troggle requires"""
import parsers.people if not os.path.isdir(settings.PHOTOS_ROOT):
parsers.people.LoadPersonsExpos() os.mkdir(settings.PHOTOS_ROOT)
import parsers.logbooks
parsers.logbooks.LoadLogbooks() def import_cavetab():
import parsers.survex import parsers.cavetab
parsers.survex.LoadAllSurvexBlocks() parsers.cavetab.LoadCaveTab(logfile=settings.LOGFILE)
import parsers.QMs
import parsers.surveys def import_people():
import parsers.people
parsers.people.LoadPersonsExpos()
def import_logbooks():
settings.LOGFILE.write('\nBegun importing logbooks at ' + time.asctime() +'\n'+'-'*60)
import parsers.logbooks
parsers.logbooks.LoadLogbooks()
def import_survex():
import parsers.survex
parsers.survex.LoadAllSurvexBlocks()
def import_QMs():
import parsers.QMs
def import_surveys():
import parsers.surveys
def reset():
reload_db()
make_dirs()
import_cavetab()
import_people()
import_logbooks()
import_survex()
import_QMs()
import_surveys()

View File

@ -5,18 +5,24 @@ import django.forms as forms
from expo.forms import LogbookEntryForm from expo.forms import LogbookEntryForm
#from troggle.reversion.admin import VersionAdmin #django-reversion version control #from troggle.reversion.admin import VersionAdmin #django-reversion version control
#overriding admin save so we have the new since parsing field
class TroggleModelAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
obj.new_since_parsing=True
obj.save()
class RoleInline(admin.TabularInline): class RoleInline(admin.TabularInline):
model = PersonRole model = PersonRole
extra = 4 extra = 4
class SurvexBlockAdmin(admin.ModelAdmin): class SurvexBlockAdmin(TroggleModelAdmin):
inlines = (RoleInline,) inlines = (RoleInline,)
class ScannedImageInline(admin.TabularInline): class ScannedImageInline(admin.TabularInline):
model = ScannedImage model = ScannedImage
extra = 4 extra = 4
class SurveyAdmin(admin.ModelAdmin): class SurveyAdmin(TroggleModelAdmin):
inlines = (ScannedImageInline,) inlines = (ScannedImageInline,)
class QMInline(admin.TabularInline): class QMInline(admin.TabularInline):
@ -34,7 +40,7 @@ class PersonTripInline(admin.TabularInline):
extra = 1 extra = 1
#class LogbookEntryAdmin(VersionAdmin): #class LogbookEntryAdmin(VersionAdmin):
class LogbookEntryAdmin(admin.ModelAdmin): class LogbookEntryAdmin(TroggleModelAdmin):
prepopulated_fields = {'slug':("title",)} prepopulated_fields = {'slug':("title",)}
search_fields = ('title','expedition__year') search_fields = ('title','expedition__year')
inlines = (PersonTripInline, PhotoInline) inlines = (PersonTripInline, PhotoInline)
@ -47,20 +53,17 @@ class PersonExpeditionInline(admin.TabularInline):
class PersonAdmin(admin.ModelAdmin): class PersonAdmin(TroggleModelAdmin):
search_fields = ('first_name','last_name') search_fields = ('first_name','last_name')
inlines = (PersonExpeditionInline,) inlines = (PersonExpeditionInline,)
class QMAdmin(admin.ModelAdmin): class QMAdmin(TroggleModelAdmin):
search_fields = ('found_by__cave__kataster_number','number') search_fields = ('found_by__cave__kataster_number','number')
def save_model(self, request, obj, form, change):
obj.new_since_parsing=True
obj.save()
class PersonExpeditionAdmin(admin.ModelAdmin): class PersonExpeditionAdmin(TroggleModelAdmin):
search_fields = ('person__first_name','expedition__year') search_fields = ('person__first_name','expedition__year')
class CaveAdmin(admin.ModelAdmin): class CaveAdmin(TroggleModelAdmin):
search_fields = ('official_name','kataster_number','unofficial_number') search_fields = ('official_name','kataster_number','unofficial_number')
#inlines = (QMInline,) #inlines = (QMInline,)
extra = 4 extra = 4
@ -68,6 +71,7 @@ class CaveAdmin(admin.ModelAdmin):
admin.site.register(Photo) admin.site.register(Photo)
admin.site.register(Subcave)
admin.site.register(Cave, CaveAdmin) admin.site.register(Cave, CaveAdmin)
admin.site.register(Area) admin.site.register(Area)
admin.site.register(OtherCaveName) admin.site.register(OtherCaveName)

View File

@ -235,10 +235,10 @@ class LogbookEntry(TroggleModel):
return "%s: (%s)" % (self.date, self.title) return "%s: (%s)" % (self.date, self.title)
def get_next_by_id(self): def get_next_by_id(self):
Logbook.objects.get(id=self.id+1) LogbookEntry.objects.get(id=self.id+1)
def get_previous_by_id(self): def get_previous_by_id(self):
Logbook.objects.get(id=self.id-1) LogbookEntry.objects.get(id=self.id-1)
class PersonTrip(TroggleModel): class PersonTrip(TroggleModel):
person_expedition = models.ForeignKey(PersonExpedition,null=True) person_expedition = models.ForeignKey(PersonExpedition,null=True)
@ -448,13 +448,29 @@ class Entrance(TroggleModel):
if f[0] == self.findability: if f[0] == self.findability:
return f[1] return f[1]
class CaveArea(TroggleModel): class Subcave(TroggleModel):
description = models.TextField() description = models.TextField()
name = models.CharField(max_length=200, unique = True) name = models.CharField(max_length=200, )
cave = models.ForeignKey('Cave') cave = models.ForeignKey('Cave', blank=True, null=True, help_text="Only the top-level subcave should be linked to a cave")
parentArea = models.ForeignKey('CaveArea') parent= models.ForeignKey('Subcave', blank=True, null=True,)
survexFile = models.CharField(max_length=200) adjoining = models.ManyToManyField('Subcave',blank=True, null=True,)
survex_file = models.CharField(max_length=200, blank=True, null=True,)
def __unicode__(self):
return self.name
def get_absolute_url(self):
urlString=self.name
if self.parent:
parent=self.parent
while parent.parent:
urlString=parent.name+'/'+urlString
parent=parent.parent
urlString=unicode(parent.cave.kataster_number)+urlString
else:
urlString=unicode(self.cave.kataster_number)+urlString
return settings.URL_ROOT + urlString
class QM(TroggleModel): class QM(TroggleModel):
#based on qm.csv in trunk/expoweb/smkridge/204 which has the fields: #based on qm.csv in trunk/expoweb/smkridge/204 which has the fields:
@ -473,7 +489,7 @@ class QM(TroggleModel):
location_description = models.TextField(blank=True) location_description = models.TextField(blank=True)
#should be a foreignkey to surveystation #should be a foreignkey to surveystation
nearest_station_description = models.CharField(max_length=400,null=True,blank=True) nearest_station_description = models.CharField(max_length=400,null=True,blank=True)
nearest_station = models.OneToOneField(SurveyStation,null=True,blank=True) nearest_station = models.CharField(max_length=200,blank=True,null=True)
area = models.CharField(max_length=100,blank=True,null=True) area = models.CharField(max_length=100,blank=True,null=True)
completion_description = models.TextField(blank=True,null=True) completion_description = models.TextField(blank=True,null=True)
comment=models.TextField(blank=True,null=True) comment=models.TextField(blank=True,null=True)

View File

@ -7,6 +7,7 @@ from django.core.urlresolvers import reverse
from troggle.alwaysUseRequestContext import render_response # see views_logbooks for explanation on this. from troggle.alwaysUseRequestContext import render_response # see views_logbooks for explanation on this.
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.conf import settings from django.conf import settings
import re
def getCave(cave_id): 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.""" """Returns a cave object when given a cave name or number. It is used by views including cavehref, ent, and qm."""
@ -51,10 +52,17 @@ def survexblock(request, survexpath):
ftext = survexblock.text ftext = survexblock.text
return render_response(request,'survexblock.html', {'survexblock':survexblock, 'ftext':ftext, }) return render_response(request,'survexblock.html', {'survexblock':survexblock, 'ftext':ftext, })
def caveArea(request, name): def subcave(request, cave_id, subcave):
cavearea = models.CaveArea.objects.get(name = name) print subcave
cave = cavearea.cave subcaveSeq=re.findall('([a-zA-Z]*)(?:/)',subcave)
return render_response(request,'cavearea.html', {'cavearea': cavearea, 'cave': cave,}) print subcaveSeq
cave=models.Cave.objects.filter(kataster_number = cave_id)[0]
subcave=models.Subcave.objects.get(name=subcaveSeq[0], cave=cave)
if len(subcaveSeq)>1:
for singleSubcave in subcaveSeq[1:]:
subcave=subcave.subcave_set.get(name=singleSubcave)
print subcave
return render_response(request,'subcave.html', {'subcave': subcave,})
def caveSearch(request): def caveSearch(request):
query_string = '' query_string = ''

View File

@ -5,6 +5,8 @@ from django.db import models
from troggle.parsers.logbooks import LoadLogbookForExpedition from troggle.parsers.logbooks import LoadLogbookForExpedition
from troggle.parsers.people import GetPersonExpeditionNameLookup from troggle.parsers.people import GetPersonExpeditionNameLookup
from troggle.expo.forms import PersonForm from troggle.expo.forms import PersonForm
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
# 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. # 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 troggle.alwaysUseRequestContext import render_response from troggle.alwaysUseRequestContext import render_response
@ -52,8 +54,16 @@ def expedition(request, expeditionname):
def get_absolute_url(self): def get_absolute_url(self):
return ('expedition', (expedition.year)) return ('expedition', (expedition.year))
def person(request, first_name='', last_name=''): def person(request, first_name='', last_name='', ):
person = Person.objects.get(first_name = first_name, last_name = last_name) person = Person.objects.get(first_name = first_name, last_name = last_name)
#This is for removing the reference to the user's profile, in case they set it to the wrong person
if request.method == 'GET':
if request.GET.get('clear_profile')=='True':
person.user=None
person.save()
return HttpResponseRedirect(reverse('profiles_select_profile'))
return render_response(request,'person.html', {'person': person, }) return render_response(request,'person.html', {'person': person, })
def get_absolute_url(self): def get_absolute_url(self):
@ -74,11 +84,11 @@ def newQMlink(logbookentry):
if logbookentry.cave: if logbookentry.cave:
for log in logbookentry.cave.logbookentry_set.all(): for log in logbookentry.cave.logbookentry_set.all():
try: try:
biggestQMnumberInLog = logbookentry.QMs_found.order_by('-number')[0].number biggestQMnumberInLog = logbookentry.QMs_found.order_by('-number')[0].number
except IndexError: except IndexError:
biggestQMnumberInLog = 0 biggestQMnumberInLog = 0
if biggestQMnumberInLog > biggestQMnumber: if biggestQMnumberInLog > biggestQMnumber:
biggestQMnumber = biggestQMnumberInLog biggestQMnumber = biggestQMnumberInLog
else: else:
return None return None
@ -97,8 +107,8 @@ def logbookSearch(request, extra):
found_entries = None found_entries = None
if ('q' in request.GET) and request.GET['q'].strip(): if ('q' in request.GET) and request.GET['q'].strip():
query_string = request.GET['q'] query_string = request.GET['q']
entry_query = search.get_query(query_string, ['text','title',]) entry_query = search.get_query(query_string, ['text','title',])
found_entries = LogbookEntry.objects.filter(entry_query) found_entries = LogbookEntry.objects.filter(entry_query)
return render_response(request,'logbooksearch.html', return render_response(request,'logbooksearch.html',
{ 'query_string': query_string, 'found_entries': found_entries, }) { 'query_string': query_string, 'found_entries': found_entries, })

View File

@ -1,10 +1,9 @@
from troggle.expo.models import Cave, Expedition, Person, LogbookEntry, PersonExpedition from troggle.expo.models import Cave, Expedition, Person, LogbookEntry, PersonExpedition, PersonTrip, Photo
import troggle.settings as settings import troggle.settings as settings
from django import forms from django import forms
from django.db.models import Q from django.db.models import Q
from troggle.parsers.people import LoadPersonsExpos import databaseReset
import re import re
from troggle.parsers.survex import LoadAllSurvexBlocks
import randSent import randSent
from django.http import HttpResponse from django.http import HttpResponse
@ -27,7 +26,7 @@ def frontpage(request):
if "reloadexpos" in request.GET: if "reloadexpos" in request.GET:
message = LoadPersonsExpos() message = LoadPersonsExpos()
message = "Reloaded personexpos" message = "Reloaded personexpos"
if "reloadsurvex" in request.GET: if "reloadsurvex" in request.POST:
message = LoadAllSurvexBlocks() message = LoadAllSurvexBlocks()
message = "Reloaded survexblocks" message = "Reloaded survexblocks"
@ -39,7 +38,17 @@ def frontpage(request):
def calendar(request,year): def calendar(request,year):
week=['S','S','M','T','W','T','F'] week=['S','S','M','T','W','T','F']
if year: if year:
expedition=Expedition.objects.get(year=year) expedition=Expedition.objects.get(year=year)
PersonExpeditions=expedition.personexpedition_set.all() PersonExpeditions=expedition.personexpedition_set.all()
return render_response(request,'calendar.html', locals()) return render_response(request,'calendar.html', locals())
def controlPanel(request):
message = "no test message" #reverse('personn', kwargs={"name":"hkjhjh"})
if request.method=='POST':
for item in request.POST:
if request.user.is_superuser and item!='item':
print "running"+ " databaseReset."+item+"()"
exec "databaseReset."+item+"()"
return render_response(request,'controlPanel.html', )

View File

@ -7,10 +7,7 @@ dl, dt, dd, ol, ul, li,
fieldset, form, label, legend, fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td table, caption, tbody, tfoot, thead, tr, th, td
{ {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-weight: inherit; font-weight: inherit;
font-style: inherit; font-style: inherit;
font-size: 100%; font-size: 100%;
@ -32,37 +29,19 @@ ul
list-style: none; list-style: none;
} }
body
{
background-color: white;
color: black;
font: 100% Verdana, Arial, Helvetica, sans-serif;
margin: 0;
padding: 0;
margin-left: auto;
margin-right: auto;
}
div#content
{
border: thin black dotted;
margin: 50px;
}
div#footer div#footer
{ {
position: fixed;
bottom: 0;
clear:both; clear:both;
background-color:#999; background-color:#999;
color:white; color:red;
text-align:center; text-align:center;
margin-left:auto; margin-left:auto;
margin-right:auto; margin-right:auto;
} }
img#frontPageBanner{position:relative;width:inherit;height:inherit;}
div.logbookentry div.logbookentry
{ {
@ -144,13 +123,7 @@ p.indent
margin-left:10px; margin-left:10px;
} }
#expoHeader {
width:100%;
position:relative;
left:0;
right:0;
height:100px;
}
#currentLocation { #currentLocation {
float:right; float:right;
background:#999; background:#999;
@ -159,15 +132,6 @@ p.indent
margin: 0px; margin: 0px;
padding: 0px; padding: 0px;
} }
#expoHeaderText {
background:#999;
position:absolute;
bottom:0px;
clip:rect(10px auto auto auto)
/* filter:alpha(opacity=90);
-moz-opacity:.90;
opacity:.90; */
}
@ -181,18 +145,6 @@ hr{
background:#000; background:#000;
} }
div#expoHeader h1{
position:relative;
bottom:-8px;
vertical-align:top;
}
div#editLink { right:0px; top:0px; text-align: right; position: absolute; top:0; right:0; z-index:1; background:#999 }
div#expoFinalDate {
display: inline;
}
div.centre img { vertical-align: middle; } div.centre img { vertical-align: middle; }
h1 { text-align: center; font-size: 210%; display: inline;} h1 { text-align: center; font-size: 210%; display: inline;}
@ -240,30 +192,9 @@ table.bigfatborder { border-width: 6px; }
table.trad td, table.trad th { margin: 0pt; border: 1px solid #aaa; table.trad td, table.trad th { margin: 0pt; border: 1px solid #aaa;
border-color: #8d8d8d #c0c0c0 #c0c0c0 #8d8d8d; } border-color: #8d8d8d #c0c0c0 #c0c0c0 #8d8d8d; }
/*Divs for layout*/
html, body, div.contents {
min-height: 100%;
height: 100%;
width:100%;
}
html>body, html>body div.contents {
height: auto;
}
body {
}
div.contents {
position: absolute;
top: 0;
right: 0;
}
div.main {
margin-bottom: 3em;
}
/* You are not expected to understand this. It is necessary. */ /* You are not expected to understand this. It is necessary. */
/* The above is the most fucktarded comment I have ever read. AC, 24 APR 2009 */
table.centre { margin-left: auto; margin-right: auto; } table.centre { margin-left: auto; margin-right: auto; }
table.centre td { text-align: left; } table.centre td { text-align: left; }
@ -338,4 +269,92 @@ img.thumbnail {
} }
br.clearfloat { br.clearfloat {
clear:both; clear:both;
} }
#error {
color: red;
}
div#header {
position:fixed;
left:100px;
right:100px;
top:0;
margin-left:auto;
margin-right:auto;
height:50px;
background-image: url( ../204plan.gif);
border-bottom:thin solid #000;
font-family: Arial, Helvetica, sans-serif;
font-variant: normal;
}
div#editLinks {
position:absolute;
background: #999;
bottom:0px;
right:0px;
font-family: "Courier New", Courier, monospace;
filter:alpha(opacity=75);
-moz-opacity:.75;
opacity:.75;
}
div#content {
margin-top: 50px;
margin-left: 100px;
margin-right: 100px;
padding: 10px;
}
img#banner {
position:fixed;
width:100%;
bottom:0;
left:0;
}
body {
background-color:#CCC;
padding-bottom:100px;
}
h1 {
margin-top:0;
margin-left:10px;
vertical-align:top;
}
#rightMargin {
position:absolute;
z-index:-2;
width:100px;
right:0px;
top:0px;
clip: rect(auto,auto,auto,auto);
}
#leftMargin {
position:absolute;
z-index:-2;
width:100px;
top:0px;
left:0px;
clip: rect(auto,100px,auto,auto,);
}
#footerLinks{
position:fixed;
text-align: center;
bottom:0;
left:0;
width:100%;
background-color:#333
}

BIN
media/eieshole.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
media/expoBanner.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

BIN
media/goesser.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@ -1,28 +1,40 @@
# -*- coding: UTF-8 -*-
import csv import csv
import settings import settings
from expo.models import QM, LogbookEntry, Cave from expo.models import QM, LogbookEntry, Cave
from datetime import * from datetime import *
from helpers import save_carefully
import re import re
#sorry that the below code is ugly. I'll fix it sometime, really! - AC def deleteQMs():
QM.objects.all().delete()
QM.objects.all().delete() def parseCaveQMs(cave,inputFile):
"""Runs through the CSV file at inputFile (which is a relative path from expoweb) and saves each QM as a QM instance."""
def parseCaveQMs(cave,pathToCSV):
if cave=='stein': if cave=='stein':
try: try:
steinBr=Cave.objects.get(official_name="Steinbrückenhöhle") steinBr=Cave.objects.get(official_name="Steinbrückenhöhle")
except Cave.DoesNotExist: except Cave.DoesNotExist:
print "Steinbruckenhoehle is not in the database. Please run parsers.cavetab first." print "Steinbruckenhoehle is not in the database. Please run parsers.cavetab first."
return return
elif cave=='hauch': elif cave=='hauch':
try: try:
hauchHl=Cave.objects.get(official_name="Hauchhöhle") hauchHl=Cave.objects.get(official_name="Hauchhöhle")
except Cave.DoesNotExist: except Cave.DoesNotExist:
print "Steinbruckenhoehle is not in the database. Please run parsers.cavetab first." print "Steinbruckenhoehle is not in the database. Please run parsers.cavetab first."
return return
elif cave =='kh':
qmPath = settings.EXPOWEB+pathToCSV try:
kh=Cave.objects.get(official_name="Kaninchenhöhle")
except Cave.DoesNotExist:
print "Steinbruckenhoehle is not in the database. Please run parsers.cavetab first."
for file in inputFile:
parse_KH_QMs(kh, inputFile=file)
return
qmPath = settings.EXPOWEB+inputFile
qmCSVContents = open(qmPath,'r') qmCSVContents = open(qmPath,'r')
dialect=csv.Sniffer().sniff(qmCSVContents.read()) dialect=csv.Sniffer().sniff(qmCSVContents.read())
qmCSVContents.seek(0,0) qmCSVContents.seek(0,0)
@ -55,13 +67,54 @@ def parseCaveQMs(cave,pathToCSV):
newQM.ticked_off_by=placeholder newQM.ticked_off_by=placeholder
newQM.comment=line[6] newQM.comment=line[6]
newQM.save() try:
print "QM "+str(newQM) + ' added to database\r', preexistingQM=QM.objects.get(number=QMnum, found_by__date__year=year) #if we don't have this one in the DB, save it
except KeyError: if preexistingQM.new_since_parsing==False: #if the pre-existing QM has not been modified, overwrite it
preexistingQM.delete()
newQM.save()
print "overwriting " + str(preexistingQM) +"\r",
else: # otherwise, print that it was ignored
print "preserving "+ str(preexistingQM) + ", which was edited in admin \r",
except QM.DoesNotExist: #if there is no pre-existing QM, save the new one
newQM.save()
print "QM "+str(newQM) + ' added to database\r',
except KeyError: #check on this one
continue continue
# except IndexError: # except IndexError:
# print "Index error in " + str(line) # print "Index error in " + str(line)
# continue # continue
parseCaveQMs(cave='stein',pathToCSV=r"smkridge/204/qm.csv") def parse_KH_QMs(kh, inputFile):
parseCaveQMs(cave='hauch',pathToCSV=r"smkridge/234/qm.csv") """import QMs from the 1623-161 (Kaninchenhöhle) html pages
"""
khQMs=open(settings.EXPOWEB+inputFile,'r')
khQMs=khQMs.readlines()
for line in khQMs:
res=re.search('name=\"[CB](?P<year>\d*)-(?P<cave>\d*)-(?P<number>\d*).*</a> (?P<grade>[ABDCV])<dd>(?P<description>.*)\[(?P<nearest_station>.*)\]',line)
if res:
res=res.groupdict()
year=int(res['year'])
#check if placeholder exists for given year, create it if not
placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=year, title="placeholder for QMs in 161", text="QMs temporarily attached to this should be re-attached to their actual trips", defaults={"date": date((year), 1, 1),"cave":kh})
lookupArgs={
'found_by':placeholder,
'number':res['number']
}
nonLookupArgs={
'grade':res['grade'],
'nearest_station':res['nearest_station'],
'location_description':res['description']
}
if
save_carefully(QM,lookupArgs,nonLookupArgs)
parseCaveQMs(cave='kh', inputFile=r"smkridge/161/qmtodo.htm")
parseCaveQMs(cave='stein',inputFile=r"smkridge/204/qm.csv")
parseCaveQMs(cave='hauch',inputFile=r"smkridge/234/qm.csv")

View File

@ -9,6 +9,8 @@ import time
import re import re
import os import os
from troggle.helpers import save_carefully
##format of CAVETAB2.CSV is ##format of CAVETAB2.CSV is
KatasterNumber = 0 KatasterNumber = 0
KatStatusCode = 1 KatStatusCode = 1
@ -136,15 +138,20 @@ def html_to_wiki(text):
text2 = "" text2 = ""
return out return out
def LoadCaveTab(): def LoadCaveTab(logfile=None):
cavetab = open(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV")) cavetab = open(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV"))
caveReader = csv.reader(cavetab) caveReader = csv.reader(cavetab)
caveReader.next() # Strip out column headers caveReader.next() # Strip out column headers
if logfile:
logfile.write("Beginning to import caves from "+str(cavetab)+"\n"+"-"*60+"\n")
for katArea in ['1623', '1626']: for katArea in ['1623', '1626']:
if not models.Area.objects.filter(short_name = katArea): if not models.Area.objects.filter(short_name = katArea):
newArea = models.Area(short_name = katArea) newArea = models.Area(short_name = katArea)
newArea.save() newArea.save()
if logfile:
logfile.write("Added area "+str(newArea.short_name)+"\n")
area1626 = models.Area.objects.filter(short_name = '1626')[0] area1626 = models.Area.objects.filter(short_name = '1626')[0]
area1623 = models.Area.objects.filter(short_name = '1623')[0] area1623 = models.Area.objects.filter(short_name = '1623')[0]
@ -153,33 +160,43 @@ def LoadCaveTab():
if line[Area] == 'nonexistent': if line[Area] == 'nonexistent':
continue continue
entranceLetters=[] #Used in caves that have mulitlple entrances, which are not described on seperate lines entranceLetters=[] #Used in caves that have mulitlple entrances, which are not described on seperate lines
if line[MultipleEntrances] == 'yes' or line[MultipleEntrances]=='': if line[MultipleEntrances] == 'yes' or line[MultipleEntrances]=='': #When true, this line contains an actual cave, otherwise it is an extra entrance.
args = {} args = {}
defaultArgs = {}
def addToArgs(CSVname, modelName): def addToArgs(CSVname, modelName):
if line[CSVname]: if line[CSVname]:
args[modelName] = html_to_wiki(line[CSVname]) args[modelName] = html_to_wiki(line[CSVname])
def addToDefaultArgs(CSVname, modelName): #This has to do with the non-destructive import. These arguments will be passed as the "default" dictionary in a get_or_create
if line[CSVname]:
defaultArgs[modelName] = html_to_wiki(line[CSVname])
# The attributes added using "addToArgs" will be used to look up an existing cave. Those added using "addToDefaultArgs" will not.
addToArgs(KatasterNumber, "kataster_number") addToArgs(KatasterNumber, "kataster_number")
addToArgs(KatStatusCode, "kataster_code") addToDefaultArgs(KatStatusCode, "kataster_code")
addToArgs(UnofficialNumber, "unofficial_number") addToArgs(UnofficialNumber, "unofficial_number")
addToArgs(Name, "official_name") addToArgs(Name, "official_name")
addToArgs(Comment, "notes") addToDefaultArgs(Comment, "notes")
addToArgs(Explorers, "explorers") addToDefaultArgs(Explorers, "explorers")
addToArgs(UndergroundDescription, "underground_description") addToDefaultArgs(UndergroundDescription, "underground_description")
addToArgs(Equipment, "equipment") addToDefaultArgs(Equipment, "equipment")
addToArgs(KatasterStatus, "kataster_status") addToDefaultArgs(KatasterStatus, "kataster_status")
addToArgs(References, "references") addToDefaultArgs(References, "references")
addToArgs(UndergroundCentreLine, "underground_centre_line") addToDefaultArgs(UndergroundCentreLine, "underground_centre_line")
addToArgs(UndergroundDrawnSurvey, "survey") addToDefaultArgs(UndergroundDrawnSurvey, "survey")
addToArgs(Length, "length") addToDefaultArgs(Length, "length")
addToArgs(Depth, "depth") addToDefaultArgs(Depth, "depth")
addToArgs(Extent, "extent") addToDefaultArgs(Extent, "extent")
addToArgs(SurvexFile, "survex_file") addToDefaultArgs(SurvexFile, "survex_file")
addToArgs(Notes, "notes") addToDefaultArgs(Notes, "notes")
newCave = models.Cave(**args) newCave, created=save_carefully(models.Cave, lookupAttribs=args, nonLookupAttribs=defaultArgs)
newCave.save() if logfile:
logfile.write("Added cave "+str(newCave)+"\n")
if line[Area]:
#If we created a new cave, add the area to it. This does mean that if a cave's identifying features have not changed, areas will not be updated from csv.
if created and line[Area]:
if line[Area] == "1626": if line[Area] == "1626":
newCave.area.add(area1626) newCave.area.add(area1626)
else: else:
@ -190,16 +207,20 @@ def LoadCaveTab():
newArea = models.Area(short_name = line[Area], parent = area1623) newArea = models.Area(short_name = line[Area], parent = area1623)
newArea.save() newArea.save()
newCave.area.add(newArea) newCave.area.add(newArea)
else: elif created:
newCave.area.add(area1623) newCave.area.add(area1623)
newCave.save()
if line[UnofficialName]: newCave.save()
newUnofficialName = models.OtherCaveName(cave = newCave, name = line[UnofficialName]) if logfile:
newUnofficialName.save() logfile.write("Added area "+line[Area]+" to cave "+str(newCave)+"\n")
if line[MultipleEntrances] == '' or \ if created and line[UnofficialName]:
newUnofficialName = models.OtherCaveName(cave = newCave, name = line[UnofficialName])
newUnofficialName.save()
if logfile:
logfile.write("Added unofficial name "+str(newUnofficialName)+" to cave "+str(newCave)+"\n")
if created and line[MultipleEntrances] == '' or \
line[MultipleEntrances] == 'entrance' or \ line[MultipleEntrances] == 'entrance' or \
line[MultipleEntrances] == 'last entrance': line[MultipleEntrances] == 'last entrance':
args = {} args = {}
@ -258,6 +279,8 @@ def LoadCaveTab():
addToArgs(Bearings, 'bearings') addToArgs(Bearings, 'bearings')
newEntrance = models.Entrance(**args) newEntrance = models.Entrance(**args)
newEntrance.save() newEntrance.save()
if logfile:
logfile.write("Added entrance "+str(newEntrance)+"\n")
if line[Entrances]: if line[Entrances]:
entrance_letter = line[Entrances] entrance_letter = line[Entrances]
@ -266,6 +289,8 @@ def LoadCaveTab():
newCaveAndEntrance = models.CaveAndEntrance(cave = newCave, entrance = newEntrance, entrance_letter = entrance_letter) newCaveAndEntrance = models.CaveAndEntrance(cave = newCave, entrance = newEntrance, entrance_letter = entrance_letter)
newCaveAndEntrance.save() newCaveAndEntrance.save()
if logfile:
logfile.write("Added CaveAndEntrance "+str(newCaveAndEntrance)+"\n")
# lookup function modelled on GetPersonExpeditionNameLookup # lookup function modelled on GetPersonExpeditionNameLookup

View File

@ -13,6 +13,7 @@ import re
import datetime import datetime
import os import os
from troggle.helpers import save_carefully
# #
# When we edit logbook entries, allow a "?" after any piece of data to say we've frigged it and # When we edit logbook entries, allow a "?" after any piece of data to say we've frigged it and
@ -72,21 +73,23 @@ def GetTripCave(place): #need to be fuzzier about matching h
noncaveplaces = [ "Journey", "Loser Plateau" ] noncaveplaces = [ "Journey", "Loser Plateau" ]
def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_underground): def EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_underground):
""" saves a logbook entry and related persontrips """
trippersons, author = GetTripPersons(trippeople, expedition, logtime_underground) trippersons, author = GetTripPersons(trippeople, expedition, logtime_underground)
# tripCave = GetTripCave(place) # tripCave = GetTripCave(place)
#
lbo = models.LogbookEntry(date=date, place=place, title=title[:50], text=text, author=author, expedition=expedition)
lplace = place.lower() lplace = place.lower()
if lplace not in noncaveplaces: if lplace not in noncaveplaces:
lbo.cave=GetCaveLookup().get(lplace) cave=GetCaveLookup().get(lplace)
#print "pppp %s |%s|" % (lplace, str(lbo.cave))
#Check for an existing copy of the current entry, and save
lbo.save() lookupAttribs={'date':date, 'title':title[:50]}
#print "ttt", date, place nonLookupAttribs={'place':place, 'text':text, 'author':author, 'expedition':expedition, 'cave':cave}
lbo, created=save_carefully(models.LogbookEntry, lookupAttribs, nonLookupAttribs)
for tripperson, time_underground in trippersons: for tripperson, time_underground in trippersons:
pto = models.PersonTrip(person_expedition = tripperson, place=place, date=date, time_underground=time_underground, lookupAttribs={'person_expedition':tripperson, 'date':date}
logbook_entry=lbo, is_logbook_entry_author=(tripperson == author)) nonLookupAttribs={'place':place,'time_underground':time_underground,'logbook_entry':lbo,'is_logbook_entry_author':(tripperson == author)}
pto.save() save_carefully(models.PersonTrip, lookupAttribs, nonLookupAttribs)
def ParseDate(tripdate, year): def ParseDate(tripdate, year):
@ -235,7 +238,7 @@ def Parseloghtml03(year, expedition, txt):
yearlinks = [ yearlinks = [
("2008", "2008/2008logbook.txt", Parselogwikitxt), ("2008", "2008/2008logbook.txt", Parselogwikitxt),
("2007", "2007/2007logbook.txt", Parselogwikitxt), #("2007", "2007/2007logbook.txt", Parselogwikitxt),
("2006", "2006/logbook/logbook_06.txt", Parselogwikitxt), ("2006", "2006/logbook/logbook_06.txt", Parselogwikitxt),
("2005", "2005/logbook.html", Parseloghtmltxt), ("2005", "2005/logbook.html", Parseloghtmltxt),
("2004", "2004/logbook.html", Parseloghtmltxt), ("2004", "2004/logbook.html", Parseloghtmltxt),
@ -299,15 +302,17 @@ def SetDatesFromLogbookEntries(expedition):
# logbookentry.href = "%s" % logbookentry.date # logbookentry.href = "%s" % logbookentry.date
# logbookentry.save() # logbookentry.save()
# lprevlogbookentry = logbookentry # lprevlogbookentry = logbookentry
for logbookentry in expedition.logbookentry_set.all():
logbookentry.slug = slugify(logbookentry.title)
logbookentry.save()
def LoadLogbookForExpedition(expedition): def LoadLogbookForExpedition(expedition):
print "deleting logbooks for", expedition """ Parses all logbook entries for one expedition """
expedition.logbookentry_set.all().delete()
models.PersonTrip.objects.filter(person_expedition__expedition=expedition).delete() #We're checking for stuff that's changed in admin before deleting it now.
#print "deleting logbooks for", expedition
#expedition.logbookentry_set.all().delete()
#models.PersonTrip.objects.filter(person_expedition__expedition=expedition).delete()
expowebbase = os.path.join(settings.EXPOWEB, "years") expowebbase = os.path.join(settings.EXPOWEB, "years")
year = str(expedition.year) year = str(expedition.year)
for lyear, lloc, parsefunc in yearlinks: for lyear, lloc, parsefunc in yearlinks:
@ -322,7 +327,10 @@ def LoadLogbookForExpedition(expedition):
def LoadLogbooks(): def LoadLogbooks():
models.LogbookEntry.objects.all().delete() """ This is the master function for parsing all logbooks into the Troggle database. Requires yearlinks, which is a list of tuples for each expedition with expedition year, logbook path, and parsing function. """
#Deletion has been moved to a seperate function to enable the non-destructive importing
#models.LogbookEntry.objects.all().delete()
expowebbase = os.path.join(settings.EXPOWEB, "years") expowebbase = os.path.join(settings.EXPOWEB, "years")
#yearlinks = [ ("2001", "2001/log.htm", Parseloghtml01), ] #overwrite #yearlinks = [ ("2001", "2001/log.htm", Parseloghtml01), ] #overwrite
#yearlinks = [ ("1996", "1996/log.htm", Parseloghtml01),] # overwrite #yearlinks = [ ("1996", "1996/log.htm", Parseloghtml01),] # overwrite

View File

@ -7,6 +7,7 @@ import re
import datetime import datetime
import os import os
import shutil import shutil
from helpers import save_carefully
# Julian: the below code was causing errors and it seems like a duplication of the above. Hope I haven't broken anything by commenting it. -Aaron # Julian: the below code was causing errors and it seems like a duplication of the above. Hope I haven't broken anything by commenting it. -Aaron
# #
@ -72,47 +73,45 @@ def LoadPersonsExpos():
print "Loading personexpeditions" print "Loading personexpeditions"
models.Person.objects.all().delete() models.Person.objects.all().delete()
models.PersonExpedition.objects.all().delete() models.PersonExpedition.objects.all().delete()
expoers2008 = """Edvin Deadman,Kathryn Hopkins,Djuke Veldhuis,Becka Lawson,Julian Todd,Natalie Uomini,Aaron Curtis,Tony Rooke,Ollie Stevens,Frank Tully,Martin Jahnke,Mark Shinwell,Jess Stirrups,Nial Peters,Serena Povia,Olly Madge,Steve Jones,Pete Harley,Eeva Makiranta,Keith Curtis""".split(",") #expoers2008 = """Edvin Deadman,Kathryn Hopkins,Djuke Veldhuis,Becka Lawson,Julian Todd,Natalie Uomini,Aaron Curtis,Tony Rooke,Ollie Stevens,Frank Tully,Martin Jahnke,Mark Shinwell,Jess Stirrups,Nial Peters,Serena Povia,Olly Madge,Steve Jones,Pete Harley,Eeva Makiranta,Keith Curtis""".split(",")
expomissing = set(expoers2008) #expomissing = set(expoers2008)
for personline in personreader: for personline in personreader:
name = personline[header["Name"]] name = personline[header["Name"]]
name = re.sub("<.*?>", "", name) name = re.sub("<.*?>", "", name)
mname = re.match("(\w+)(?:\s((?:van |ten )?\w+))?(?:\s\(([^)]*)\))?", name) mname = re.match("(\w+)(?:\s((?:van |ten )?\w+))?(?:\s\(([^)]*)\))?", name)
nickname = mname.group(3) or "" nickname = mname.group(3) or ""
person = models.Person(first_name=mname.group(1), last_name=(mname.group(2) or "")) lookupAttribs={'first_name':mname.group(1), 'last_name':(mname.group(2) or "")}
person.is_vfho = personline[header["VfHO member"]] nonLookupAttribs={'is_vfho':personline[header["VfHO member"]],}
#person.Sethref() person, created = save_carefully(models.Person, lookupAttribs=lookupAttribs, nonLookupAttribs=nonLookupAttribs)
#print "NNNN", person.href
is_guest = (personline[header["Guest"]] == "1") # this is really a per-expo catagory; not a permanent state
person.save()
parseMugShotAndBlurb(personline=personline, header=header, person=person) parseMugShotAndBlurb(personline=personline, header=header, person=person)
# make person expedition from table # make person expedition from table
for year, attended in zip(headers, personline)[5:]: for year, attended in zip(headers, personline)[5:]:
expedition = models.Expedition.objects.get(year=year) expedition = models.Expedition.objects.get(year=year)
if attended == "1" or attended == "-1": if attended == "1" or attended == "-1":
personexpedition = models.PersonExpedition(person=person, expedition=expedition, nickname=nickname, is_guest=is_guest) personexpedition = models.PersonExpedition(person=person, expedition=expedition, nickname=nickname, is_guest=(personline[header["Guest"]] == "1"))
personexpedition.save() personexpedition.save()
# this fills in those people for whom 2008 was their first expo # this fills in those people for whom 2008 was their first expo
print "Loading personexpeditions 2008" #print "Loading personexpeditions 2008"
for name in expomissing: #for name in expomissing:
firstname, lastname = name.split() # firstname, lastname = name.split()
is_guest = name in ["Eeva Makiranta", "Keith Curtis"] # is_guest = name in ["Eeva Makiranta", "Keith Curtis"]
print "2008:", name # print "2008:", name
persons = list(models.Person.objects.filter(first_name=firstname, last_name=lastname)) # persons = list(models.Person.objects.filter(first_name=firstname, last_name=lastname))
if not persons: # if not persons:
person = models.Person(first_name=firstname, last_name = lastname, is_vfho = False, mug_shot = "") # person = models.Person(first_name=firstname, last_name = lastname, is_vfho = False, mug_shot = "")
#person.Sethref() # #person.Sethref()
person.save() # person.save()
else: # else:
person = persons[0] # person = persons[0]
expedition = models.Expedition.objects.get(year="2008") # expedition = models.Expedition.objects.get(year="2008")
personexpedition = models.PersonExpedition(person=person, expedition=expedition, nickname="", is_guest=is_guest) # personexpedition = models.PersonExpedition(person=person, expedition=expedition, nickname="", is_guest=is_guest)
personexpedition.save() # personexpedition.save()
#Notability is now a method of person. Makes no sense to store it in the database; it would need to be recalculated every time something changes. - AC 16 Feb 09 #Notability is now a method of person. Makes no sense to store it in the database; it would need to be recalculated every time something changes. - AC 16 Feb 09
# could rank according to surveying as well # could rank according to surveying as well

View File

@ -121,14 +121,14 @@ class RegistrationManager(models.Manager):
current_site = Site.objects.get_current() current_site = Site.objects.get_current()
subject = render_to_string('registration/activation_email_subject.txt', subject = render_to_string('registration/activation_email_subject.txt',
{ 'site': current_site }) { 'site': settings.URL_ROOT })
# Email subject *must not* contain newlines # Email subject *must not* contain newlines
subject = ''.join(subject.splitlines()) subject = ''.join(subject.splitlines())
message = render_to_string('registration/activation_email.txt', message = render_to_string('registration/activation_email.txt',
{ 'activation_key': registration_profile.activation_key, { 'activation_key': registration_profile.activation_key,
'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS, 'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS,
'site': current_site }) 'site': settings.URL_ROOT })
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [new_user.email]) send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [new_user.email])
user_registered.send(sender=self.model, user=new_user) user_registered.send(sender=self.model, user=new_user)

10
save_carefully.py Normal file
View File

@ -0,0 +1,10 @@
def save(objectType, lookupAttribs={}, nonLookupAttribs={}):
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()
return instance

View File

@ -35,7 +35,7 @@ USE_I18N = True
# Examples: "http://foo.com/media/", "/media/". # Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/troggle/media-admin/' ADMIN_MEDIA_PREFIX = '/troggle/media-admin/'
PHOTOS_ROOT = os.path.join(EXPOWEB, 'photos') PHOTOS_ROOT = os.path.join(EXPOWEB, 'photos')
#MEDIA_URL = urlparse.urljoin(URL_ROOT , '/site_media/') MEDIA_URL = urlparse.urljoin(URL_ROOT , '/site_media/')
SURVEYS_URL = urlparse.urljoin(URL_ROOT , '/survey_scans/') SURVEYS_URL = urlparse.urljoin(URL_ROOT , '/survey_scans/')
PHOTOS_URL = urlparse.urljoin(URL_ROOT , '/photos/') PHOTOS_URL = urlparse.urljoin(URL_ROOT , '/photos/')
SVX_URL = urlparse.urljoin(URL_ROOT , '/survex/') SVX_URL = urlparse.urljoin(URL_ROOT , '/survex/')
@ -80,6 +80,7 @@ INSTALLED_APPS = (
'django.contrib.redirects', 'django.contrib.redirects',
#'photologue', #'photologue',
#'troggle.reversion', #'troggle.reversion',
'django_evolution',
'troggle.registration', 'troggle.registration',
'troggle.profiles', 'troggle.profiles',
'troggle.expo' 'troggle.expo'

View File

@ -5,28 +5,35 @@
<link rel="stylesheet" type="text/css" href="{{ settings.MEDIA_URL }}css/main3.css" /> <link rel="stylesheet" type="text/css" href="{{ settings.MEDIA_URL }}css/main3.css" />
<title>{% block title %}THE TITLE{% endblock %}</title> <title>{% block title %}THE TITLE{% endblock %}</title>
<script src="{{ settings.MEDIA_URL }}js/base.js" type="text/javascript"></script> <script src="{{ settings.MEDIA_URL }}js/base.js" type="text/javascript"></script>
<script src="{{ settings.MEDIA_URL }}js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$("#killEyeCandy").click(function () {
$("#leftMargin").fadeIn("slow");
});
</script>
{% block head %}{% endblock %} {% block head %}{% endblock %}
</head> </head>
<body> <body>
<div class="wrapper">
<div id="expoHeader"> <img id="frontPageBanner" src="{{ settings.MEDIA_URL }}loserBanner.jpg"/> <div id="header">
<div id="expoHeaderText"> <h1>CUCC Expeditions to Austria: 1976 - 2009</h1>
<h1>CUCC Expeditions to Austria: 1976 - </h1> <div id="editLinks"> {% block loginInfo %}
<div id="expoFinalDate">
<h1>2009</h1>
</div>
</div>
</div>
<hr/>
<div id="editLink"> {% block loginInfo %}
{% if user.username %} {% if user.username %}
You are logged in as {{ user.username }}. You are logged in as {{ user.username }} {% if user.person %}<a href="{{ user.person.get_absolute_url }}">{{ user.person }}</a>{% endif %}.
| <a href="{{ settings.URL_ROOT }}/accounts/logout/">Log out</a> {% else %} <a href="{{ settings.URL_ROOT }}/accounts/register">Sign up</a> | <a href="{{ settings.URL_ROOT }}/accounts/login/">Log in</a> {% endif %} | <a href="{{ settings.URL_ROOT }}/accounts/logout/">Log out</a> {% else %} <a href="{{ settings.URL_ROOT }}/accounts/register">Sign up</a> | <a href="{{ settings.URL_ROOT }}/accounts/login/">Log in</a> {% endif %}
{% endblock%} {% endblock%}
| <a href="{{ settings.URL_ROOT }}">Home </a> | | <a href="{{ settings.URL_ROOT }}">Home </a> | <a href="#" id="killEyeCandy">Kill Eyecandy</a> |
{% block editLink %} {% block editLink %}
{% endblock %} </div> {% endblock %}
</div>
</div>
{% block nav %} {% block nav %}
<!-- Use id="nav" for the left side menu --> <!-- Use id="nav" for the left side menu -->
{% endblock %} {% endblock %}
@ -39,7 +46,16 @@
</div> </div>
</div> </div>
<div class="push"></div> <div class="push"></div>
</div> <div class="footer">
<div id="footer"> {% block footer %} <a href="http://cucc.survex.com"> CUCC website</a>| <a href="http://cucc.survex.com/expo"> Expedition website </a>| <a href="{% url frontpage %}"> Troggle front page </a>| <a href="{% url caveindex %}"> All caves </a>| <a href="{% url personindex %}"> All cavers </a>| <a href="{% url caveindex %}"> Virtual survey binder </a>| <a href="{% url survey %}"> Expedition statistics </a>| <a href="{% url calendar 2007 %}"> Expedition calendar </a> {% endblock %} </div> <img id="banner" src="{{ settings.MEDIA_URL }}expoBanner.gif"/>
</div>
<img id="leftMargin" src="{{ settings.MEDIA_URL }}eieshole.jpg">
<img id="rightMargin" src="{{ settings.MEDIA_URL }}goesser.jpg">
<div class="footer" id="footerLinks">
<a href="http://cucc.survex.com"> CUCC website</a>| <a href="http://cucc.survex.com/expo"> Expedition website </a>| <a href="{% url frontpage %}"> Troggle front page </a>| <a href="{% url caveindex %}"> All caves </a>| <a href="{% url personindex %}"> All cavers </a>| <a href="{% url caveindex %}"> Virtual survey binder </a>| <a href="{% url survey %}"> Expedition statistics </a>| <a href="{% url calendar 2007 %}"> Expedition calendar </a>
</div>
</body> </body>
</html> </html>

View File

@ -1,9 +0,0 @@
{% extends "cavebase.html" %}
{% load wiki_markup %}
{% block content %}
{{ cavearea.description|wiki_to_html_short }}
{{ cavearea.name|wiki_to_html_short }}
{{ cavearea.parentArea|wiki_to_html_short }}
{{ cavearea.survexFile|wiki_to_html_short }}
{% endblock %}

View File

@ -0,0 +1,37 @@
{% extends "base.html" %}
{% block content %}
<form name="form1" method="post" action="">
<h3>Dump:</h3>
<table>
<tr><td>Dump entire database and recreate tables: </td><td><input type="checkbox" name="dump_db" /></td></tr>
</table>
<h3>Import (non-destructive):</h3>
<table>
<tr><td>caves from cavetab2.csv using parsers\cavetab.py</td><td> <input type="checkbox" class="parser" name="import_cavetab"/></td></tr>
<tr><td>logbook entries using parsers\logbooks.py</td><td><input type="checkbox" name="import_logbooks"/></td></tr>
<tr><td>people from folk.csv using parsers\people.py</td><td><input type="checkbox" name="import_folk"/></td></tr>
<tr><td>QMs using parsers\QMs.py</td><td><input type="checkbox" name="QMs" value="import_QMs" /></td></tr>
<tr><td>survey scans using parsers\surveys.py</td><td><input type="checkbox" name="import_surveys" /></td></tr>
<tr><td>survex data using parsers\survex.py</td><td><input type="checkbox" name="survex" value="import_survex" /></td></tr>
</table>
<p>
<input type="submit" id="Import" value="Import">
<input type="submit" name="check_all_import" id="check_all_import" value="Check all">
</p>
</form>
<h3>Export to csv:</h3>
<table>
<tr>
<td>caves to cavetab2.csv</td><td> <input name="export_cavetab" type="submit" id="export_cavetab" value="Export" disabled /></td></tr>
</label>
</table>
{% endblock %}

View File

@ -2,10 +2,37 @@
{% block content %} {% block content %}
<h2>Troggle profile selection page</h2>
Hello, {{ user }}.
<br /><br />
{% if user.person %}
This is where you go to associate a new user account with a pre-existing profile from old expo data.
<br /><br />
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: <br /><br /> <a href= {{ user.person.get_absolute_url }}> {{ user.person.get_absolute_url }} </a> <br /><br /> or edit it at:
<br /><br /> <a href= {{ user.person.get_admin_url }}> {{ user.person.get_admin_url }} </a>.<br /><br />
If your account is associated with the wrong person's profile due to inebriation or incompetance during account setup, click <a href="{{ user.person.get_absolute_url }}/?clear_profile=True">here</a> 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.
<br /><br />
<form method="post"> <form method="post">
{{ form.as_p }} {{ form.as_p }}
<input type="submit" /> <input name="" type="submit" value="This is me!" />
</form> </form>
<br />
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 %} {% if form.errors %}
<p class="errornote">Please correct the errors below</p> <p class="errornote">Please correct the errors below</p>

View File

@ -1,13 +1,20 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %} {% block title %}
registration_form.html | {{ block.super }} New troggle account registered
{% endblock %} {% endblock %}
{% block header %} {% block header %}
<h1>activate.html</h1> <h1>activate.html</h1>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
You are now activated.
<p>
Hello, {{user}}! Your account is now activated. You've also been logged in automatically for your convenience. 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>.
</p>
{% endblock %} {% endblock %}

View File

@ -1,3 +1,10 @@
Activate your account in {{ expiration_days }} days... Hello,
{{ URL_ROOT }}{% url registration_activate activation_key %}
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 }}, or else you'll have to sign up again.
Yours,
The magical troggle

View File

@ -9,5 +9,5 @@ registration_complete.html | {{ block.super }}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
Thank you for signing up, {{ user.username }}. An email with the activation code has been sent to your inbox. 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>. Thank you for signing up. An email with the activation code has been sent to your inbox.
{% endblock %} {% endblock %}

View File

@ -27,7 +27,7 @@ urlpatterns = patterns('',
url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"), url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"),
url(r'^cave/(?P<cave_id>[^/]+)/?$', views_caves.cave, name="cave"), url(r'^cave/(?P<cave_id>[^/]+)/?$', views_caves.cave, name="cave"),
#url(r'^cavehref/(.+)$', views_caves.cave, name="cave"), #url(r'^cavehref/(.+)$', views_caves.cave, name="cave"),url(r'cave'),
url(r'^jgtfile/(.*)$', view_surveys.jgtfile, name="jgtfile"), url(r'^jgtfile/(.*)$', view_surveys.jgtfile, name="jgtfile"),
url(r'^jgtuploadfile$', view_surveys.jgtuploadfile, name="jgtuploadfile"), url(r'^jgtuploadfile$', view_surveys.jgtuploadfile, name="jgtuploadfile"),
@ -39,7 +39,7 @@ urlpatterns = patterns('',
url(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent), url(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent),
#(r'^cave/(?P<cave_id>[^/]+)/edit/$', edit_cave), #(r'^cave/(?P<cave_id>[^/]+)/edit/$', edit_cave),
#(r'^cavesearch', caveSearch), #(r'^cavesearch', caveSearch),
url(r'^cavearea', caveArea, name="caveArea"), url(r'^cave/(?P<cave_id>[^/]+)/(?P<subcave>[a-zA-Z/]+)/?$', subcave, name="subcave"),
url(r'^survex/(.*?)\.index$', views_survex.index, name="survexindex"), url(r'^survex/(.*?)\.index$', views_survex.index, name="survexindex"),
@ -59,7 +59,9 @@ urlpatterns = patterns('',
url(r'^survey/?$', surveyindex, name="survey"), url(r'^survey/?$', surveyindex, name="survey"),
url(r'^survey/(?P<year>\d\d\d\d)\#(?P<wallet_number>\d*)$', survey, name="survey"), url(r'^survey/(?P<year>\d\d\d\d)\#(?P<wallet_number>\d*)$', survey, name="survey"),
url(r'^controlpanel/?$', views_other.controlPanel, name="survey"),
(r'^admin/doc/?', include('django.contrib.admindocs.urls')), (r'^admin/doc/?', include('django.contrib.admindocs.urls')),
(r'^admin/(.*)', admin.site.root), (r'^admin/(.*)', admin.site.root),
#url(r'^admin/', include(admin.site.urls),name="admin"), #url(r'^admin/', include(admin.site.urls),name="admin"),