mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
comments trying to understand..
This commit is contained in:
parent
685131a4c1
commit
c7cb8ece2e
@ -16,7 +16,13 @@ import re
|
||||
There are other, simpler, upload forms in view/uploads.py
|
||||
|
||||
class-based forms are quicker to set up (for Django experts) but
|
||||
are more difficult to maintain by non-Django experts.
|
||||
are more difficult to maintain (or even begin to understand) by non-Django experts.
|
||||
|
||||
Notes to self, as I try to work out what the hell is going on:
|
||||
|
||||
Note that HTMLarea invokes a widget which sets a CSS class which calls javascript in
|
||||
templates/html_editor_scripts_css.html - which imports jquery and codemirror directly, without
|
||||
declaring it anywhere or locally installing it. (!)
|
||||
"""
|
||||
|
||||
todo = """
|
||||
@ -89,12 +95,6 @@ class CaveForm(ModelForm):
|
||||
print("EEE", cave_slug.replace("-PENDING-", "-"))
|
||||
return cave_slug.replace("-PENDING-", "-")
|
||||
|
||||
# def clean_url(self):
|
||||
# data = self.cleaned_data["url"]
|
||||
# if not re.match("\d\d\d\d/.", data):
|
||||
# raise ValidationError("URL must start with a four digit Kataster area.")
|
||||
# return data
|
||||
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(CaveForm, self).clean() # where is this code hidden? How does this work??
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user