diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2025-03-03 00:16:07 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2025-03-03 00:16:07 +0000 |
commit | ec3f513308c7e2c5ff6aef8535d3d28f5f785313 (patch) | |
tree | 6cbcaaffdac2d892e5a8eb6ac03c12184fbdf217 /core | |
parent | ab8d5271634e4f86cb619773b25d7bfd61847e37 (diff) | |
download | troggle-ec3f513308c7e2c5ff6aef8535d3d28f5f785313.tar.gz troggle-ec3f513308c7e2c5ff6aef8535d3d28f5f785313.tar.bz2 troggle-ec3f513308c7e2c5ff6aef8535d3d28f5f785313.zip |
bugfix in .url file
Diffstat (limited to 'core')
-rw-r--r-- | core/views/editor_helpers.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/core/views/editor_helpers.py b/core/views/editor_helpers.py index 1b4dcf8..e3c0d76 100644 --- a/core/views/editor_helpers.py +++ b/core/views/editor_helpers.py @@ -300,8 +300,9 @@ def new_image_form(request, path): editor = form.cleaned_data["who_are_you"] editor = git_string(editor) title = form.cleaned_data["header"] - referer = request.headers["Referer"].replace("_edit","") # original page being edited - host = request.headers["Host"] + referer = request.headers["Referer"] # original + host = request.headers["Host"] + print(f"{host=}") f = request.FILES["file_"] if not title: title = f.name @@ -455,7 +456,7 @@ def save_original_in_expofiles(f, year, photographer, host, handbook_directory, f.open() # rewind to beginning content = f.read() write_binary_file(filepath, content) - write_url_file(filepath, f.name, handbook_directory, page) + write_url_file(filepath, host, handbook_directory, page) elif isinstance(f, TemporaryUploadedFile): if filepath.is_file: print(f"+++++ Out of cheese error\n Destination EXISTS {filepath}") @@ -479,11 +480,18 @@ def save_original_in_expofiles(f, year, photographer, host, handbook_directory, raise TypeError(msg) return -def write_url_file(targetpath, host, handbook_rel_path, page): +def write_url_file(targetpath, host, handbook_rel_path, page): + """ + page is the referrer page, which is sort-of what we want, + but troggle URLs are such that this is not the same page we want to be visiting, e.g. + if he referrer is a "_edit" page, then we want to go to the view page, not the edit page. + ALSO ths will be different if the page is a Cave Description Page, and Entrance page pr a Handbook page. + """ # the ".url" is there, just never visible in Windows Explorer. # FIND AND FIX the correct host for this ! content = f"[InternetShortcut]\nURL={page}\n\n[TroggleImage]\nURL=http://{host}/{handbook_rel_path}" + content = content.replace("localhost:8000", "expo.survex.com") print(content) filepath = targetpath.with_suffix(".url") write_files([(filepath, content, "utf8")]) |