mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-15 14:07:14 +00:00
tidy trailing slash everywhere & fix tests
This commit is contained in:
66
urls.py
66
urls.py
@@ -73,27 +73,44 @@ re_path( <regular expression that matches the thing in the web browser>,
|
||||
<reference to python function in 'core' folder>, <optional name>)
|
||||
|
||||
Django also provides the reverse function: given an an object, provide the URL
|
||||
which is vital to writing code for the webapp. So the URL dispatch is declarative.
|
||||
which is important to writing code for the webapp. So the URL dispatch is declarative.
|
||||
But this means that two URLs should NOT go to the same python target function,
|
||||
(or only if the target name is different)
|
||||
|
||||
The API urls return TSV or JSON and are new in July 2020.
|
||||
|
||||
CONVENTION
|
||||
Unlike most DJango projects, we have the convention that we do NOT have a terminal slash
|
||||
on the URL of a page which is generated. (Generated pages are neither files not directories.)
|
||||
So the url is "/dwgfiles" not "/dwgfiles/" everywhere, and similarly for "/walletedit" etc.
|
||||
This is important in troggle because we do NOT universally use the reverse() function
|
||||
or the url() function to get the URL from the declarations in this url.py file.
|
||||
The reason is that url() requires quite a wide knowledge of troggle, whereas explicit
|
||||
urls can be done by beginner maintainers and work (but do add to future maintenance).
|
||||
|
||||
NOTE
|
||||
- The admin and logout paths need to stay using re_path() as they
|
||||
have to be locked to the start.
|
||||
|
||||
- admin and login forms are provided by Django so we have to fit in to their conventions.
|
||||
|
||||
- The final _edit and CATCHALL also have to use re_path().
|
||||
|
||||
|
||||
Many of these patterns do not work because troggle spent many years broken and we have
|
||||
not yet restored all the functions. Some may have never been fully implemented in
|
||||
the first place and what they were intended to provide is obscure.
|
||||
|
||||
Some short names such as indxal.htm date from the Archimedes-era when filenames had to be less
|
||||
than 10-chars long.
|
||||
"""
|
||||
|
||||
todo = '''
|
||||
- Replace more re_path() with modern and simpler path(). Careful: some have to stay as re_path()
|
||||
|
||||
- The admin and logout paths need to stay using re_path() as they
|
||||
have to be locked to the start.
|
||||
|
||||
- The final _edit and CATCHALL also have to use re_path().
|
||||
|
||||
- Test VERY CAREFULLY for each change. It is fragile.
|
||||
'''
|
||||
|
||||
# Many of these patterns do not work because troggle spent many years broken and we have
|
||||
# not yet restored all the functions. Some may have never been fully implemented in
|
||||
# the first place and what they were intended to provide is obscure.
|
||||
|
||||
|
||||
# WHen running on the server, apache intercepts all the /expofiles/ files so troggle never sees them,
|
||||
@@ -134,18 +151,18 @@ trogglepatterns = [
|
||||
path('entrances', entranceindex, name="entranceindex"),
|
||||
|
||||
re_path(r'^admin/doc/', include('django.contrib.admindocs.urls')), # needs docutils Python module (http://docutils.sf.net/).
|
||||
path('admin/', admin.site.urls), # includes admin login & logout urls & /admin/jsi18n/
|
||||
path('admin/', admin.site.urls), # includes admin login & logout urls & /admin/jsi18n/ NOTE TERMINAL SLASH
|
||||
|
||||
# Uploads - uploading a file
|
||||
path('walletedit/', walletedit, name='walletedit'), # not just an upload, also edit metadata
|
||||
path('walletedit', walletedit, name='walletedit'), # not just an upload, also edit metadata
|
||||
path('walletedit/<path:path>', walletedit, name='walletedit'), # path=2020#01
|
||||
path('photoupload/', photoupload, name='photoupload'), # restricted to current year
|
||||
path('photoupload', photoupload, name='photoupload'), # restricted to current year
|
||||
path('photoupload/<path:folder>', photoupload, name='photoupload'), # restricted to current year
|
||||
path('gpxupload/', gpxupload, name='gpxupload'), # restricted to current year
|
||||
path('gpxupload', gpxupload, name='gpxupload'), # restricted to current year
|
||||
path('gpxupload/<path:folder>', gpxupload, name='gpxupload'), # restricted to current year
|
||||
path('dwgupload/<path:folder>', dwgupload, name='dwgupload'),
|
||||
path('dwgupload/', dwgupload, name='dwgupload'),
|
||||
path('dwguploadnogit/', dwgupload, {'gitdisable': 'yes'}, name='dwguploadnogit'), # used in testing
|
||||
path('dwgupload', dwgupload, name='dwgupload'),
|
||||
path('dwguploadnogit', dwgupload, {'gitdisable': 'yes'}, name='dwguploadnogit'), # used in testing
|
||||
path('dwguploadnogit/<path:folder>', dwgupload, {'gitdisable': 'yes'}, name='dwguploadnogit'), # used in testing
|
||||
path('logbookedit/', logbookedit, name='logbookedit'),
|
||||
path('logbookedit/<slug:slug>', logbookedit, name='logbookedit'),
|
||||
@@ -175,7 +192,7 @@ trogglepatterns = [
|
||||
# /home/philip/expo/troggle/.venv/lib/python3.xx/site-packages/django/contrib/admin/sites.py
|
||||
|
||||
# setting LOGIN_URL = '/accounts/login/' is default.
|
||||
# NB setting url pattern name to 'login' instea dof 'expologin' with override Django, see https://docs.djangoproject.com/en/dev/topics/http/urls/#naming-url-patterns
|
||||
# NB setting url pattern name to 'login' instead of 'expologin' with override Django, see https://docs.djangoproject.com/en/dev/topics/http/urls/#naming-url-patterns
|
||||
path('accounts/logout/', expologout, name='expologout'), # same as in django.contrib.auth.urls
|
||||
path('accounts/login/', expologin, name='expologin'), # same as in django.contrib.auth.urls
|
||||
path("accounts/register/<slug:url_username>", register, name="re_register"), # overriding django.contrib.auth.urls
|
||||
@@ -204,14 +221,14 @@ trogglepatterns = [
|
||||
# Internal. editfile.html template uses these internally
|
||||
re_path(r'^getPeople/(?P<expeditionslug>.*)', get_people, name = "get_people"),
|
||||
re_path(r'^getLogBookEntries/(?P<expeditionslug>.*)', get_logbook_entries, name = "get_logbook_entries"),
|
||||
re_path(r'^getEntrances/(?P<caveslug>.*)', get_entrances, name = "get_entrances"), # used internally ?
|
||||
re_path(r'^getEntrances/(?P<caveslug>.*)', get_entrances, name = "get_entrances"),
|
||||
|
||||
# Cave description pages
|
||||
path('cave/<slug:slug>', caveslugfwd, name="caveslugfwd"),
|
||||
path('cave_debug', cave_debug, name="cave_debug"),
|
||||
path('kataster/<slug:slug>', kataster, name="kataster"),
|
||||
path('kataster', kataster, name="kataster"),
|
||||
path('fix/<slug:areacode>', fix, name="fix"),
|
||||
path('kataster/<slug:slug>', kataster, name="kataster"), # for renaming a cave from e.g. 1623-2005-05 to 1623-264
|
||||
path('kataster', kataster, name="kataster"), # illustrative placeholder for kataster renaming
|
||||
path('fix/<slug:areacode>', fix, name="fix"), # one-off fix misplaced images and descriptive files
|
||||
re_path(r'^newcave/$', edit_cave, name="newcave"),
|
||||
re_path(r'^cave/3d/(?P<cave_id>[^/]+).3d$', cave3d, name="cave3d"),
|
||||
|
||||
@@ -251,9 +268,7 @@ trogglepatterns = [
|
||||
path('survexdir', survex.survexdir, name="survexdir"),
|
||||
|
||||
path('survexfile', survex.survexcavesingle, {'cave_shortname': ''}, name="survexcavessingle"),
|
||||
path('survexfile/', survex.survexcavesingle, {'cave_shortname': ''}, name="survexcavessingle"),
|
||||
path('survexfile/caves', survex.survexcaveslist, name="survexcaveslist"),
|
||||
path('survexfile/caves/', survex.survexcaveslist, name="survexcaveslist"), # auto slash not working
|
||||
|
||||
path('survexfile/<path:survex_file>.svx', survex.svx, name="svx"),
|
||||
path('survexfile/<path:survex_file>.3d', survex.threed, name="threed"),
|
||||
@@ -262,11 +277,10 @@ trogglepatterns = [
|
||||
path('survexfile/<path:cave_shortname>', survex.survexcavesingle, name="survexcavessingle"),
|
||||
|
||||
path('survexfilewild', statistics.svxfilewild, name="svxfilewild"),
|
||||
path('survexfilewild/', statistics.svxfilewild, name="svxfilewild"),
|
||||
path('survexfilewild/<int:year>', statistics.svxfilewild, name="svxfilewild"),
|
||||
|
||||
# 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', allscans, name="allscans"), # all the scans in all wallets
|
||||
path('survey_scans/<path:path>/', walletedit, name="singlewallet"), # replaced singlewallet()
|
||||
path('survey_scans/<path:path>/<file>', scansingle, name="scansingle"), # works, but html href goes direct to /expofiles/ too
|
||||
path('cave/scans/<slug:caveid>', cavewallets, name="cavewallets"), # like allscans, but for just one cave
|
||||
@@ -277,9 +291,7 @@ trogglepatterns = [
|
||||
|
||||
# The tunnel and therion drawings files pageswalletslistcave
|
||||
path('drawings', dwgallfiles, name="dwgallfiles"),
|
||||
path('drawings/', dwgallfiles, name="dwgallfiles"),
|
||||
path('dwgfiles', dwgallfiles, name="dwgallfiles"),
|
||||
path('dwgfiles/', dwgallfiles, name="dwgallfiles"),
|
||||
path('dwgdataraw/<path:path>', dwgfilesingle, name="dwgfilesingle"),
|
||||
|
||||
# QMs pages - must precede other /caves pages?
|
||||
@@ -315,7 +327,7 @@ trogglepatterns = [
|
||||
# Final catchall which also serves expoweb handbook pages and imagestiny
|
||||
# but a universal catchall also prevents the djang standard append_slash working, as every string resolves.
|
||||
# try to fix in troggle/middleware.py
|
||||
re_path(r'^(.*)$', expopage, name="expopage"), # CATCHALL assumed relative to EXPOWEB
|
||||
re_path(r'^(.*)$', expopage, name="expopage"), # CATCHALL assumed relative to EXPOWEB. This means APPEND_SLASH never works.
|
||||
]
|
||||
|
||||
# do NOT allow DIR_ROOT prefix to all urls
|
||||
|
||||
Reference in New Issue
Block a user