mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 16:51:54 +00:00
[svn] Fixed broken buttons on controlpanel, added CAVETAB2.CSV export and download buttons and made them work too.
Changed ordering on PersonExpeditions so that it is based on their expedition. That way, even if we don't have date info on when a user was on expo exactly, pages like personindex work correctly.
This commit is contained in:
parent
191619e6d8
commit
e9e755b517
@ -6,6 +6,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
|
||||
from django.core import management
|
||||
from django.db import connection
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpResponse
|
||||
|
||||
def reload_db():
|
||||
cursor = connection.cursor()
|
||||
@ -55,4 +56,19 @@ def reset():
|
||||
import_logbooks()
|
||||
import_survex()
|
||||
import_QMs()
|
||||
import_surveys()
|
||||
import_surveys()
|
||||
|
||||
def export_cavetab():
|
||||
from export import tocavetab
|
||||
outfile=file(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV"),'w')
|
||||
tocavetab.writeCaveTab(outfile)
|
||||
outfile.close()
|
||||
|
||||
def export_qms(): #finish this. need cave chooser
|
||||
from export import toqms
|
||||
outfile=file(os.path.join(settings.EXPOWEB, "noinfo", "CAVETAB2.CSV"),'w')
|
||||
outfile.close()
|
||||
|
||||
|
||||
|
||||
|
@ -162,7 +162,8 @@ class PersonExpedition(TroggleModel):
|
||||
|
||||
class Meta:
|
||||
ordering = ('expedition',)
|
||||
get_latest_by = 'date_from'
|
||||
#order_with_respect_to = 'expedition'
|
||||
get_latest_by = 'expedition'
|
||||
|
||||
def GetPersonChronology(self):
|
||||
res = { }
|
||||
|
@ -5,8 +5,7 @@ from django.db.models import Q
|
||||
import databaseReset
|
||||
import re
|
||||
import randSent
|
||||
from django.http import HttpResponse
|
||||
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.core.urlresolvers import reverse
|
||||
from troggle.alwaysUseRequestContext import render_response # see views_logbooks for explanation on this.
|
||||
|
||||
@ -62,9 +61,20 @@ def calendar(request,year):
|
||||
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+"()"
|
||||
if request.user.is_superuser:
|
||||
for item in request.POST:
|
||||
if item!='item':
|
||||
print "running"+ " databaseReset."+item+"()"
|
||||
exec "databaseReset."+item+"()"
|
||||
else:
|
||||
return HttpResponseRedirect(reverse('auth_login'))
|
||||
|
||||
return render_response(request,'controlPanel.html', )
|
||||
return render_response(request,'controlPanel.html', )
|
||||
|
||||
def downloadCavetab(request):
|
||||
from export import tocavetab
|
||||
response = HttpResponse(mimetype='text/csv')
|
||||
response['Content-Disposition'] = 'attachment; filename=CAVEETAB2.CSV'
|
||||
tocavetab.writeCaveTab(response)
|
||||
return response
|
||||
|
@ -42,8 +42,7 @@ def cavetabRow(cave):
|
||||
caveRow[headers.index(column)]=modelField.replace(u'\xd7','x').replace(u'\u201c','').replace(u'\u2013','').replace(u'\xbd','')
|
||||
return caveRow
|
||||
|
||||
def writeCaveTab(path):
|
||||
outfile=file(path,'w')
|
||||
def writeCaveTab(outfile):
|
||||
cavewriter=csv.writer(outfile,lineterminator='\r')
|
||||
cavewriter.writerow(headers)
|
||||
for cave in models.Cave.objects.all():
|
||||
|
@ -28,8 +28,7 @@ def qmRow(qm):
|
||||
qmRow[headers.index(column)]=modelField.replace(u'\xd7','x').replace(u'\u201c','').replace(u'\u2013','').replace(u'\xbd','')
|
||||
return qmRow
|
||||
|
||||
def writeQmTable(path,cave):
|
||||
outfile=file(path,'w')
|
||||
def writeQmTable(outfile,cave):
|
||||
cavewriter=csv.writer(outfile,lineterminator='\r')
|
||||
cavewriter.writerow(headers)
|
||||
for qm in cave.get_QMs():
|
||||
|
@ -1,6 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
sys.path.append("/home/mjg/expoweb/troggle")
|
||||
import troggle.expo.models as models
|
||||
from django.conf import settings
|
||||
import csv
|
||||
|
2
urls.py
2
urls.py
@ -58,6 +58,7 @@ urlpatterns = patterns('',
|
||||
url(r'^survey/(?P<year>\d\d\d\d)\#(?P<wallet_number>\d*)$', survey, name="survey"),
|
||||
|
||||
url(r'^controlpanel/?$', views_other.controlPanel, name="controlpanel"),
|
||||
url(r'^cavetab/?$', views_other.downloadCavetab, name="downloadcavetab"),
|
||||
|
||||
(r'^admin/doc/?', include('django.contrib.admindocs.urls')),
|
||||
(r'^admin/(.*)', admin.site.root),
|
||||
@ -68,7 +69,6 @@ urlpatterns = patterns('',
|
||||
|
||||
# (r'^personform/(.*)$', personForm),
|
||||
|
||||
(r'^photologue/', include('photologue.urls')),
|
||||
|
||||
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
|
||||
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
|
||||
|
Loading…
Reference in New Issue
Block a user