diff --git a/core/forms.py b/core/forms.py index 8abf32a..0cd156f 100644 --- a/core/forms.py +++ b/core/forms.py @@ -150,32 +150,32 @@ def get_name(pe): else: return pe.person.first_name -#class UploadFileForm(forms.Form): -# title = forms.CharField(max_length=50) -# file = forms.FileField() -# html = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30})) -# lon_utm = forms.FloatField(required=False) -# lat_utm = forms.FloatField(required=False) -# slug = forms.CharField(max_length=50) -# date = forms.DateField(required=False) +class UploadFileForm(forms.Form): + title = forms.CharField(max_length=50) + file = forms.FileField() + html = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30})) + lon_utm = forms.FloatField(required=False) + lat_utm = forms.FloatField(required=False) + slug = forms.CharField(max_length=50) + date = forms.DateField(required=False) -# caves = [cave.slug for cave in Cave.objects.all()] -# caves.sort() -# caves = ["-----"] + caves -# cave = forms.ChoiceField([(c, c) for c in caves], required=False) + caves = [cave.slug for cave in Cave.objects.all()] + #caves.sort() + caves = ["-----"] + caves + cave = forms.ChoiceField([(c, c) for c in caves], required=False) -# entrance = forms.ChoiceField([("-----", "Please select a cave"), ], required=False) -# qm = forms.ChoiceField([("-----", "Please select a cave"), ], required=False) + entrance = forms.ChoiceField([("-----", "Please select a cave"), ], required=False) + qm = forms.ChoiceField([("-----", "Please select a cave"), ], required=False) -# expeditions = [e.year for e in Expedition.objects.all()] -# expeditions.sort() -# expeditions = ["-----"] + expeditions -# expedition = forms.ChoiceField([(e, e) for e in expeditions], required=False) + expeditions = [e.year for e in Expedition.objects.all()] + expeditions.sort() + expeditions = ["-----"] + expeditions + expedition = forms.ChoiceField([(e, e) for e in expeditions], required=False) -# logbookentry = forms.ChoiceField([("-----", "Please select an expedition"), ], required=False) + logbookentry = forms.ChoiceField([("-----", "Please select an expedition"), ], required=False) -# person = forms.ChoiceField([("-----", "Please select an expedition"), ], required=False) - -# survey_point = forms.CharField() + person = forms.ChoiceField([("-----", "Please select an expedition"), ], required=False) + + survey_point = forms.CharField() diff --git a/core/views_other.py b/core/views_other.py index 87cf724..0b56786 100644 --- a/core/views_other.py +++ b/core/views_other.py @@ -13,6 +13,7 @@ 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 from troggle.helper import login_required_if_public +from troggle.core.forms import UploadFileForm def showrequest(request): @@ -52,20 +53,6 @@ def frontpage(request): from django.contrib.admin.templatetags import log return render(request,'frontpage.html', locals()) -def todo(request): - message = "no test message" #reverse('personn', kwargs={"name":"hkjhjh"}) - if "reloadexpos" in request.GET: - message = LoadPersonsExpos() - message = "Reloaded personexpos" - if "reloadsurvex" in request.POST: - message = LoadAllSurvexBlocks() - message = "Reloaded survexblocks" - - expeditions = Expedition.objects.order_by("-year") - totallogbookentries = LogbookEntry.objects.count() - return render(request,'index.html', {'expeditions':expeditions, 'all':'all', 'totallogbookentries':totallogbookentries, "message":message}) - - def controlPanel(request): jobs_completed=[] if request.method=='POST': @@ -146,6 +133,7 @@ def eyecandy(request): return def ajax_QM_number(request): + res="" if request.method=='POST': cave=Cave.objects.get(id=request.POST['cave']) print(cave) @@ -214,57 +202,57 @@ def logbook_entry_suggestions(request): @login_required_if_public def newFile(request, pslug = None): -# if pslug: -# previousfile = LogbookEntry.objects.get(slug = pslug, date = previousdate, expedition = expedition) -# assert previousfile.filename + if pslug: + previousfile = LogbookEntry.objects.get(slug = pslug, date = previousdate, expedition = expedition) + assert previousfile.filename 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 = 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 + 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 = 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 -# 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 + 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 return render(request, 'editfile.html', { 'fileForm': fileform, diff --git a/templates/frontpage.html b/templates/frontpage.html index a11b6f7..5f0bf18 100644 --- a/templates/frontpage.html +++ b/templates/frontpage.html @@ -46,12 +46,12 @@ Here you will find information about the {{expedition.objects.count}} expedition
-If you are an expedition member, please sign up using the link to the top right. +You are not logged-in, so not all the pages will be visible and you will not be able to edit anything.
{% endblock content %} {% block margins %} - - + + {% endblock margins %} \ No newline at end of file diff --git a/templates/qm.html b/templates/qm.html index f960197..007dadb 100644 --- a/templates/qm.html +++ b/templates/qm.html @@ -24,7 +24,7 @@Please see the issues tracker on google code. You can contribute new feature requests and bug reports.
- -Julian's work: -
parse 1992-1976 logbooks; (esp top 161)
-detect T/U on log entries;
-name matching and spelling in survex files;
-Improve logbook wikihtml text
- -Other work:
-surf through the tunnel sketches and images
-bugs with all.svx block (double dot) -
render bitmap view of every survex block as a thumbnail
-upload tunnel images and tunnel sketches
-where are the subcaves;
-cave section entrance match for logbook entries
-simplify the survex parsing code (if necessary);
-wiki survex stop linegap between comment lins
-links between logbooks and survex blocks to cave things;
-mini-tree of survexblocks;
-connect sketches to caves to survey blocks and render thumbnailwise;
-all images to start appearing in pages; and so on
- -