diff --git a/_test_response_photo_upload.html b/_test_response_photo_upload.html new file mode 100644 index 000000000..916076244 --- /dev/null +++ b/_test_response_photo_upload.html @@ -0,0 +1,63 @@ + + + +
+ + +i.e. without the final '/' + + + + + +
+ + + + + + + diff --git a/core/TESTS/test_imports.py b/core/TESTS/test_imports.py index 322fc9dc3..f28895198 100644 --- a/core/TESTS/test_imports.py +++ b/core/TESTS/test_imports.py @@ -96,6 +96,7 @@ class SimpleTest(SimpleTestCase): import troggle.parsers.QMs import troggle.parsers.scans import troggle.parsers.survex + import troggle.parsers.users import troggle.settings from troggle.parsers.logbooks import GetCaveLookup @@ -106,6 +107,14 @@ class SimpleTest(SimpleTestCase): from django.http import HttpResponse from django.urls import reverse + def test_import_users_urls(self): + import base64 + import json + import os + from cryptography.fernet import Fernet + from pathlib import Path + from django.contrib.auth.models import User + def test_import_urls(self): from django.conf import settings diff --git a/core/TESTS/test_logins.py b/core/TESTS/test_logins.py index 1a153d2f4..9602b9472 100644 --- a/core/TESTS/test_logins.py +++ b/core/TESTS/test_logins.py @@ -187,7 +187,7 @@ class PostTests(TestCase): with open("core/fixtures/test_upload_file.txt", "r") as testf: response = self.client.post( - "/photoupload/", data={"name": "test_upload_file.txt", "renameto": "", "uploadfiles": testf} + "/photoupload", data={"name": "test_upload_file.txt", "renameto": "", "uploadfiles": testf} ) content = response.content.decode() self.assertEqual(response.status_code, HTTPStatus.OK) @@ -224,7 +224,7 @@ class PostTests(TestCase): rename = "RENAMED-FILE.JPG" with open("core/fixtures/test_upload_file.txt", "r") as testf: response = self.client.post( - "/photoupload/", data={"name": "test_upload_file.txt", "renameto": rename, "uploadfiles": testf} + "/photoupload", data={"name": "test_upload_file.txt", "renameto": rename, "uploadfiles": testf} ) content = response.content.decode() self.assertEqual(response.status_code, HTTPStatus.OK) @@ -255,11 +255,11 @@ class PostTests(TestCase): self.assertTrue(u.is_active, "User '" + u.username + "' is INACTIVE") c.login(username=u.username, password="secretword") - response = self.client.post("/photoupload/", data={"photographer": "GussieFinkNottle"}) + response = self.client.post("/photoupload", data={"photographer": "GussieFinkNottle"}) content = response.content.decode() self.assertEqual(response.status_code, HTTPStatus.OK) # with open('_test_response.html', 'w') as f: - # f.write(content) + # f.write(content) for ph in [r"Create new Photographer folder", r"/GussieFinkNottle/"]: phmatch = re.search(ph, content) self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph + "'") diff --git a/core/TESTS/test_parsers.py b/core/TESTS/test_parsers.py index 66e058d55..549095e7c 100644 --- a/core/TESTS/test_parsers.py +++ b/core/TESTS/test_parsers.py @@ -206,7 +206,7 @@ class ImportTest(TestCase): def test_survexfiles(self): # Needs another test with test data - response = self.client.get("/survexfile/caves/") + response = self.client.get("/survexfile/caves") self.assertEqual(response.status_code, HTTPStatus.OK) content = response.content.decode() # with open('_test_response.html', 'w') as f: diff --git a/core/TESTS/test_urls.py b/core/TESTS/test_urls.py index e7a30cfb8..861ae2c3c 100644 --- a/core/TESTS/test_urls.py +++ b/core/TESTS/test_urls.py @@ -141,18 +141,17 @@ class URLTests(TestCase): def test_url_allscans(self): """Test the {% url "allscans" %} reverse resolution - path('survey_scans/', allscans, name="allscans"), # all the scans in all wallets + path('survey_scans', allscans, name="allscans"), # all the scans in all wallets """ reversed_url = reverse('allscans') # NB _ must be written as - if present in name - self.assertEqual(reversed_url, "/survey_scans/") + self.assertEqual(reversed_url, "/survey_scans") def test_url_survexcaveslist(self): """Test the {% url "allscans" %} reverse resolution path('survexfile/caves', survex.survexcaveslist, name="survexcaveslist"), - path('survexfile/caves/', survex.survexcaveslist, name="survexcaveslist"), # auto slash not working """ reversed_url = reverse('survexcaveslist') # NB _ must be written as - if present in name - self.assertEqual(reversed_url, "/survexfile/caves/") + self.assertEqual(reversed_url, "/survexfile/caves") def test_url_threed(self): """Test the {% url "threed" %} reverse resolution diff --git a/core/TESTS/tests.py b/core/TESTS/tests.py index d13e1b09d..4c4638a6c 100644 --- a/core/TESTS/tests.py +++ b/core/TESTS/tests.py @@ -457,7 +457,7 @@ class PageTests(TestCase): def test_page_dwgallfiles_empty_slash(self): # this gets an empty page as the database has not been loaded - response = self.client.get("/dwgfiles/") + response = self.client.get("/dwgfiles") self.assertEqual(response.status_code, HTTPStatus.OK) content = response.content.decode() for ph in [ diff --git a/core/middleware.py b/core/middleware.py index 2b280a1d2..fe68fb2d5 100644 --- a/core/middleware.py +++ b/core/middleware.py @@ -36,6 +36,12 @@ class TroggleAppendSlashMiddleware(MiddlewareMixin): do NOT include troggle.core.middleware.TroggleAppendSlashMiddleware in settings.py + + FURTHER WARNING + If playing about with this, the 301 redirects that it creates will be cached INDEFINITELY by any browser you + used to test it, e.g. /css/main.css with be permanetly redirected to /css/main2.css/ with dreadful + consequences, similarly for any images visited. You have to go into your browser settings and delete all cached + files to recover from this. """ def process_request(self, request): diff --git a/core/views/signup.py b/core/views/signup.py index 7536556f6..bb85e030d 100644 --- a/core/views/signup.py +++ b/core/views/signup.py @@ -23,7 +23,7 @@ from troggle.core.utils import ( write_and_commit, ) from troggle.parsers.users import get_encryptor, ENCRYPTED_DIR, how_many_previous_expos - +from .auth import login_required_if_public """The new user signup form and expo user management system in 2025. """ @@ -50,7 +50,7 @@ def signupok(request): {"year": SIGNUP_YEAR, "dates": SIGNUP_DATES, "signup_user": signup_user, "signedup_people": signedup_people}, ) - +@login_required_if_public def signup(request): """Displays and processes the applicant signup form for the forthcoming expo The user must be logged-on as a personal login and that is @@ -75,11 +75,12 @@ def signup(request): if len(people) == 1: signup_person = people[0] form_read_only = False - # else: + experience = how_many_previous_expos(signup_person) + else: + experience = 0 # No, just make the form read-only. # return HttpResponseRedirect("/accounts/login") - experience = how_many_previous_expos(signup_person) if request.method == "POST": # If the form has been submitted... pageform = ExpoSignupForm(request.POST) # A form bound to the POST data diff --git a/settings.py b/settings.py index 486d4940e..e8a0022ff 100644 --- a/settings.py +++ b/settings.py @@ -113,7 +113,7 @@ FORM_RENDERER = "django.forms.renderers.TemplatesSetting" # Required to customi # see https://docs.djangoproject.com/en/dev/topics/http/middleware/#upgrading-pre-django-1-10-style-middleware # Seriously, read this: https://www.webforefront.com/django/middlewaredjango.html which is MUCH BETTER than the docs -# We are NOT using the home-built SmartAppendSlashMiddleware +# We are NOT using the home-built TroggleAppendSlashMiddleware, NOR are we using the Django system append_slash MIDDLEWARE = [ #'django.middleware.security.SecurityMiddleware', # SECURE_SSL_REDIRECT and SECURE_SSL_HOST # we don't use this "django.middleware.gzip.GZipMiddleware", # not needed when expofiles and photos served by apache @@ -128,11 +128,12 @@ MIDDLEWARE = [ #"troggle.core.middleware.TroggleAppendSlashMiddleware", # modified Feb.2025 ] -WSGI_APPLICATION = "troggle.wsgi.application" # change to asgi as soon as we upgrade to Django 3.0 +WSGI_APPLICATION = "troggle.wsgi.application" # change to asgi as soon as we upgrade to Django 5 ? # Append slash can't work if we have a universal catchall URL rule, and we do because all the handbook files # do not have simple prefix. This is why we used to have an /expoweb/ prefix for everything in the website. -# APPEND_SLASH = True # using django.middleware.common.CommonMiddleware. Pointless, never happens if there is a catchall. -# TROGGLE_APPEND_SLASH = True # this is our middleware: see the code in troggle/core/middleware.py for why we do NOT use it. +# Also site-media etc. +APPEND_SLASH = False # using django.middleware.common.CommonMiddleware which we need for other things (I think). + QM_PATTERN = r"\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]" # Re-enable TinyMCE when Dj upgraded to v3. Also templates/editexpopage.html diff --git a/templates/pagenotfound.html b/templates/pagenotfound.html index 913c092fc..891674e2f 100644 --- a/templates/pagenotfound.html +++ b/templates/pagenotfound.html @@ -41,7 +41,8 @@ Did you mistype the URL '{{ path }}' ? {% endif %}
-
Did you get lost ?
+
{% include "menu.html" %}
diff --git a/templates/svxcaves.html b/templates/svxcaves.html
index 1bea2746e..7c481b656 100644
--- a/templates/svxcaves.html
+++ b/templates/svxcaves.html
@@ -18,7 +18,7 @@
{% empty %}
If you were expecting to see a list of survex files here and a summary table of who did what and when, perhaps
- because you followed a link from the master caves' survex list page which showed that such survex files clearly existed, and yet there is nothing here but a blank; then this will be because
+ because you followed a link from the master caves' survex list page which showed that such survex files clearly existed, and yet there is nothing here but a blank; then this will be because
[a] - this cave has no survex survey files at all, or
[b] - you have run a 'caves' parsing import after running a 'survex' import and the survex data has been blanked out, or
[c] - the survex (.svx) files have been stored on the server in the
diff --git a/templates/wallet_new.html b/templates/wallet_new.html
index 619e0252b..448249f32 100644
--- a/templates/wallet_new.html
+++ b/templates/wallet_new.html
@@ -6,7 +6,7 @@ Upload the survexfile using e.g.
(for a survex file for cave 1623-290). You will cut and paste the survex file data into the window on the form.
-
While still logged-in, go to this page Create Wallet which will take you to the next unused wallet number page, and click the 'Create' button. This will not actually complete +
While still logged-in, go to this page Create Wallet which will take you to the next unused wallet number page, and click the 'Create' button. This will not actually complete the creation of the wallet until you have also set the date for the wallet in the wallet edit form (which will appear when you press 'Create').
While editing the wallet you should enter in the form the url of the survexfile which you have just created at e.g. /survexfile/caves-1623/290/mynewsurvex.svx (see above). diff --git a/templates/wallet_table.html b/templates/wallet_table.html index 3f90152db..ba02e1477 100644 --- a/templates/wallet_table.html +++ b/templates/wallet_table.html @@ -55,7 +55,7 @@ It lists things like "1984AndysNotebook" instead of a wallet identifier, but if "1984AndysNotebook" you will see some of the the notes and sketches scanned from it.
Or look at all the scanned files,
-their wallet names and the drawings that were created using them at Drawings
+their wallet names and the drawings that were created using them at Drawings
which is probably more useful.
{% endfor %}
diff --git a/urls.py b/urls.py
index 695b66c64..4803171e6 100644
--- a/urls.py
+++ b/urls.py
@@ -73,27 +73,44 @@ re_path(