From 2c2f11be39f88310e21f974416d6cf24754fb269 Mon Sep 17 00:00:00 2001 From: substantialnoninfringinguser Date: Tue, 19 May 2009 06:32:42 +0100 Subject: [PATCH] [svn] --- expo/context.py | 5 ++-- expo/models.py | 2 +- expo/views_caves.py | 1 - expo/views_other.py | 18 +++++++++---- media/css/dropdownNavStyle.css | 2 +- media/css/main3.css | 25 ++++------------- media/css/nav.css | 31 ++++++++++++++++++--- media/js/base.js | 7 ++--- parsers/QMs.py | 2 +- parsers/cavetab.py | 2 +- parsers/people.py | 49 +++++++++++++++++++--------------- parsers/surveys.py | 2 +- settings.py | 2 +- templates/base.html | 27 +++++++++---------- templates/controlPanel.html | 27 ++++++++++++++----- templates/survey.html | 37 ++++++++++++++++++------- urls.py | 5 ++-- 17 files changed, 149 insertions(+), 95 deletions(-) diff --git a/expo/context.py b/expo/context.py index 06215ce..bb38a84 100644 --- a/expo/context.py +++ b/expo/context.py @@ -1,4 +1,5 @@ from django.conf import settings +from expo.models import Expedition -def settings_context(request): - return { 'settings':settings } \ No newline at end of file +def troggle_context(request): + return { 'settings':settings, 'Expedition':Expedition } \ No newline at end of file diff --git a/expo/models.py b/expo/models.py index 74a26d4..798fa35 100644 --- a/expo/models.py +++ b/expo/models.py @@ -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 diff --git a/expo/views_caves.py b/expo/views_caves.py index 691cdcb..51c9e11 100644 --- a/expo/views_caves.py +++ b/expo/views_caves.py @@ -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()) - diff --git a/expo/views_other.py b/expo/views_other.py index 8f3af0d..4cbf786 100644 --- a/expo/views_other.py +++ b/expo/views_other.py @@ -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 @@ -98,4 +101,9 @@ def downloadQMs(request): response = HttpResponse(mimetype='text/csv') response['Content-Disposition'] = 'attachment; filename=qm.csv' toqms.writeQmTable(response,cave) - return response \ No newline at end of file + return response + +def ajax_test(request): + post_text = request.POST['post_data'] + return HttpResponse("{'response_text': '"+post_text+" recieved.'}", + mimetype="application/json") \ No newline at end of file diff --git a/media/css/dropdownNavStyle.css b/media/css/dropdownNavStyle.css index b3cf2b4..8ac9849 100644 --- a/media/css/dropdownNavStyle.css +++ b/media/css/dropdownNavStyle.css @@ -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;} diff --git a/media/css/main3.css b/media/css/main3.css index 77657a0..2105050 100644 --- a/media/css/main3.css +++ b/media/css/main3.css @@ -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; - margin-left:130px; - margin-right:130px; + padding: 0px; + margin-left: 130px; + margin-right: 130px; + margin-bottom: 0px; + } /*.fadeIn { diff --git a/media/css/nav.css b/media/css/nav.css index 1c97c51..81f7918 100644 --- a/media/css/nav.css +++ b/media/css/nav.css @@ -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; } \ No newline at end of file diff --git a/media/js/base.js b/media/js/base.js index 7a7ed5e..62a72f4 100644 --- a/media/js/base.js +++ b/media/js/base.js @@ -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")}, diff --git a/parsers/QMs.py b/parsers/QMs.py index 732e913..571ec28 100644 --- a/parsers/QMs.py +++ b/parsers/QMs.py @@ -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) diff --git a/parsers/cavetab.py b/parsers/cavetab.py index 2dc071c..89e7728 100644 --- a/parsers/cavetab.py +++ b/parsers/cavetab.py @@ -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 diff --git a/parsers/people.py b/parsers/people.py index 2950fb7..cd9a661 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -25,18 +25,22 @@ def saveMugShot(mugShotPath, mugShotFilename, person): mugShotFilename=mugShotFilename[2:] 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() - mugShotObj.contains_person.add(person) - mugShotObj.save() + if created: + mugShotObj.contains_person.add(person) + mugShotObj.save() def parseMugShotAndBlurb(personline, header, person): #create mugshot Photo instance @@ -46,10 +50,11 @@ 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() - person.blurb=re.search('.*.*External links
  • Troggle front page
  • caves
  • cavers
  • +
  • expeditions + +
  • survey binder
  • -
  • statistics
  • +
  • diversions + +
  • expedition calendar
  • admin
  • - - diff --git a/templates/controlPanel.html b/templates/controlPanel.html index bce56f8..487b7d1 100644 --- a/templates/controlPanel.html +++ b/templates/controlPanel.html @@ -1,15 +1,30 @@ {% extends "base.html" %} {% block content %} -
    -

    Dump:

    + +{% if jobs_completed %} +
    + Just finished running: +
      + {% for job in jobs_completed %} +
    • {{ job }}
    • + {% endfor %} +
    + {% if settings.LOGFILE %}See the logfile at {{settings.LOGFILE.path}} for more information.{% endif %} + dismiss this message +
    +{% endif %} + + + +

    Wipe:

    - +
    Dump entire database and recreate tables:
    Wipe entire database and recreate tables:
    - +

    Import (non-destructive):

    - +
    @@ -24,7 +39,7 @@

    - +

    diff --git a/templates/survey.html b/templates/survey.html index 9d677e5..290cd97 100644 --- a/templates/survey.html +++ b/templates/survey.html @@ -11,8 +11,27 @@ blankColor = "rgb(153, 153, 153)" 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"; + } + {% endblock %}
    @@ -45,7 +64,7 @@
    - @@ -70,16 +89,16 @@
    -
    survex file editor, keeping file in original structure
    diff --git a/urls.py b/urls.py index 8ae9ca7..fc2b7a2 100644 --- a/urls.py +++ b/urls.py @@ -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[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"), @@ -72,8 +72,7 @@ urlpatterns = patterns('', (r'^accounts/', include('registration.urls')), (r'^profiles/', include('profiles.urls')), -# (r'^personform/(.*)$', personForm), - +# (r'^personform/(.*)$', personForm), (r'^site_media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
    caves from cavetab2.csv using parsers\cavetab.py
    logbook entries using parsers\logbooks.py