forked from expo/troggle
archeology on the logbook entry editing forms
This commit is contained in:
@@ -23,15 +23,24 @@ download all QMs (not working)
|
||||
|
||||
todo = '''Delete the newfile & TripForm code once we have a proper file-upload system working.
|
||||
meanwhile keep it as an example to consider.
|
||||
|
||||
Check that the logbookdownloader works by testing with a round trip.
|
||||
|
||||
Use it to convert all older logbooks into the 2005-variant of HTML then we can
|
||||
get rid of the parsers for older formats. There are no images stored in the database,
|
||||
so this is only a tool for a first pass, to be followed by extensive hand-editing!
|
||||
When we have done all the old logbooks, delete this function and the two templates.
|
||||
|
||||
But how does this interact with troggle/logbooksdump.py ?S
|
||||
'''
|
||||
|
||||
def todos(request, module):
|
||||
'''produces todo text from module
|
||||
We should automate this to find all those strings automatically
|
||||
'''
|
||||
from troggle.core.TESTS.tests import todo as tests
|
||||
from troggle.core.views.logbooks import todo as viewlogbooks
|
||||
from troggle.core.forms import todo as forms
|
||||
print(f'TODO - {tests}')
|
||||
tododict = {'views/other': todo,
|
||||
'tests': tests,
|
||||
'views/logbooks': viewlogbooks,
|
||||
@@ -85,6 +94,12 @@ def controlpanel(request):
|
||||
|
||||
|
||||
def downloadlogbook(request,year=None,extension=None,queryset=None):
|
||||
'''Constructs, from the database, a complete HTML (or TXT) formatted logbook - but TEXT ONLY
|
||||
for the current year. Formats available are HTML2005 or 2008text
|
||||
|
||||
There are no images stored in the database, so this is only a tool for a first pass, tobe followed by
|
||||
extensive hand-editing.
|
||||
'''
|
||||
|
||||
if year:
|
||||
current_expedition=Expedition.objects.get(year=year)
|
||||
@@ -108,11 +123,14 @@ def downloadlogbook(request,year=None,extension=None,queryset=None):
|
||||
elif extension == 'html':
|
||||
response = HttpResponse(content_type='text/html')
|
||||
style='2005'
|
||||
else:
|
||||
response = HttpResponse(content_type='text/html')
|
||||
style='2005'
|
||||
|
||||
template='logbook'+style+'style.'+extension
|
||||
response['Content-Disposition'] = 'attachment; filename='+filename+'.'+extension
|
||||
t=loader.get_template(template)
|
||||
c=Context({'logbook_entries':logbook_entries})
|
||||
c={'logbook_entries':logbook_entries}
|
||||
response.write(t.render(c))
|
||||
return response
|
||||
|
||||
@@ -153,7 +171,12 @@ def ajax_QM_number(request):
|
||||
|
||||
@login_required_if_public
|
||||
def newfile(request, pslug = None):
|
||||
''' not known quite what this was for or where it fits in - original 2006 troggle idea never finished?
|
||||
'''
|
||||
If not POST, it goes straight to UploadFileForm using the editfile.html template which is about re-submitting
|
||||
a LBE aka TripReport
|
||||
|
||||
If it is POST, then it is a new LBE so an HTML formatted version of it is produced, using template.render()
|
||||
and a format 'dataformat/logbookentry.html' which is then put in expoweb/years<year>/autologbook/<LBEnamedfile>
|
||||
'''
|
||||
if pslug:
|
||||
previousfile = LogbookEntry.objects.get(slug = pslug, date = previousdate, expedition = expedition)
|
||||
@@ -174,10 +197,10 @@ def newfile(request, pslug = None):
|
||||
delLogbookEntry(previouslbe)
|
||||
f = open(filename, "w")
|
||||
template = loader.get_template('dataformat/logbookentry.html')
|
||||
context = Context({'trip': tripForm.cleaned_data,
|
||||
context = {'trip': tripForm.cleaned_data,
|
||||
'persons': personTripFormSet.cleaned_data,
|
||||
'date': dateStr,
|
||||
'expeditionyear': expeditionyear})
|
||||
'expeditionyear': expeditionyear}
|
||||
f.write(template.render(context))
|
||||
f.close()
|
||||
print(logbookparsers.parseAutoLogBookEntry(filename))
|
||||
|
||||
Reference in New Issue
Block a user