From be0148d146263140961e3e47dccd54bc28827e0a Mon Sep 17 00:00:00 2001
From: Philip Sargent <philip.sargent@klebos.com>
Date: Fri, 30 Apr 2021 21:32:53 +0100
Subject: [PATCH] removing cruft, renaming badly named things

---
 core/TESTS/test_imports.py                    |  2 +-
 core/TESTS/tests_logins.py                    |  4 +-
 core/templatetags/wiki_markup.py              |  2 -
 core/views/caves.py                           |  2 +-
 core/views/logbooks.py                        |  4 +-
 core/views/other.py                           | 10 +-
 templates/base.html                           |  7 +-
 templates/cavebase.html                       |  6 +-
 templates/{editcave2.html => editcave.html}   |  0
 templates/editfile.html                       | 98 -------------------
 templates/expowebbase.html                    | 41 --------
 .../{personindex.html => notablepersons.html} |  0
 templates/personForm.html                     |  6 --
 templates/plainbase.html                      |  8 +-
 templates/qm.html                             |  1 -
 templates/subcave.html                        | 59 -----------
 urls.py                                       |  4 +-
 17 files changed, 17 insertions(+), 237 deletions(-)
 rename templates/{editcave2.html => editcave.html} (100%)
 delete mode 100644 templates/editfile.html
 delete mode 100644 templates/expowebbase.html
 rename templates/{personindex.html => notablepersons.html} (100%)
 delete mode 100644 templates/personForm.html
 delete mode 100644 templates/subcave.html

diff --git a/core/TESTS/test_imports.py b/core/TESTS/test_imports.py
index 38d89ae..155851e 100644
--- a/core/TESTS/test_imports.py
+++ b/core/TESTS/test_imports.py
@@ -96,7 +96,7 @@ class SimpleTest(SimpleTestCase):
         from troggle.core.views.expo import expofiles_redirect, expofilessingle, expopage, editexpopage, mediapage, map, mapfile
         from troggle.core.views.logbooks import expedition, personexpedition, Expeditions_tsvListView, Expeditions_jsonListView
         from troggle.core.views.logbooks import get_logbook_entries, logbookentry, logbookSearch
-        from troggle.core.views.logbooks import personindex, person, get_people
+        from troggle.core.views.logbooks import notablepersons, person, get_people
         from troggle.core.views.other import troggle404, frontpage
         from troggle.core.views.prospect import prospecting
         from troggle.core.views.prospect import prospecting_image
diff --git a/core/TESTS/tests_logins.py b/core/TESTS/tests_logins.py
index 66e69c6..1637a2c 100644
--- a/core/TESTS/tests_logins.py
+++ b/core/TESTS/tests_logins.py
@@ -92,8 +92,8 @@ class PostTests(TestCase):
             content = response.content.decode()
             self.assertEqual(response.status_code, 200)
             self.assertEqual(response.status_code, HTTPStatus.OK)
-            with open('test_up.html', 'w') as f: 
-                f.write(content) 
+            # with open('test_up.html', 'w') as f: 
+                # f.write(content) 
             t    = re.search(r'README.txt', content)
             self.assertIsNone(t, 'Logged in as \'' + u.username + '\' (not staff) but failed to upload file' )
 
diff --git a/core/templatetags/wiki_markup.py b/core/templatetags/wiki_markup.py
index 966853d..7e9a4b1 100644
--- a/core/templatetags/wiki_markup.py
+++ b/core/templatetags/wiki_markup.py
@@ -169,8 +169,6 @@ def wiki_to_html_short(value, autoescape=None):
     value = re.sub(r"\[\[\s*cave:([^\s]+)\s*\s*\]\]", r'<a href="%scave/\1/">\1</a>' % settings.URL_ROOT, value, re.DOTALL)
     #make people links
     value = re.sub(r"\[\[\s*person:(.+)\|(.+)\]\]",r'<a href="%sperson/\1/">\2</a>' % settings.URL_ROOT, value, re.DOTALL)
-    #make subcave links
-    value = re.sub(r"\[\[\s*subcave:(.+)\|(.+)\]\]",r'<a href="%ssubcave/\1/">\2</a>' % settings.URL_ROOT, value, re.DOTALL)
     #make cavedescription links
     value = re.sub(r"\[\[\s*cavedescription:(.+)\|(.+)\]\]",r'<a href="%scavedescription/\1/">\2</a>' % settings.URL_ROOT, value, re.DOTALL)
 
diff --git a/core/views/caves.py b/core/views/caves.py
index b7143cc..229aa57 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -354,7 +354,7 @@ def edit_cave(request, slug=None):
         #versionControlForm = VersionControlCommentForm()
         
     return render(request, 
-                               'editcave2.html', 
+                               'editcave.html', 
                                {'form': form, 'cave': cave, 'message': message,
                                 'caveAndEntranceFormSet': ceFormSet,
                                 #'versionControlForm': versionControlForm
diff --git a/core/views/logbooks.py b/core/views/logbooks.py
index 3181a33..2ec6991 100644
--- a/core/views/logbooks.py
+++ b/core/views/logbooks.py
@@ -31,7 +31,7 @@ It uses the global object TROG to hold some cached pages.
 todo = '''Fix the get_person_chronology() display bug.
 '''
 
-def personindex(request):
+def notablepersons(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
     pcols = [ ]
@@ -45,7 +45,7 @@ def personindex(request):
             if person.bisnotable():
                 notablepersons.append(person)
 
-    return render(request,'personindex.html', {'persons': persons, 'pcols':pcols, 'notablepersons':notablepersons})
+    return render(request,'notablepersons.html', {'persons': persons, 'pcols':pcols, 'notablepersons':notablepersons})
 
 
 def expedition(request, expeditionname):
diff --git a/core/views/other.py b/core/views/other.py
index c721a61..d3d1126 100644
--- a/core/views/other.py
+++ b/core/views/other.py
@@ -33,10 +33,6 @@ todo = '''
     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 newfile() - check on deleted UploadFileForm using the editfile.html template which is about re-submitting 
-    a LBE aka TripReport
-
 '''
 
 def todos(request, module): 
@@ -214,7 +210,7 @@ def scanupload(request, wallet=None):
     '''
     filesaved = False
     actual_saved = []
-    print(f'! - FORM scanupload - start {wallet}')
+    # print(f'! - FORM scanupload - start {wallet}')
     if wallet is None:
         wallet = "2021#01" # improve this later
     if not re.match('(19|20)\d\d:\d\d', wallet):
@@ -248,12 +244,12 @@ def scanupload(request, wallet=None):
             if multiple:
                 for f in multiple:
                     actual_saved.append( fs.save(f.name, content=f) )
-                    print(f'! - FORM scanupload multiple {actual_saved}')
+                    # print(f'! - FORM scanupload multiple {actual_saved}')
             filesaved = True
     
     files = []
     dirs = []
-    print(f'! - FORM scanupload - start {wallet} {dirpath}')
+    # print(f'! - FORM scanupload - start {wallet} {dirpath}')
     try:
         for f in dirpath.iterdir():
             if f.is_dir():
diff --git a/templates/base.html b/templates/base.html
index ccc6982..20d6af5 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -44,7 +44,7 @@
     <a href="/handbook/computing/todo-data.html">tasks to do </a>  |
     <a id="cavesLink" href="{% url "caveindex" %}">caves</a>  |
     <a id="folklink" href="/folk">expoers</a>  |
-    <a id="caversLink" href="{% url "personindex" %}">survey lengths</a>  |
+    <a id="caversLink" href="{% url "notablepersons" %}">survey lengths</a>  |
     <a href="{% url "stats" %}">statistics</a> |
     <a href="{% url "expedition" 2018 %}">Expo2018</a> |
     <a href="{% url "expedition" 2019 %}">Expo2019</a> |
@@ -65,10 +65,7 @@
 
 <div id="related"> 
 {% block related %}
-<script language="javascript">
-	$('#related').remove()
-	/*This is a hack to stop a line appearing because of the empty div border*/
-</script>
+
 {% endblock %}
 </div>
     {% block content %}
diff --git a/templates/cavebase.html b/templates/cavebase.html
index 81fc979..e68b99b 100644
--- a/templates/cavebase.html
+++ b/templates/cavebase.html
@@ -10,11 +10,7 @@
 <link rel="stylesheet" type="text/css" href="{{ settings.JSLIB_URL }}jquery-ui/css/smoothness/jquery-ui.css" />
 <script src="{{ settings.JSLIB_URL }}jquery/jquery.min.js" type="text/javascript"></script>
 <script src="{{ settings.JSLIB_URL }}jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
-<script type="text/javascript">
-	$(function() {
-		$( "#tabs" ).tabs();
-	});
-</script>
+
 {% block extraheaders %}{% endblock %}
 </head>
 <body>
diff --git a/templates/editcave2.html b/templates/editcave.html
similarity index 100%
rename from templates/editcave2.html
rename to templates/editcave.html
diff --git a/templates/editfile.html b/templates/editfile.html
deleted file mode 100644
index b3b53ed..0000000
--- a/templates/editfile.html
+++ /dev/null
@@ -1,98 +0,0 @@
-{% extends "base.html" %}
-{% load csrffaker %} 
-{% block title %}File{% endblock %}
-{% block head %}
-<script>
-	$(function() {
-		$("#id_date").datepicker({dateFormat: "yy-mm-dd"});
-                $("#id_cave").change(function() {
-                         $('#id_entrance').load('{% url "get_entrances" caveslug="" %}' + this.value);
-                                                 });
-                $("#id_cave").change(function() {
-                         $('#id_qm').load('{% url "get_qms" caveslug="" %}' + this.value);
-                                                 });
-                $("#id_expedition").change(function() {
-                         $('#id_logbookentry').load('{% url "get_logbook_entries" expeditionslug="" %}' + this.value);
-                                                 });
-                $("#id_expedition").change(function() {
-                         $('#id_person').load('{% url "get_people" expeditionslug="" %}' + this.value);
-                                                 });
-	});
-
-</script>
-
-<link rel="stylesheet" href="{{ settings.JSLIB_URL }}jquery-ui/css/lightness/jquery-ui.css" type="text/css" media="all" />
-<script src="{{ settings.JSLIB_URL }}jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
-<script src="{{ settings.MEDIA_URL }}js/jquery.formset.min.js" type="text/javascript"></script>
-<!--<script src="{{ settings.TINY_MCE_MEDIA_URL }}tiny_mce.js" type="text/javascript"></script>
--->
-{{ fileForm.media }}
-{% endblock %}
-{% block content %}
-
-<form action="" method="post">{% csrf_token %}
-    {{ fileForm.non_field_errors }}
-    <div class="fieldWrapper">
-        {{ fileForm.title.errors }}
-        <label for="id_title">Title:</label>
-        {{ fileForm.title }}
-    </div>
-    <div class="fieldWrapper">
-        {{ fileForm.slug.errors }}
-        <label for="id_slug">Slug:</label>
-        {{ fileForm.slug }}
-    </div>
-    <div class="fieldWrapper">
-        {{ fileForm.date.errors }}
-        <label for="id_date">Date:</label>
-        {{ fileForm.date }}
-    </div>
-    <div class="fieldWrapper" id="lon_utm">
-        {{ fileForm.lon_utm.errors }}
-        <label for="id_lon_utm">Longitude:</label>
-        {{ fileForm.lon_utm }}
-    </div>
-    <div class="fieldWrapper" id="lat_utm">
-        {{ fileForm.lat_utm.errors }}
-        <label for="id_lat_utm">Latitude:</label>
-        {{ fileForm.lat_utm }}
-    </div>
-    <div class="fieldWrapper" id="cave">
-        {{ fileForm.cave.errors }}
-        <label for="id_cave">Cave:</label>
-        {{ fileForm.cave }}
-    </div>
-    <div class="fieldWrapper" id="entrance">
-        {{ fileForm.entrance.errors }}
-        <label for="id_entrance">Entrance:</label>
-        {{ fileForm.entrance }}
-    </div>
-    <div class="fieldWrapper" id="qm">
-        {{ fileForm.qm.errors }}
-        <label for="id_cavem">QM:</label>
-        {{ fileForm.qm }}
-    </div>
-    <div class="fieldWrapper" id="expedition">
-        {{ fileForm.expedition.errors }}
-        <label for="id_expediton">Expedition:</label>
-        {{ fileForm.expedition }}
-    </div>
-    <div class="fieldWrapper" id="logbookentry">
-        {{ fileForm.logbookentry.errors }}
-        <label for="id_logbookentry">Logbook Entry:</label>
-        {{ fileForm.logbookentry }}
-    </div>
-    <div class="fieldWrapper" id="person">
-        {{ fileForm.person.errors }}
-        <label for="id_expediton">Person:</label>
-        {{ fileForm.person }}
-    </div>
-    <div class="fieldWrapper">
-        {{ fileForm.html.errors }}
-        <label for="id_date">Content:</label>
-        {{ fileForm.html }}
-    </div>
-    <p><input type="submit" value="Submit Trip Report" /></p>
-</form>
-
-{% endblock %}
diff --git a/templates/expowebbase.html b/templates/expowebbase.html
deleted file mode 100644
index 097c4e0..0000000
--- a/templates/expowebbase.html
+++ /dev/null
@@ -1,41 +0,0 @@
-<!DOCTYPE html>
-<!-- expowebbase.html - this text visible because this template has been included -->
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>{% block title %}{% endblock %}
-</title>
-<link rel="stylesheet" type="text/css" href="../css/main2.css" />
-</head>
-<body>
-<div id="mainmenu">
-<ul>
-<li><a href="/index.htm">Expo website home</a></li>
-<li><a href="/intro.html">Introduction</a></li>
-<li><a href="/infodx.htm">Main index</a></li>
-<li><a href="/caves">Cave index</a></li>
-{% if cavepage %}
-<ul>
-<li><a href="{% url "survexcaveslist" %}">All Survex</a></li>
-<li><a href="{% url "allwallets" %}">Scans</a></li>
-<li><a href="{% url "dwgdata" %}">Drawings</a></li>
-<li><a href="{% url "survexcavessingle" "caves-1623/290/290.svx" %}">290</a></li>
-<li><a href="{% url "survexcavessingle" "caves-1623/291/291.svx" %}">291</a></li>
-<li><a href="{% url "survexcavessingle" "caves-1626/359/359.svx" %}">359</a></li>
-<li><a href="{% url "survexcavessingle" "caves-1623/258/258.svx" %}">258</a></li>
-<li><a href="{% url "survexcavessingle" "caves-1623/264/264.svx" %}">264</a></li>
-<li><a href="{% url "expedition" 2018 %}">Expo2018</a></li>
-<li><a href="{% url "expedition" 2019 %}">Expo2019</a></li>
-<li><a href="/admin">Django admin</a></li>
-</ul>
-{% endif %}
-<li><a href="/handbook/index.htm">Expedition handbook</a></li>
-<li><a href="/pubs.htm">Published reports</a></li>
-<li><a href="/areas.htm">Area description</a></li>
-<li><a href="/">CUCC website</a></li>
-</ul>
-</div>
-{% block content %}{% endblock %}
-</body>
-</html>
-
diff --git a/templates/personindex.html b/templates/notablepersons.html
similarity index 100%
rename from templates/personindex.html
rename to templates/notablepersons.html
diff --git a/templates/personForm.html b/templates/personForm.html
deleted file mode 100644
index 4577239..0000000
--- a/templates/personForm.html
+++ /dev/null
@@ -1,6 +0,0 @@
-{% extends "base.html" %}
-{% block content %}
-
-{{ form }}
-
-{% endblock %}
\ No newline at end of file
diff --git a/templates/plainbase.html b/templates/plainbase.html
index afeb8f9..5b209cf 100644
--- a/templates/plainbase.html
+++ b/templates/plainbase.html
@@ -1,4 +1,6 @@
 {% autoescape off %}
+<!-- svxfile.html - this text visible because this template has been included -->
+<!-- This is ONLY used by templates/prospecting.html -->
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@@ -7,11 +9,7 @@
 <link rel="stylesheet" type="text/css" href="{{ settings.JSLIB_URL }}jquery-ui/css/smoothness/jquery-ui.css" />
 <script src="{{ settings.JSLIB_URL }}jquery/jquery.min.js" type="text/javascript"></script>
 <script src="{{ settings.JSLIB_URL }}jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
-<script type="text/javascript">
-	$(function() {
-		$( "#tabs" ).tabs();
-	});
-</script>
+
 {% block extrahead %}{% endblock %}
 </head>
 <body {% block bodyattrs %}{% endblock %}>
diff --git a/templates/qm.html b/templates/qm.html
index 86ec2b5..58f040a 100644
--- a/templates/qm.html
+++ b/templates/qm.html
@@ -23,7 +23,6 @@
 <h2>Related items</h2>
   
 Parent cave: {{qm.found_by.cave|link}}
-(to do: add parent survey and parent subcave)
 {% block content %}
 
 <h3>Location</h3>
diff --git a/templates/subcave.html b/templates/subcave.html
deleted file mode 100644
index 28023b1..0000000
--- a/templates/subcave.html
+++ /dev/null
@@ -1,59 +0,0 @@
-{% extends "cavebase.html" %}
-
-{% load mptt_tags %}
-{% block title %} Subcave {{subcave}} {% endblock title %}
-{% block editLink %}<a href={{subcave.get_admin_url}}>Edit subcave {{subcave|wiki_to_html_short}}</a>{% endblock %}
-
-{% block contentheader %}
-	{{subcave.title}}
-{% endblock contentheader %}
-
-
-
-{% block content %}
-{% block related %}
-
-  <h2>Related places</h2>
-  
-  <h3>Parent</h3>
-  
-  <ul>
-   	{% if subcave.parent %}
-	    <li><a href="{{subcave.parent.get_absolute_url}}">{{subcave.parent}}</a></li>
-    {% else %}    
-	    <li><a href="{{subcave.cave.get_absolute_url}}">{{subcave.cave}}</a></li>
-    {% endif %}
-  </ul>
-  
-  <h3>Connected subareas</h3>
-  
-  <ul>
-  	{% for sibling in subcave.adjoining.all%}
-	    <li><a href="{{sibling.get_absolute_url}}">{{silbling}}</a></li>
-    {% endfor %}
-  </ul>
-  
-  <h3>Children</h3>
-
-  <ul>
-  	{% for child in subcave.children.all %}
-	    <li><a href="{{child.get_absolute_url}}">{{child}}</a></li>
-    {% endfor %}    
-  </ul>
-
-
-{% endblock %}
-
-ok here comes the drilldown<br />
-{% drilldown_tree_for_node subcave as drilldown %}
-{% for each in drilldown %}
-{{ each }}>
-{% endfor %}
-
-
-<h2>{{subcave}}</h2>
-<p>
-	{{subcave.description}}
-</p>
-
-{% endblock content %}
\ No newline at end of file
diff --git a/urls.py b/urls.py
index 85a9759..3ca192d 100644
--- a/urls.py
+++ b/urls.py
@@ -14,7 +14,7 @@ from troggle.core.views.other import troggle404, frontpage, todos, controlpanel,
 from troggle.core.views.other import exportlogbook
 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
+from troggle.core.views.logbooks import notablepersons, person, get_people
 from troggle.core.views.logbooks import expedition, personexpedition, Expeditions_tsvListView, Expeditions_jsonListView
 from troggle.core.views.prospect import prospecting_image
 from troggle.core.views.prospect import prospecting
@@ -73,7 +73,7 @@ trogglepatterns = [
     
     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"),
+    re_path(r'^people/?$',   notablepersons, name="notablepersons"),
 
     re_path(r'^admin/doc/',  include('django.contrib.admindocs.urls')), # needs docutils Python module (http://docutils.sf.net/).
     re_path(r'^admin/',      admin.site.urls), # includes admin login & logout urls