2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 17:17:08 +00:00

comments trying to understand..

This commit is contained in:
2023-11-02 21:05:08 +02:00
parent 685131a4c1
commit c7cb8ece2e
2 changed files with 19 additions and 9 deletions

View File

@@ -22,9 +22,15 @@ MAX_IMAGE_HEIGHT = 800
THUMBNAIL_WIDTH = 200
THUMBNAIL_HEIGHT = 200
"""This is all written by Martin Green, and completely undocumented.
It uses a lot of opinionated Django default magic, none of which I am familiar with.
Philip
"""
def get_dir(path):
"From a path sent from urls.py, determine the directory."
# todo re-write this to use modern pathlib functions
if "/" in path:
return path.rsplit("/", 1)[0]
else:
@@ -34,6 +40,7 @@ def get_dir(path):
def image_selector(request, path):
"""Returns available images"""
directory = get_dir(path)
print(f" - image selector {directory=} {path=}")
thumbnailspath = Path(settings.EXPOWEB) / directory / "t"
thumbnails = []
if thumbnailspath.is_dir():
@@ -116,7 +123,7 @@ def new_image_form(request, path):
thumbnail = thumbnail.convert('RGB')
thumbnail.save(tb, format="jpeg", quality = 70)
image_rel_path, thumb_rel_path, desc_rel_path = form.get_rel_paths()
image_page_template = loader.get_template("image_page_template.html")
image_page_template = loader.get_template("image_page_template.html") # this is the .html file in the /l/ folder
image_page = image_page_template.render(
{
"header": form.cleaned_data["header"],
@@ -190,7 +197,7 @@ class NewWebImageForm(forms.Form):
]
def get_full_paths(self):
return [Path(settings.EXPOWEB) / x for x in self.get_rel_paths()]
return [Path(settings.EXPOWEB) / x for x in self.get_rel_paths()] # this is where we would want to insert the /caveid/ ?!
def clean_file_(self):
for rel_path, full_path in zip(self.get_rel_paths(), self.get_full_paths()):
@@ -200,6 +207,9 @@ class NewWebImageForm(forms.Form):
class HTMLarea(forms.Textarea):
"""This is called from CaveForm in core/forms.py which is called from core/views/caves.py when editing a cave description
(and similarly for Entrance Descriptions). It is alls called from core/views/expo.py when editing expo (i.e. handbook) pages.
"""
template_name = "widgets/HTMLarea.html"
def __init__(self, *args, **kwargs):