summaryrefslogtreecommitdiffstats
path: root/core/views/expo.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/views/expo.py')
-rw-r--r--core/views/expo.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/core/views/expo.py b/core/views/expo.py
index 42ca8a2..a312143 100644
--- a/core/views/expo.py
+++ b/core/views/expo.py
@@ -48,11 +48,11 @@ default_head = '''<head>
<input type=submit value="Search"></li>
</ul>'''
-def expofiles_redirect(request, path):
+def expofiles_redirect(request, filepath):
'''This is used only when running as a test system without a local copy of /expofiles/
when settings.EXPOFILESREMOTE is True
'''
- return redirect(urljoin('http://expo.survex.com/expofiles/', path))
+ return redirect(urljoin('http://expo.survex.com/expofiles/', filepath))
def map(request):
'''Serves unadorned the expoweb/map/map.html file
@@ -70,6 +70,10 @@ def expofilessingle(request, filepath):
'''sends a single binary file to the user, if not found, show the parent directory
If the path actually is a directory, then show that.
'''
+ #print(f' - expofilessingle {filepath}')
+ if filepath =="" or filepath =="/":
+ return expofilesdir(request, settings.EXPOFILES, "")
+
fn=urlunquote(filepath)
fn = Path(settings.EXPOFILES,filepath)
if fn.is_dir():
@@ -77,21 +81,27 @@ def expofilessingle(request, filepath):
if fn.is_file():
return HttpResponse(content=open(fn, "rb"),content_type=getmimetype(filepath)) # any file
else:
- # not a file, so show parent directory
- return expofilesdir(request, Path(fn).parent, Path(filepath).parent)
+ # not a file, so show parent directory - DANGER need to check this is limited to below expofiles
+ if Path(fn).parent == Path(settings.EXPOFILES).parent:
+ return expofilesdir(request, Path(settings.EXPOFILES), Path(filepath).parent)
+ else:
+ return expofilesdir(request, Path(fn).parent, Path(filepath).parent)
def expofilesdir(request, dirpath, filepath):
'''does a directory display. If there is an index.html file we should display that.
- dirpath is a full Path() resolved including lcoal machine /expofiles/
- filepath is a Path() and it does not have /expofiles/ in it
'''
- # print(f' - expofilesdir {dirpath}')
- urlpath = 'expofiles' / Path(filepath)
+ #print(f' - expofilesdir {dirpath} settings.EXPOFILESREMOTE: {settings.EXPOFILESREMOTE}')
+ if filepath:
+ urlpath = 'expofiles' / Path(filepath)
+ else:
+ urlpath = Path('expofiles')
try:
for f in dirpath.iterdir():
pass
except FileNotFoundError:
- print(f' - expofilesdir {dirpath}')
+ #print(f' - expofilesdir error {dirpath}')
return expofilesdir(request, dirpath.parent, filepath.parent)
fileitems = []
@@ -145,7 +155,7 @@ def mediapage(request, subpath=None, doc_root=None):
'''This is for special prefix paths /photos/ /site_media/, /static/ etc.
as defined in urls.py . If given a directory, gives a failure page.
'''
- # print(" - XXXXX_ROOT: {} ...{}".format(doc_root, subpath))
+ #print(" - XXXXX_ROOT: {} ...{}".format(doc_root, subpath))
if doc_root is not None:
filetobeopened = Path(doc_root, subpath)
if filetobeopened.is_dir():