diff --git a/core/TESTS/tests.py b/core/TESTS/tests.py index 4d22596..d8143b5 100644 --- a/core/TESTS/tests.py +++ b/core/TESTS/tests.py @@ -1,4 +1,4 @@ -""" +''' We are using unittest for troggle. Note that the database has not been parsed from the source files when these tests are run, @@ -17,7 +17,12 @@ which rely on database resolution will fail unless a fixture has been set up for them. https://docs.djangoproject.com/en/3.0/topics/testing/tools/ -""" +''' + + +todo = '''ADD TESTS when we are redirecting /expofiles/ to a remote file-delivering site +''' + import unittest import re from django.test import TestCase, SimpleTestCase, Client diff --git a/core/admin.py b/core/admin.py index c71f4f6..0b5ecad 100644 --- a/core/admin.py +++ b/core/admin.py @@ -4,7 +4,7 @@ from django.forms import ModelForm from django.http import HttpResponse from django.core import serializers -from troggle.core.views.other import downloadLogbook +from troggle.core.views.other import downloadlogbook from troggle.core.models.troggle import Person, PersonExpedition, Expedition, DataIssue from troggle.core.models.caves import Cave, Area, Entrance, CaveAndEntrance, LogbookEntry, PersonTrip, QM from troggle.core.models.survex import SurvexBlock, SurvexPersonRole, SurvexStation, ScansFolder, SingleScan diff --git a/core/forms.py b/core/forms.py index d2eddd3..0ecca73 100644 --- a/core/forms.py +++ b/core/forms.py @@ -15,9 +15,13 @@ from troggle.core.models.caves import Cave, LogbookEntry, QM, Entrance, CaveAndE Some are not used and need renovating or destroying. ''' +todo = '''Fix UploadFileForm +delete TripForm once working +''' + class CaveForm(ModelForm): '''Only those fields for which we want to override defaults are listed here - the other fields are present on the form, but use the default presentaiton style + the other fields are present on the form, but use the default presentation style ''' official_name = forms.CharField(required = False, widget=forms.TextInput(attrs={'size': '45'})) underground_description = forms.CharField(required = False, widget=forms.Textarea(attrs={'rows':9})) diff --git a/core/views/logbooks.py b/core/views/logbooks.py index 74da4f6..05faa64 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -29,6 +29,9 @@ and for persons: their individual pages and their perseonexpedition pages. It uses the global object TROG to hold some cached pages. ''' +todo = '''Fix the get_person_chronology() display bug. +''' + def personindex(request): persons = Person.objects.all() # From what I can tell, "persons" seems to be the table rows, while "pcols" is the table columns. - AC 16 Feb 09 diff --git a/core/views/other.py b/core/views/other.py index b179f82..cadb609 100644 --- a/core/views/other.py +++ b/core/views/other.py @@ -14,12 +14,29 @@ from troggle.core.models.caves import LogbookEntry, QM, Cave, PersonTrip from .login import login_required_if_public from troggle.core.forms import UploadFileForm -"""Utility functions and code to serve the control panel and individual user's +'''Utility functions and code to serve the control panel and individual user's progress and task list (deprecated as we do not have individual user login). 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. +''' + +def todos(request, module): + '''produces todo text from module + ''' + 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, + 'core/forms': forms} + return render(request,'core/todos.html', {'tododict': tododict}) def troggle404(request): # cannot get this to work. Handler404 in urls.py not right syntax '''Custom 404 page to be used even when Debug=True @@ -44,7 +61,7 @@ def frontpage(request): return render(request,'frontpage.html', locals()) -def controlPanel(request): +def controlpanel(request): jobs_completed=[] if request.method=='POST': if request.user.is_superuser: # expoadmin is both .is_staff and ._is_superuser @@ -67,7 +84,7 @@ def controlPanel(request): return render(request,'controlPanel.html', {'caves':Cave.objects.all(),'expeditions':Expedition.objects.all(),'jobs_completed':jobs_completed}) -def downloadLogbook(request,year=None,extension=None,queryset=None): +def downloadlogbook(request,year=None,extension=None,queryset=None): if year: current_expedition=Expedition.objects.get(year=year) @@ -135,7 +152,7 @@ def ajax_QM_number(request): return HttpResponse(res) @login_required_if_public -def newFile(request, pslug = None): +def newfile(request, pslug = None): ''' not known quite what this was for or where it fits in - original 2006 troggle idea never finished? ''' if pslug: diff --git a/templates/core/todos.html b/templates/core/todos.html new file mode 100644 index 0000000..d6d2d4e --- /dev/null +++ b/templates/core/todos.html @@ -0,0 +1,3 @@ +{% extends "baseapi.html" %} +{% block content %}{% for k, v in tododict.items %}{{k}}: {{v}}

+{% endfor %}{% endblock %} \ No newline at end of file diff --git a/urls.py b/urls.py index bfe8d0f..d3855b8 100644 --- a/urls.py +++ b/urls.py @@ -7,9 +7,9 @@ from django.contrib import admin from django.contrib import auth from django.urls import reverse, resolve -from troggle.core.views import other, caves, statistics, survex +from troggle.core.views import caves, statistics, survex from troggle.core.views.surveys import surveyscansingle, surveyscansfolder, surveyscansfolders, dwgdata, dwgfilesingle, dwgfileupload -from troggle.core.views.other import troggle404, frontpage +from troggle.core.views.other import troggle404, frontpage, todos, controlpanel, frontpage, newfile, downloadlogbook, ajax_QM_number, downloadQMs from troggle.core.views.caves import ent, cavepage from troggle.core.views.logbooks import get_logbook_entries, logbookentry, logbookSearch from troggle.core.views.logbooks import personindex, person, get_people @@ -34,6 +34,9 @@ which is vital to writing code for the webapp. So the URL dispatch is declarativ The API urls return TSV or JSON and are new in July 2020. """ +todo = '''Replace most re_path() with modern and simpler path() +''' + #handler404 = 'troggle.core.views.other.troggle404' # can't get this to work. but 404.html is default anyway # Many of these patterns do not work because troggle spent many years broken and we have @@ -63,7 +66,6 @@ else: trogglepatterns = [ re_path(r'^expofiles/', include(expofilesurls)), - re_path(r'^troggle$', other.frontpage, name="frontpage"), # control panel. Shows recent actions. re_path(r'^caves$', caves.caveindex, name="caveindex"), re_path(r'^indxal.htm$', caves.caveindex, name="caveindex"), # ~420 hrefs to this url in expoweb files re_path(r'^people/?$', personindex, name="personindex"), @@ -88,10 +90,10 @@ trogglepatterns = [ # Logbook entries re_path(r'^logbookentry/(?P.*)/(?P.*)/?$', logbookentry,name="logbookentry"), - re_path(r'^newfile', other.newFile, name="newFile"), # oddly broken, needs investigating more + re_path(r'^newfile', newfile, name="newFile"), # oddly broken, needs investigating more re_path(r'^logbooksearch/(.*)/?$', logbookSearch), - re_path(r'^logbook(?P\d\d\d\d)\.(?P.*)/?$', other.downloadLogbook), - re_path(r'^logbook/?$', other.downloadLogbook, name="downloadlogbook"), + re_path(r'^logbook(?P\d\d\d\d)\.(?P.*)/?$', downloadlogbook), + re_path(r'^logbook/?$', downloadlogbook, name="downloadlogbook"), # Internal. editfile.html template uses these internally re_path(r'^getPeople/(?P.*)', get_people, name = "get_people"), @@ -116,16 +118,18 @@ trogglepatterns = [ re_path(r'^entrance/(?P[^/]+)/(?P[^/]+)/edit/', caves.edit_entrance, name = "editentrance"), re_path(r'^entrance/new/(?P[^/]+)$', caves.edit_entrance, name = "newentrance"), - +# System admin and monitoring re_path(r'^statistics/?$', statistics.stats, name="stats"), re_path(r'^stats/?$', statistics.stats, name="stats"), re_path(r'^pathsreport.*$', statistics.pathsreport, name="pathsreport"), re_path(r'^dataissues/?$', statistics.dataissues, name="dataissues"), - re_path(r'^controlpanel/?$', other.controlPanel, name="controlpanel"), + re_path(r'^troggle$', frontpage, name="frontpage"), # control panel. Shows recent actions. + re_path(r'^todo/(?P.*)$', todos, name="todos"), + re_path(r'^controlpanel/?$', controlpanel, name="controlpanel"), # The survexfile pages - re_path(r'^survexfile/(?P.*?)\.svx$', survex.svx, name="svx"), + re_path(r'^survexfile/(?P.*?)\.svx$', survex.svx, name="svx"), re_path(r'^survexfile/(?P.*?)\.3d$', survex.threed, name="threed"), re_path(r'^survexfile/(?P.*?)\.log$', survex.svxraw), re_path(r'^survexfile/(?P.*?)\.err$', survex.err), @@ -151,8 +155,8 @@ trogglepatterns = [ # QMs pages - must precede other /caves pages re_path(r'^cave/qms/([^/]+)/?$', caves.caveQMs), # blank page usually re_path(r'^cave/(?P[^/]+)/(?P\d\d\d\d)-(?P\d*)(?P[ABCDX]?)?$', caves.qm, name="qm"), - re_path(r'^cave/(?P[^/]+)/qm\.csv/?$', other.downloadQMs, name="downloadqms"), - re_path(r'^newqmnumber/?$', other.ajax_QM_number, ), # blank page if no ch given + re_path(r'^cave/(?P[^/]+)/qm\.csv/?$', downloadQMs, name="downloadqms"), + re_path(r'^newqmnumber/?$', ajax_QM_number, ), # blank page if no ch given # re_path(r'^downloadqms$', other.downloadQMs), # MultiValueDictKeyError # Prospecting Guide document