forked from expo/troggle
delete old forms, templates. fix logdataissues
This commit is contained in:
@@ -22,17 +22,19 @@ Also has code to download a logbook in a choice of formats (why?!) and to
|
||||
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.
|
||||
todo = '''
|
||||
- Check that the logbookdownloader works by testing with a round trip.
|
||||
|
||||
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.
|
||||
|
||||
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 ?
|
||||
|
||||
- deleted nefile() - check on deleted UploadFileForm using the editfile.html template which is about re-submitting
|
||||
a LBE aka TripReport
|
||||
|
||||
But how does this interact with troggle/logbooksdump.py ?S
|
||||
'''
|
||||
|
||||
def todos(request, module):
|
||||
@@ -174,50 +176,6 @@ def ajax_QM_number(request):
|
||||
|
||||
return HttpResponse(res)
|
||||
|
||||
@login_required_if_public
|
||||
def newfile(request, pslug = None):
|
||||
'''
|
||||
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)
|
||||
if request.method == 'POST': # If the form has been submitted...
|
||||
tripForm = TripForm(request.POST) # A form bound to the POST data
|
||||
personTripFormSet = PersonTripFormSet(request.POST)
|
||||
if tripForm.is_valid() and personTripFormSet.is_valid(): # All validation rules pass
|
||||
dateStr = tripForm.cleaned_data["date"].strftime("%Y-%m-%d")
|
||||
directory = os.path.join(settings.EXPOWEB,
|
||||
"years",
|
||||
expedition.year,
|
||||
"autologbook")
|
||||
filename = os.path.join(directory,
|
||||
dateStr + "." + slugify(tripForm.cleaned_data["title"])[:50] + ".html")
|
||||
if not os.path.isdir(directory):
|
||||
os.mkdir(directory)
|
||||
if pslug and pdate:
|
||||
delLogbookEntry(previouslbe)
|
||||
f = open(filename, "w")
|
||||
template = loader.get_template('dataformat/logbookentry.html')
|
||||
context = {'trip': tripForm.cleaned_data,
|
||||
'persons': personTripFormSet.cleaned_data,
|
||||
'date': dateStr,
|
||||
'expeditionyear': expeditionyear}
|
||||
f.write(template.render(context))
|
||||
f.close()
|
||||
print(logbookparsers.parseAutoLogBookEntry(filename))
|
||||
return HttpResponseRedirect(reverse('expedition', args=[expedition.year])) # Redirect after POST
|
||||
else:
|
||||
if pslug:
|
||||
pass
|
||||
else:
|
||||
fileform = UploadFileForm() # An unbound form
|
||||
|
||||
return render(request, 'editfile.html', {'fileForm': fileform, })
|
||||
|
||||
@login_required_if_public
|
||||
def scanupload(request, year='2050'):
|
||||
print(f'! - FORM scanupload - start')
|
||||
|
||||
Reference in New Issue
Block a user