From 43c6e2f2e1a462132cacc5d7b6af34a08f5ff585 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 4 Jun 2020 23:00:58 +0100 Subject: [PATCH] dlete todo page, partly fix other url pages --- core/forms.py | 44 ++++++++-------- core/views_other.py | 110 +++++++++++++++++---------------------- templates/frontpage.html | 6 +-- templates/qm.html | 2 +- templates/tasks.html | 11 +--- templates/todo.html | 61 ---------------------- urls.py | 19 ++++--- 7 files changed, 85 insertions(+), 168 deletions(-) delete mode 100644 templates/todo.html 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 @@

Related items

Parent cave: {{qm.found_by.cave|link}} -(todo: add parent survey and parent subcave) +(to do: add parent survey and parent subcave) {% block content %}

Location

diff --git a/templates/tasks.html b/templates/tasks.html index 36d35f4..97a924f 100644 --- a/templates/tasks.html +++ b/templates/tasks.html @@ -12,25 +12,16 @@
  • Upload a photo
  • Record a new trip
  • -

    Your unfinished business

    +

    Unfinished wallets work to do:

    {% for survey in surveys_unfinished %}
  • {{survey|link}}
  • {% endfor %} -

    General unfinished business

    -add wikilinks -

    Caving recommendations

    {% for qm in qms_recommended %}
  • {{qm|link}}
  • {% endfor %} -

    Profile tasks

    - -
  • Dates present on expo
  • -
  • Mugshot
  • -
  • Blurb
  • - {% endblock content %} {% block margins %} diff --git a/templates/todo.html b/templates/todo.html deleted file mode 100644 index 7482b72..0000000 --- a/templates/todo.html +++ /dev/null @@ -1,61 +0,0 @@ -{% extends "base.html" %} -{% load wiki_markup %} - -{% block title %}Cambridge Expeditions to Austria{% endblock %} - -{% block content %} - -

    The unfinished front page

    - - -

    Further work

    - -

    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

    - -

    {{message}}

    - -
    - - -
    - - - -{% endblock %} diff --git a/urls.py b/urls.py index 0044633..523b1a7 100644 --- a/urls.py +++ b/urls.py @@ -22,13 +22,12 @@ admin.autodiscover() actualurlpatterns = patterns('', url(r'^troggle$', views_other.frontpage, name="frontpage"), - url(r'^todo/$', views_other.todo, name="todo"), url(r'^caves/?$', views_caves.caveindex, name="caveindex"), url(r'^people/?$', views_logbooks.personindex, name="personindex"), - url(r'^newqmnumber/?$', views_other.ajax_QM_number, ), - url(r'^lbo_suggestions/?$', logbook_entry_suggestions), + url(r'^newqmnumber/?$', views_other.ajax_QM_number, ), + url(r'^lbo_suggestions/?$', logbook_entry_suggestions), #broken #(r'^person/(?P\d*)/?$', views_logbooks.person), url(r'^person/(?P[A-Z]*[a-z\-\'&;]*)[^a-zA-Z]*(?P[a-z\-\']*[^a-zA-Z]*[A-Z]*[a-z\-&;]*)/?', views_logbooks.person, name="person"), #url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"), @@ -38,14 +37,14 @@ actualurlpatterns = patterns('', url(r'^personexpedition/(?P[A-Z]*[a-z&;]*)[^a-zA-Z]*(?P[A-Z]*[a-zA-Z&;]*)/(?P\d+)/?$', views_logbooks.personexpedition, name="personexpedition"), url(r'^logbookentry/(?P.*)/(?P.*)/?$', views_logbooks.logbookentry,name="logbookentry"), url(r'^newlogbookentry/(?P.*)$', views_logbooks.newLogbookEntry, name="newLogBookEntry"), - url(r'^editlogbookentry/(?P[^/]*)/(?P[^/]*)/(?P[^/]*)/$', views_logbooks.newLogbookEntry, name="editLogBookEntry"), + url(r'^editlogbookentry/(?P[^/]*)/(?P[^/]*)/(?P[^/]*)/$', views_logbooks.newLogbookEntry, name="editLogBookEntry"), # working ! url(r'^deletelogbookentry/(?P[^/]*)/(?P[^/]*)/(?P[^/]*)/$', views_logbooks.deleteLogbookEntry, name="deleteLogBookEntry"), - url(r'^newfile', views_other.newFile, name="newFile"), + url(r'^newfile', views_other.newFile, name="newFile"), # oddly broken, needs investigating more - url(r'^getEntrances/(?P.*)', views_caves.get_entrances, name = "get_entrances"), + url(r'^getEntrances/(?P.*)', views_caves.get_entrances, name = "get_entrances"), #works url(r'^getQMs/(?P.*)', views_caves.get_qms, name = "get_qms"), # no template "get_qms"? - url(r'^getPeople/(?P.*)', views_logbooks.get_people, name = "get_people"), - url(r'^getLogBookEntries/(?P.*)', views_logbooks.get_logbook_entries, name = "get_logbook_entries"), + url(r'^getPeople/(?P.*)', views_logbooks.get_people, name = "get_people"), # fails + url(r'^getLogBookEntries/(?P.*)', views_logbooks.get_logbook_entries, name = "get_logbook_entries"), #works url(r'^cave/new/$', views_caves.edit_cave, name="newcave"), url(r'^cave/(?P[^/]+)/?$', views_caves.cave, name="cave"), @@ -61,8 +60,8 @@ actualurlpatterns = patterns('', #url(r'^cavehref/(.+)$', views_caves.cave, name="cave"),url(r'cave'), url(r'^cave/3d/(?P[^/]+).3d$', views_caves.cave3d, name="cave3d"), -# url(r'^jgtfile/(.*)$', view_surveys.jgtfile, name="jgtfile"), -# url(r'^jgtuploadfile$', view_surveys.jgtuploadfile, name="jgtuploadfile"), + url(r'^jgtfile/(.*)$', view_surveys.jgtfile, name="jgtfile"), + url(r'^jgtuploadfile$', view_surveys.jgtuploadfile, name="jgtuploadfile"), url(r'^cave/(?P[^/]+)/?(?P[^/])$', ent), url(r'^cave/(?P[^/]+)/edit/$', views_caves.edit_cave, name="edit_cave"),