2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-16 10:37:12 +00:00

break recursive import cycle

This commit is contained in:
Philip Sargent
2020-06-16 16:07:36 +01:00
parent 4c44a504ed
commit 1b693da5ed
4 changed files with 92 additions and 94 deletions

View File

@@ -8,7 +8,7 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.template import Context, loader
import databaseReset
import troggle.parsers.imports
from troggle.core.models import Expedition, Person, PersonExpedition
from troggle.core.models_caves import LogbookEntry, QM, Cave, PersonTrip
from troggle.core.models_survex import SurvexLeg
@@ -35,18 +35,16 @@ def controlPanel(request):
jobs_completed=[]
if request.method=='POST':
if request.user.is_superuser:
# NONE of this works now that databaseReset has been so extensively rewritten
#importlist is mostly here so that things happen in the correct order.
#http post data seems to come in an unpredictable order, so we do it this way.
importlist=['reinit_db', 'import_people', 'import_caves', 'import_logbooks',
'import_survexblks', 'import_QMs', 'import_surveyscans', 'import_tunnelfiles']
databaseReset.dirsredirect()
for item in importlist:
if item in request.POST:
print(("running"+ " databaseReset."+item+"()"))
exec("databaseReset."+item+"()")
jobs_completed.append(item)
# NONE of this works now that databaseReset (now parsers.imports) has been so extensively rewritten
reinit_db()
import_caves()
import_people()
import_surveyscans()
import_logbooks()
import_QMs()
import_tunnelfiles()
import_survexblks()
import_survexpos()
else:
if request.user.is_authenticated(): #The user is logged in, but is not a superuser.
return render(request,'controlPanel.html', {'caves':Cave.objects.all(),'error':'You must be a superuser to use that feature.'})
@@ -212,24 +210,6 @@ def newFile(request, pslug = None):
else:
if pslug:
pass
# if previouslbe.cave:
# tripForm = TripForm(initial={"date": previousdate,
# "title": previouslbe.title,
# "cave": previouslbe.cave.reference(),
# "location": None,
# "caveOrLocation": "cave",
# "html": previouslbe.text})
# else:
# tripForm = TripForm(initial={"date": previousdate,
# "title": previouslbe.title,
# "cave": None,
# "location": previouslbe.place,
# "caveOrLocation": "location",
# "html": previouslbe.text})
# personTripFormSet = PersonTripFormSet(initial=[{"name": get_name(py.personexpedition),
# "TU": py.time_underground,
# "author": py.is_logbook_entry_author}
# for py in previouslbe.persontrip_set.all()])
else:
fileform = UploadFileForm() # An unbound form