2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 16:51:54 +00:00
This commit is contained in:
substantialnoninfringinguser 2009-05-19 06:32:42 +01:00
parent d71078d03d
commit 2c2f11be39
17 changed files with 149 additions and 95 deletions

View File

@ -1,4 +1,5 @@
from django.conf import settings
from expo.models import Expedition
def settings_context(request):
return { 'settings':settings }
def troggle_context(request):
return { 'settings':settings, 'Expedition':Expedition }

View File

@ -21,7 +21,7 @@ class TroggleModel(models.Model):
return self._meta.object_name
def get_admin_url(self):
return settings.URL_ROOT + "/admin/expo/" + self.object_name.lower() + "/" + str(self.pk)
return settings.URL_ROOT + "/admin/expo/" + self.object_name().lower() + "/" + str(self.pk)
class Meta:
abstract = True

View File

@ -93,4 +93,3 @@ def survey(request,year,wallet_number):
elevationSketches=current_survey.scannedimage_set.filter(contents='elevation')
return render_response(request,'survey.html', locals())

View File

@ -60,17 +60,20 @@ def calendar(request,year):
return render_response(request,'calendar.html', locals())
def controlPanel(request):
message = "no test message" #reverse('personn', kwargs={"name":"hkjhjh"})
jobs_completed=[]
if request.method=='POST':
if request.user.is_superuser:
for item in request.POST:
if item!='item':
importlist=['import_people', 'import_cavetab', 'import_logbooks', 'import_surveys', 'import_QMs']
databaseReset.make_dirs()
for item in importlist:
if item in request.POST:
print "running"+ " databaseReset."+item+"()"
exec "databaseReset."+item+"()"
jobs_completed.append(item)
else:
return HttpResponseRedirect(reverse('auth_login'))
return render_response(request,'controlPanel.html', {'caves':Cave.objects.all()} )
return render_response(request,'controlPanel.html', {'caves':Cave.objects.all(),'jobs_completed':jobs_completed})
def downloadCavetab(request):
from export import tocavetab
@ -99,3 +102,8 @@ def downloadQMs(request):
response['Content-Disposition'] = 'attachment; filename=qm.csv'
toqms.writeQmTable(response,cave)
return response
def ajax_test(request):
post_text = request.POST['post_data']
return HttpResponse("{'response_text': '"+post_text+" recieved.'}",
mimetype="application/json")

View File

@ -20,7 +20,7 @@ ul.dropdown li.hover a { color: black; background:gray;}
*/
ul.dropdown ul { width: 220px; visibility: hidden; position: absolute; bottom: 100%; left: 0px; margin-left:0px; padding-left: 0px; background:none}
ul.dropdown ul li { font-weight: normal; color: black; background: none; border-bottom: 1px solid #ccc; float: none; padding:0px; margin:0px}
ul.dropdown ul li:hover, ul.dropdown ul li a:hover { color:white;}
/* IE 6 & 7 Needs Inline Block */
ul.dropdown ul li a { border-right: none; width: 100%; display: inline-block; color: black;}

View File

@ -199,24 +199,7 @@ a.redtext:link {
}
.redtext
.menuBarItem {
font-variant: small-caps;
text-align: right;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
}
.menuBarItem : hover {
background: "rgb(125, 125, 125)";
}
.behind {
@ -327,9 +310,11 @@ h1 {
#footerLinks{
position:fixed;
bottom:0px;
padding: 0;
padding: 0px;
margin-left: 130px;
margin-right: 130px;
margin-bottom: 0px;
}
/*.fadeIn {

View File

@ -1,12 +1,37 @@
div#nav {
position:fixed;
width: 12em;
background: rgb(153, 153, 153);
background: none;
margin-top: 0px;
margin-left: 120px;
border-top: thin black solid;
margin-left: 130px;
border-right: thin black solid;
border-left: thin black solid;
border-bottom: thin black solid;
border-top: none;
}
div#content {
padding-left:240px;
}
.menuBarItem {
font-variant: small-caps;
text-align: right;
border-top-style: none;
border-right-style: none;
border-bottom-style: none;
border-left-style: none;
border-top-width: thin;
border-right-width: thin;
border-bottom-width: thin;
border-left-width: thin;
}
.menuBarItem:hover {
background:#333;
}
.menuBarItem.on {
background:#333;
color:#999;
}

View File

@ -16,7 +16,7 @@ function setMaxHeight(group, target) {
}
/*This is the jquery comment stuff */
/*This is the jquery stuff */
$(document).ready(function() {
$('.searchable li').quicksearch({
@ -42,12 +42,13 @@ $(".toggleMenu").click(function () {
$(".toggleMenu").toggle();
});
$(".nav").css('opacity','7')
$(".footer").hide();
$(".fadeIn").hide();
setTimeout("$('.leftMargin.fadeIn').fadeIn(3000);",1000);
setTimeout("$('.rightMargin.fadeIn').fadeIn(3000);",2000);
$("a.closeDiv").click(function () {
$(this).parent().hide();
});
/*$("#footerLinks").hover(
function() {$(".footer").fadeIn("slow")},

View File

@ -34,7 +34,7 @@ def parseCaveQMs(cave,inputFile):
return
qmPath = settings.EXPOWEB+inputFile
qmCSVContents = open(qmPath,'r')
qmCSVContents = open(qmPath,'rU')
dialect=csv.Sniffer().sniff(qmCSVContents.read())
qmCSVContents.seek(0,0)
qmReader = csv.reader(qmCSVContents,dialect=dialect)

View File

@ -137,7 +137,7 @@ def html_to_wiki(text):
return out
def LoadCaveTab(logfile=None):
cavetab = open(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV"))
cavetab = open(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV"),'rU')
caveReader = csv.reader(cavetab)
caveReader.next() # Strip out column headers

View File

@ -26,15 +26,19 @@ def saveMugShot(mugShotPath, mugShotFilename, person):
else:
mugShotFilename=mugShotFilename # just in case one doesn't
mugShotObj = models.Photo(
caption="Mugshot for "+person.first_name+" "+person.last_name,
is_mugshot=True,
file=mugShotFilename,
dummyObj=models.Photo(file=mugShotFilename)
#Put a copy of the file in the right place. mugShotObj.file.path is determined by the django filesystemstorage specified in models.py
if not os.path.exists(dummyObj.file.path):
shutil.copy(mugShotPath, dummyObj.file.path)
mugShotObj, created = save_carefully(
models.Photo,
lookupAttribs={'is_mugshot':True, 'file':mugShotFilename},
nonLookupAttribs={'caption':"Mugshot for "+person.first_name+" "+person.last_name}
)
shutil.copy(mugShotPath, mugShotObj.file.path) #Put a copy of the file in the right place. mugShotObj.file.path is determined by the django filesystemstorage specified in models.py
mugShotObj.save()
if created:
mugShotObj.contains_person.add(person)
mugShotObj.save()
@ -46,6 +50,7 @@ def parseMugShotAndBlurb(personline, header, person):
saveMugShot(mugShotPath=mugShotPath, mugShotFilename=mugShotFilename, person=person)
elif mugShotPath[-3:]=='htm': #if person has an html page, find the image(s) and add it. Also, add the text from the html page to the "blurb" field in his model instance.
personPageOld=open(mugShotPath,'r').read()
if not person.blurb:
person.blurb=re.search('<body>.*<hr',personPageOld,re.DOTALL).group() #this needs to be refined, take care of the HTML and make sure it doesn't match beyond the blurb
for mugShotFilename in re.findall('i/.*?jpg',personPageOld,re.DOTALL):
mugShotPath = os.path.join(settings.EXPOWEB, "folk", mugShotFilename)
@ -61,18 +66,17 @@ def LoadPersonsExpos():
# make expeditions
print "Loading expeditions"
models.Expedition.objects.all().delete()
years = headers[5:]
for year in years:
expedition = models.Expedition(year = year, name = "CUCC expo %s" % year)
expedition.save()
lookupAttribs = {'year':year}
nonLookupAttribs = {'name':"CUCC expo %s" % year}
save_carefully(models.Expedition, lookupAttribs, nonLookupAttribs)
# make persons
print "Loading personexpeditions"
models.Person.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(",")
#expomissing = set(expoers2008)
@ -84,7 +88,7 @@ def LoadPersonsExpos():
lookupAttribs={'first_name':mname.group(1), 'last_name':(mname.group(2) or "")}
nonLookupAttribs={'is_vfho':personline[header["VfHO member"]],}
person, created = save_carefully(models.Person, lookupAttribs=lookupAttribs, nonLookupAttribs=nonLookupAttribs)
person, created = save_carefully(models.Person, lookupAttribs, nonLookupAttribs)
parseMugShotAndBlurb(personline=personline, header=header, person=person)
@ -92,8 +96,9 @@ def LoadPersonsExpos():
for year, attended in zip(headers, personline)[5:]:
expedition = models.Expedition.objects.get(year=year)
if attended == "1" or attended == "-1":
personexpedition = models.PersonExpedition(person=person, expedition=expedition, nickname=nickname, is_guest=(personline[header["Guest"]] == "1"))
personexpedition.save()
lookupAttribs = {'person':person, 'expedition':expedition}
nonLookupAttribs = {'nickname':nickname, 'is_guest':(personline[header["Guest"]] == "1")}
save_carefully(models.PersonExpedition, lookupAttribs, nonLookupAttribs)
# this fills in those people for whom 2008 was their first expo

View File

@ -54,7 +54,7 @@ TEMPLATE_LOADERS = (
# 'django.template.loaders.eggs.load_template_source',
)
TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "expo.context.settings_context", )
TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "expo.context.troggle_context", )
LOGIN_REDIRECT_URL = '/'

View File

@ -65,15 +65,25 @@ window.onload = contentHeight;
<li><a href="#">External links</a>
<ul class="sub_menu">
<li><a id="cuccLink" href="http://cucc.survex.com">CUCC website</a></li>
<li><a id="cuccLink" href="http://www.srcf.ucam.org/caving/wiki/Main_Page">CUCC website</a></li>
<li><a id="expoWebsiteLink" href="http://cucc.survex.com/expo">Expedition website</a></li>
</ul>
</li>
<li><a href="{% url frontpage %}">Troggle front page</a></li>
<li><a id="cavesLink" href="{% url caveindex %}">caves</a></li>
<li><a id="caversLink" href="{% url personindex %}">cavers</a></li>
<li><a href="#">expeditions</a>
<ul class="sub_menu">
<li><a id="expeditionsLink" href="{{ Expedition.objects.latest.get_absolute_url }}">newest</a></li>
<li><a id="expeditionsLink" href="{% url expeditions %}">list all</a></li>
</ul>
</li>
<li><a id="surveyBinderLink" href="{% url survey %}">survey binder</a></li>
<li><a href="#">diversions</a>
<ul class="sub_menu">
<li><a href="{% url stats %}">statistics</a></li>
</ul>
</li>
<li><a href="{% url calendar 2008 %}">expedition calendar</a></li>
<li><a href="#">admin</a>
<ul class="sub_menu">
@ -84,18 +94,5 @@ window.onload = contentHeight;
</ul>
<div class="toggleMenu" style="display:none; position:fixed; bottom:0; right:130px"><a href="#">Show menu</a></li>
<!--
<a id="cuccLink" href="http://cucc.survex.com">CUCC website</a> |
<a id="expoWebsiteLink" href="http://cucc.survex.com/expo">Expedition website</a> |
External links |
<a href="{% url frontpage %}">Troggle front page</a> |
<a href="{% url caveindex %}">Caves</a> |
<a id="caversLink" href="{% url personindex %}">Cavers</a> |
<a id="surveyBinderLink" href="{% url survey %}"> Survey binder</a> |
<a href="{% url stats %}"> Statistics</a> |
<a href="{% url calendar 2008 %}">Expedition calendar</a>
</div>
-->
</body>
</html>

View File

@ -1,15 +1,30 @@
{% extends "base.html" %}
{% block content %}
<form name="import" method="post" action="">
<h3>Dump:</h3>
{% if jobs_completed %}
<div style="border:thin black solid; width: 40%; color:#F00; margin-left:auto; margin-right:auto">
Just finished running:
<ul>
{% for job in jobs_completed %}
<li>{{ job }}</li>
{% endfor %}
</ul>
{% if settings.LOGFILE %}See the logfile at {{settings.LOGFILE.path}} for more information.{% endif %}
<a href="#" class="closeDiv">dismiss this message</a>
</div>
{% endif %}
<form name="reset" method="post" action="">
<h3>Wipe:</h3>
<table>
<tr><td>Dump entire database and recreate tables: </td><td><input type="checkbox" name="dump_db" /></td></tr>
<tr><td>Wipe entire database and recreate tables: </td><td><input type="checkbox" name="reset" /></td><td> <input type="submit" id="Import" value="I really want to delete all information in troggle, and accept all responsibility."></td></tr>
</table>
</form>
<h3>Import (non-destructive):</h3>
<form name="import" method="post" action="">
<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>
@ -24,7 +39,7 @@
<p>
<input type="submit" id="Import" value="Import">
<input type="submit" name="check_all_import" id="check_all_import" value="Check all">
<input type="submit" name="check_all_import" id="check_all_import" value="Check all" disabled >
</p>
</form>

View File

@ -12,7 +12,26 @@
highlightedColor = "rgb(125, 125, 125)"
chosenColor = "rgb(255, 255, 255)"
$(document).ready(function() {
$(".menuBarItem").click(function() {
$("#"+this.id+"Content").toggle();
if ($(this).hasClass('on')){
$(this).removeClass('on');}
else {
$(this).addClass('on');
}
});
});
function redirectSurvey(){
window.location = "{% url survey %}" + '/' + document.getElementById("expeditionChooser").value + "%23" + document.getElementById("surveyChooser").value;
}
function redirectYear(){
window.location = "{% url survey %}" + '/' + document.getElementById("expeditionChooser").value + "%23";
}
</script>
{% endblock %}
<div id="currentLocation">
@ -70,16 +89,16 @@
</center>
<!-- <h4>Click to toggle:</h4>-->
<div id="surveyWalletNav">
<div id="notes" class="menuBarItem" > {% if notes %}&#10003;{% endif %}
<div id="notes" class="menuBarItem" "> {% if notes %}&#10003;{% endif %}
scanned notes </div>
<div id="survexFile" class="menuBarItem" > {% if current_survey.survex_file %}&#10003;{% endif %}
<div id="survexFile" class="menuBarItem" "> {% if current_survey.survex_file %}&#10003;{% endif %}
survex file </div>
<div id="printedCentreline" class="menuBarItem" > {% if current_survey.centreline_printed_on %}&#10003;{% endif %}
<div id="printedCentreline" class="menuBarItem" "> {% if current_survey.centreline_printed_on %}&#10003;{% endif %}
printed centreline </div>
<div id="scannedPassageSketch" class="menuBarItem" > {% if planSketches %}&#10003;{% endif %}
<div id="scannedPassageSketch" class="menuBarItem" "> {% if planSketches %}&#10003;{% endif %}
scanned passage sketch </div>
<div id="tunnelXMLfile" class="menuBarItem" >tunnel xml file</div>
<div id="mainSketchIntegration" class="menuBarItem" >add to main sketch</div>
<div id="tunnelXMLfile" class="menuBarItem" ">tunnel xml file</div>
<div id="mainSketchIntegration" class="menuBarItem" ">add to main sketch</div>
</div>
</div>
{% endblock %}
@ -141,7 +160,7 @@
</p>
</div>
{% endfor %}
<div class="figure"> <a href="{{ settings.URL_ROOT }}admin/expo/scannedimage/add/" target="_blank"> <img src="{{ settings.URL_ROOT }}{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_addlink.gif" /> Add a new scanned notes page. </a> </div>
<div class="figure"> <a href="{{ settings.URL_ROOT }}admin/expo/scannedimage/add/"> <img src="{{ settings.URL_ROOT }}{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_addlink.gif" /> Add a new scanned notes page. </a> </div>
</div>
<br class="clearfloat" />
<div id="survexFileContent" class="behind"> survex file editor, keeping file in original structure <br />

View File

@ -24,7 +24,7 @@ urlpatterns = patterns('',
#url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"),
url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"),
url(r'^expeditions/?$', object_list, {'queryset':Expedition.objects.all(),'template_name':'expeditions.html'},name="expeditionlist"),
url(r'^expeditions/?$', object_list, {'queryset':Expedition.objects.all(),'template_name':'object_list.html'},name="expeditions"),
url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-z]*)/(?P<year>\d+)/?$', views_logbooks.personexpedition, name="personexpedition"),
url(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', views_logbooks.logbookentry,name="logbookentry"),
@ -74,7 +74,6 @@ urlpatterns = patterns('',
# (r'^personform/(.*)$', personForm),
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),