From c39fb3070789c19b870603434560e523166abad4 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 27 Jul 2022 23:22:46 +0300 Subject: [PATCH] new urls and dummy functions and rename --- core/views/scans.py | 23 +++++++++++++++++++++-- templates/base.html | 2 +- urls.py | 19 ++++++++++++------- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/core/views/scans.py b/core/views/scans.py index 770b925..61d988e 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -20,7 +20,26 @@ by looking inside the file before being served. need to check if inavlid query string is invalid, or produces multiple replies and render a user-friendly error page. ''' - + + +def walletslistyear(request, year): + '''Page which displays a list of all the wallets in a specific year + ''' + if year < 1976 or year > 2050: + return render(request, 'errors/generic.html', {'message': 'Year out of range. Must be between 1976 and 2050'}) + else: + year = str(year) + return render(request, 'errors/generic.html', {'message': 'not implemented yet'}) + +def walletslistcave(request, caveid): + '''Page which displays a list of all the wallets attached to a specific cave, e.g. '1623-204' + ''' + g = GetCaveLookup() + if caveid not in g: + return render(request, 'errors/generic.html', {'message': f'Cave identifier not recognised:"{caveid}"'}) + + return render(request, 'errors/generic.html', {'message': 'not implemented yet'}) + def oldwallet(request, path): '''Now called only for non-standard wallet structures for pre-2000 wallets ''' @@ -59,7 +78,7 @@ def scansingle(request, path, file): return render(request, 'errors/generic.html', {'message': message}) -def allwallets(request): +def allscans(request): '''Returns all the wallets in the system, we would like to use the Django queryset SQL optimisation https://docs.djangoproject.com/en/3.2/ref/models/querysets/#prefetch-related to get the related singlescan and survexblock objects but that requires rewriting this to do the query on those, not on diff --git a/templates/base.html b/templates/base.html index 2661123..8f3f562 100644 --- a/templates/base.html +++ b/templates/base.html @@ -31,7 +31,7 @@ 359 | Survex | All Survex | - Scans | + Scans | Upload Scans | Drawings | Upload Drawings | diff --git a/urls.py b/urls.py index e02c4f0..7dba6f6 100644 --- a/urls.py +++ b/urls.py @@ -8,7 +8,7 @@ from django.contrib import auth from django.urls import path, reverse, resolve from troggle.core.views import statistics, survex -from troggle.core.views.scans import scansingle, allwallets, cavewallets +from troggle.core.views.scans import scansingle, allscans, cavewallets, walletslistyear, walletslistcave from troggle.core.views.drawings import dwgallfiles, dwgfilesingle from troggle.core.views.uploads import dwgupload, scanupload, photoupload from troggle.core.views.other import troggle404, frontpage, todos, controlpanel, frontpage @@ -164,13 +164,18 @@ trogglepatterns = [ path('survexfile/', survex.survexcavesingle, name="survexcavessingle"), -# The survey scans in the wallets. This short-cuts SCANS_URL which is not actually used anywhere! - path('survey_scans/', allwallets, name="allwallets"), - path('survey_scans//', scanupload, name="singlewallet"), # replaced singlewallet() - path('survey_scans//', scansingle, name="scansingle"), # works, but html href goes direct to /expofiles/ too - re_path(r'^cave/scans/(?P[^/]+)$', cavewallets, name="cavewallets"), # like allwallets, but for just one cave +# The survey scans in the wallets. This short-cuts SCANS_URL which is not used anymore and is defunct + path('survey_scans/', allscans, name="allscans"), # all the scans in all wallets + path('survey_scans//', scanupload, name="singlewallet"), # replaced singlewallet() + path('survey_scans//', scansingle, name="scansingle"), # works, but html href goes direct to /expofiles/ too + path('cave/scans/', cavewallets, name="cavewallets"), # like allscans, but for just one cave + +# The data about the wallets themselves, not the scans inside tehm + path('wallets/cave/', walletslistcave, name="walletslistcave"), # wallets that are for a specific cave, an identifier + path('wallets/year/', walletslistyear, name="walletslistyear"), # wallets that are for a specific year, as an integer '1985' -# The tunnel and therion drawings files pages + +# The tunnel and therion drawings files pageswalletslistcave path('dwgfiles', dwgallfiles, name="dwgallfiles"), path('dwgfiles/', dwgallfiles, name="dwgallfiles"), path('dwgdataraw/', dwgfilesingle, name="dwgfilesingle"),