mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 14:57:12 +00:00
2003 logbook export/re-import as now HTML format
This commit is contained in:
@@ -148,15 +148,13 @@ def controlpanel(request):
|
||||
|
||||
|
||||
def exportlogbook(request,year=None,extension=None):
|
||||
'''Constructs, from the database, a complete HTML formatted logbook - but TEXT ONLY
|
||||
for the current year. Formats available are HTML2005 or HTML2022 (planned)
|
||||
'''Constructs, from the database, a complete HTML formatted logbook
|
||||
for the current year. Formats available are HTML2005 (others old & broken or not written yet)
|
||||
|
||||
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.
|
||||
hand-editing. However links to images work int he HTML text of a logbook entry
|
||||
|
||||
NEED TO ADD IN THE MATERIAL WHICH IS NOT IN ANY LBE ! e.g. front matter.
|
||||
|
||||
This function DOES NOT WORK.
|
||||
NEED TO ADD IN THE MATERIAL WHICH IS NOT IN ANY LBE ! e.g. front matter.
|
||||
|
||||
This function is the recipient of the POST action os the export form in the control panel
|
||||
'''
|
||||
@@ -170,26 +168,18 @@ def exportlogbook(request,year=None,extension=None):
|
||||
else:
|
||||
print(f'Logbook export {request.POST}')
|
||||
|
||||
if request.POST.get("year", '2016'):
|
||||
year = request.POST['year']
|
||||
if request.POST.get("extension", 'html'):
|
||||
extension = request.POST['extension'] # e.g. html
|
||||
|
||||
year = request.POST['year']
|
||||
current_expedition=Expedition.objects.get(year=year)
|
||||
logbook_entries=LogbookEntry.objects.filter(expedition=current_expedition).order_by('date') # need to be sorted by date!
|
||||
|
||||
#print(f'Logbook has {len(logbook_entries)} entries in it.')
|
||||
print(f'Logbook has {len(logbook_entries)} entries in it.')
|
||||
|
||||
if extension == 'html2005':
|
||||
response = HttpResponse(content_type='text/html')
|
||||
style='2005'
|
||||
else :
|
||||
extension == 'html2022'
|
||||
response = HttpResponse(content_type='text/html')
|
||||
style='2022'
|
||||
|
||||
filename='newlogbook.' + extension
|
||||
template='logbook'+style+'style.'+extension
|
||||
extension ='html'
|
||||
response = HttpResponse(content_type='text/html')
|
||||
style='2005'
|
||||
|
||||
filename='logbook-new-format.' + extension
|
||||
template='logbook'+style+'style.'+ extension
|
||||
response['Content-Disposition'] = 'attachment; filename='+filename
|
||||
t=loader.get_template(template)
|
||||
logbookfile = (t.render({'logbook_entries':logbook_entries}))
|
||||
|
||||
Reference in New Issue
Block a user