From cacae6a9cd40828ca03671d47f2fc70306f16d8d Mon Sep 17 00:00:00 2001
From: Philip Sargent <philip.sargent@klebos.com>
Date: Tue, 30 Mar 2021 21:05:27 +0100
Subject: [PATCH] rename flatpages as expopages to reduce confusion

---
 core/TESTS/tests.py                            |  2 +-
 core/management/commands/reset_db.py           |  2 +-
 core/view_surveys.py                           |  2 +-
 databaseReset.py                               | 10 +++++-----
 {flatpages => expopages}/__init__.py           |  0
 {flatpages => expopages}/admin.py              |  2 +-
 .../migrations/__init__.py                     |  0
 {flatpages => expopages}/models.py             |  0
 {flatpages => expopages}/views.py              | 18 +++++++++---------
 logbooksdump.py                                |  2 +-
 settings.py                                    |  4 ++--
 urls.py                                        |  4 ++--
 12 files changed, 23 insertions(+), 23 deletions(-)
 rename {flatpages => expopages}/__init__.py (100%)
 rename {flatpages => expopages}/admin.py (60%)
 rename {flatpages => expopages}/migrations/__init__.py (100%)
 rename {flatpages => expopages}/models.py (100%)
 rename {flatpages => expopages}/views.py (95%)

diff --git a/core/TESTS/tests.py b/core/TESTS/tests.py
index 85d6c44..f5645be 100644
--- a/core/TESTS/tests.py
+++ b/core/TESTS/tests.py
@@ -70,7 +70,7 @@ class SimpleTest(SimpleTestCase):
     def test_import_parses_mix(self):
         from troggle.parsers.logbooks import GetCaveLookup
         import troggle.settings
-        #import troggle.flatpages.models
+        #import troggle.expopages.models
         import troggle.logbooksdump
         import troggle.parsers.caves
         import troggle.parsers.people
diff --git a/core/management/commands/reset_db.py b/core/management/commands/reset_db.py
index 2aea94a..c7cfd7a 100644
--- a/core/management/commands/reset_db.py
+++ b/core/management/commands/reset_db.py
@@ -8,7 +8,7 @@ from django.core.management.base import BaseCommand, CommandError
 from django.contrib.auth.models import User
 
 from troggle.core.models import Cave, Entrance
-import troggle.flatpages.models
+import troggle.expopages.models
 
 import settings
 
diff --git a/core/view_surveys.py b/core/view_surveys.py
index 6aaa9dc..dcec1c2 100644
--- a/core/view_surveys.py
+++ b/core/view_surveys.py
@@ -9,7 +9,7 @@ from django.shortcuts import render
 from django.http import HttpResponse, Http404
 
 from troggle.core.models_survex import ScansFolder, SingleScan, SurvexBlock, TunnelFile
-from troggle.flatpages import views as flatviews
+from troggle.expopages import views as flatviews
 import parsers.surveys
 
 '''Some of these views serve files as binary blobs, and simply set the mime type based on the file extension,
diff --git a/databaseReset.py b/databaseReset.py
index bf91ccf..34529a5 100644
--- a/databaseReset.py
+++ b/databaseReset.py
@@ -33,7 +33,7 @@ except:
     raise
 print(" - Memory footprint after loading Django: {:.3f} MB".format(resource.getrusage(resource.RUSAGE_SELF)[2]/1024.0))
 
-import troggle.flatpages.models
+import troggle.expopages.models
 import troggle.core.models
 import troggle.core.models_survex
 
@@ -97,16 +97,16 @@ def reinit_db():
     if django.db.connections.databases['default']['ENGINE'] == 'django.db.backends.sqlite3':
         with transaction.atomic():
             management.call_command('makemigrations','core', interactive=False)
-            management.call_command('makemigrations','flatpages', interactive=False)
+            management.call_command('makemigrations','expopages', interactive=False)
             management.call_command('migrate', interactive=False)
             management.call_command('migrate','core', interactive=False)
-            management.call_command('migrate','flatpages', interactive=False)
+            management.call_command('migrate','expopages', interactive=False)
     else:
         management.call_command('makemigrations','core', interactive=False)
-        management.call_command('makemigrations','flatpages', interactive=False)
+        management.call_command('makemigrations','expopages', interactive=False)
         management.call_command('migrate', interactive=False)
         management.call_command('migrate','core', interactive=False)
-        management.call_command('migrate','flatpages', interactive=False)
+        management.call_command('migrate','expopages', interactive=False)
 
     
     print(" - done migration on: " + settings.DATABASES['default']['NAME'])
diff --git a/flatpages/__init__.py b/expopages/__init__.py
similarity index 100%
rename from flatpages/__init__.py
rename to expopages/__init__.py
diff --git a/flatpages/admin.py b/expopages/admin.py
similarity index 60%
rename from flatpages/admin.py
rename to expopages/admin.py
index ddb9ab2..91caa9c 100644
--- a/flatpages/admin.py
+++ b/expopages/admin.py
@@ -1,4 +1,4 @@
-#from troggle.flatpages.models import Redirect, EntranceRedirect
+#from troggle.expopages.models import Redirect, EntranceRedirect
 from django.contrib import admin
 
 # admin.site.register(Redirect)
diff --git a/flatpages/migrations/__init__.py b/expopages/migrations/__init__.py
similarity index 100%
rename from flatpages/migrations/__init__.py
rename to expopages/migrations/__init__.py
diff --git a/flatpages/models.py b/expopages/models.py
similarity index 100%
rename from flatpages/models.py
rename to expopages/models.py
diff --git a/flatpages/views.py b/expopages/views.py
similarity index 95%
rename from flatpages/views.py
rename to expopages/views.py
index 9ab69de..0567229 100644
--- a/flatpages/views.py
+++ b/expopages/views.py
@@ -56,15 +56,15 @@ def flatpage(request, path):
     
     This is a horrible mess and some code is redundant and unreachable because of urls.py setup
     '''
-    # print(" - FLATPAGES delivering the file: {} as MIME type: {}".format(path,getmimetype(path)),flush=True)
+    # print(" - EXPOPAGES delivering the file: {} as MIME type: {}".format(path,getmimetype(path)),flush=True)
 
     if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated():
-        # print((" - FLATPAGES redirect to logon: flat path noinfo", path))
+        # print((" - EXPOPAGES redirect to logon: flat path noinfo", path))
         return HttpResponseRedirect(urljoin(reverse("auth_login"),'?next={}'.format(request.path)))
 
     expowebpath = Path(settings.EXPOWEB)
     if path.endswith("/") or path == "":
-        # print(" - FLATPAGES the file: {} ENDSWITH ...".format(path))
+        # print(" - EXPOPAGES the file: {} ENDSWITH ...".format(path))
 
         try:
             o = open(os.path.normpath(expowebpath / path / "index.html"), "rb")
@@ -76,7 +76,7 @@ def flatpage(request, path):
             except IOError:
                 return render(request, 'pagenotfound.html', {'path': path})
     else:
-        # print(" - FLATPAGES the file: '{}'  ...".format(path))
+        # print(" - EXPOPAGES the file: '{}'  ...".format(path))
         if path.startswith('site_media'):
             # print(" - MEDIA_ROOT: {}  ...{}".format(settings.MEDIA_ROOT, path))
             path = path.replace("site_media", settings.MEDIA_ROOT)
@@ -89,12 +89,12 @@ def flatpage(request, path):
             # print(" - NO    _ROOT: {}  ...".format(expowebpath))
             filetobeopened = os.path.normpath(expowebpath / path)
         
-        # print(" - FLATPAGES full path : {}  ...".format(filetobeopened))
+        # print(" - EXPOPAGES full path : {}  ...".format(filetobeopened))
         try:
             o = open(filetobeopened, "rb")
-            #print(" - FLATPAGES full path no error: {}  ...".format(filetobeopened))
+            #print(" - EXPOPAGES full path no error: {}  ...".format(filetobeopened))
         except IOError:
-            #print(" - FLATPAGES ERROR: {}  ...".format(filetobeopened))
+            #print(" - EXPOPAGES ERROR: {}  ...".format(filetobeopened))
             #o.close() 
             return render(request, 'pagenotfound.html', {'path': path})
  
@@ -108,7 +108,7 @@ def flatpage(request, path):
         if m:
             preheader, headerattrs, head, postheader, bodyattrs, body, postbody = m.groups()
         else:
-            return HttpResponse(html + "HTML Parsing failure: Page could not be split into header and body: failed in flatpages.views.py")
+            return HttpResponse(html + "HTML Parsing failure: Page could not be split into header and body: failed in expopages.views.py")
         m = re.search(rb"<title>(.*)</title>", head, re.DOTALL + re.IGNORECASE)
         if m:
             title, = m.groups()
@@ -134,7 +134,7 @@ def flatpage(request, path):
         return render(request, 'flatpage.html', {'editable': editable, 'path': path, 'title': title, 
                     'body': body, 'homepage': (path == "index.htm"), 'has_menu': has_menu})
     else:
-        # print(" - FLATPAGES delivering the file: {} as MIME type: {}".format(path,getmimetype(path)))
+        # print(" - EXPOPAGES delivering the file: {} as MIME type: {}".format(path,getmimetype(path)))
         return HttpResponse(content=open(filetobeopened, "rb"), content_type=getmimetype(path))
         #return HttpResponse(content=open(singlescan.ffile,"rb"), content_type=getmimetype(path))
 
diff --git a/logbooksdump.py b/logbooksdump.py
index 6877afd..bdd1cb1 100644
--- a/logbooksdump.py
+++ b/logbooksdump.py
@@ -19,7 +19,7 @@ from django.http import HttpResponse
 from django.urls import reverse
 
 from troggle.core.models_caves import Cave, Entrance
-import troggle.flatpages.models
+import troggle.expopages.models
 
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 def import_auto_logbooks():
diff --git a/settings.py b/settings.py
index 80fb84b..5c8a8fb 100644
--- a/settings.py
+++ b/settings.py
@@ -120,10 +120,10 @@ INSTALLED_APPS = (
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.admindocs',
-#    'django.contrib.staticfiles', # Using workarounds with flatpages
+#    'django.contrib.staticfiles', # Using workarounds with expopages
     'registration', # only for expo user. REPLACE using django.contrib.auth
     'troggle.core',
-    'troggle.flatpages', # Written by Martin Green 2011. This is NOT django.contrib.flatpages which stores HTML in the database
+    'troggle.expopages', # Written by Martin Green 2011. This is NOT django.contrib.flatpages which stores HTML in the database
 )
 
 # See the recommended order of these in https://docs.djangoproject.com/en/2.2/ref/middleware/
diff --git a/urls.py b/urls.py
index 8143d7a..85f5ad9 100644
--- a/urls.py
+++ b/urls.py
@@ -10,7 +10,7 @@ from troggle.core import views_other, views_caves, views_logbooks, views_statist
 from troggle.core.views_other import troggle404
 from troggle.core.views_caves import ent, prospecting_image
 from troggle.core.views_statistics import pathsreport, stats
-from flatpages import views as flatviews
+from expopages import views as flatviews
 """This sets the actualurlpatterns[] and urlpatterns[] lists which django uses 
 to resolve urls - in both directions as these are declarative. 
 
@@ -83,7 +83,7 @@ actualurlpatterns = [
 
     url(r'^cave/new/$', views_caves.edit_cave, name="newcave"),
     url(r'^cave/(?P<cave_id>[^/]+)/?$', views_caves.cave, name="cave"),
-    url(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent), # how can this work?
+    url(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent), # view_caves.ent
     url(r'^cave/(?P<slug>[^/]+)/edit/$', views_caves.edit_cave, name="edit_cave"),
     url(r'^cave/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d*)(?P<grade>[ABCDX]?)?$', views_caves.qm, name="qm"),