forked from expo/troggle
[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.core import management
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.http import HttpResponse
|
||||||
|
|
||||||
def reload_db():
|
def reload_db():
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
@ -56,3 +57,18 @@ def reset():
|
|||||||
import_survex()
|
import_survex()
|
||||||
import_QMs()
|
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:
|
class Meta:
|
||||||
ordering = ('expedition',)
|
ordering = ('expedition',)
|
||||||
get_latest_by = 'date_from'
|
#order_with_respect_to = 'expedition'
|
||||||
|
get_latest_by = 'expedition'
|
||||||
|
|
||||||
def GetPersonChronology(self):
|
def GetPersonChronology(self):
|
||||||
res = { }
|
res = { }
|
||||||
|
@ -5,8 +5,7 @@ from django.db.models import Q
|
|||||||
import databaseReset
|
import databaseReset
|
||||||
import re
|
import re
|
||||||
import randSent
|
import randSent
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
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.
|
||||||
|
|
||||||
@ -62,9 +61,20 @@ def calendar(request,year):
|
|||||||
def controlPanel(request):
|
def controlPanel(request):
|
||||||
message = "no test message" #reverse('personn', kwargs={"name":"hkjhjh"})
|
message = "no test message" #reverse('personn', kwargs={"name":"hkjhjh"})
|
||||||
if request.method=='POST':
|
if request.method=='POST':
|
||||||
for item in request.POST:
|
if request.user.is_superuser:
|
||||||
if request.user.is_superuser and item!='item':
|
for item in request.POST:
|
||||||
print "running"+ " databaseReset."+item+"()"
|
if item!='item':
|
||||||
exec "databaseReset."+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','')
|
caveRow[headers.index(column)]=modelField.replace(u'\xd7','x').replace(u'\u201c','').replace(u'\u2013','').replace(u'\xbd','')
|
||||||
return caveRow
|
return caveRow
|
||||||
|
|
||||||
def writeCaveTab(path):
|
def writeCaveTab(outfile):
|
||||||
outfile=file(path,'w')
|
|
||||||
cavewriter=csv.writer(outfile,lineterminator='\r')
|
cavewriter=csv.writer(outfile,lineterminator='\r')
|
||||||
cavewriter.writerow(headers)
|
cavewriter.writerow(headers)
|
||||||
for cave in models.Cave.objects.all():
|
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','')
|
qmRow[headers.index(column)]=modelField.replace(u'\xd7','x').replace(u'\u201c','').replace(u'\u2013','').replace(u'\xbd','')
|
||||||
return qmRow
|
return qmRow
|
||||||
|
|
||||||
def writeQmTable(path,cave):
|
def writeQmTable(outfile,cave):
|
||||||
outfile=file(path,'w')
|
|
||||||
cavewriter=csv.writer(outfile,lineterminator='\r')
|
cavewriter=csv.writer(outfile,lineterminator='\r')
|
||||||
cavewriter.writerow(headers)
|
cavewriter.writerow(headers)
|
||||||
for qm in cave.get_QMs():
|
for qm in cave.get_QMs():
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import sys
|
|
||||||
sys.path.append("/home/mjg/expoweb/troggle")
|
|
||||||
import troggle.expo.models as models
|
import troggle.expo.models as models
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import csv
|
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'^survey/(?P<year>\d\d\d\d)\#(?P<wallet_number>\d*)$', survey, name="survey"),
|
||||||
|
|
||||||
url(r'^controlpanel/?$', views_other.controlPanel, name="controlpanel"),
|
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/doc/?', include('django.contrib.admindocs.urls')),
|
||||||
(r'^admin/(.*)', admin.site.root),
|
(r'^admin/(.*)', admin.site.root),
|
||||||
@ -68,7 +69,6 @@ urlpatterns = patterns('',
|
|||||||
|
|
||||||
# (r'^personform/(.*)$', personForm),
|
# (r'^personform/(.*)$', personForm),
|
||||||
|
|
||||||
(r'^photologue/', include('photologue.urls')),
|
|
||||||
|
|
||||||
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
|
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
|
||||||
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
|
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
|
||||||
|
Loading…
Reference in New Issue
Block a user