diff --git a/coulomb_social/apps/spaces/views.py b/coulomb_social/apps/spaces/views.py index 7433e55..6e52366 100644 --- a/coulomb_social/apps/spaces/views.py +++ b/coulomb_social/apps/spaces/views.py @@ -377,6 +377,14 @@ def page_edit(request: HttpRequest, slug: str, page_slug: str = "index") -> Http return redirect("spaces:detail", slug=slug) doc = pageops.read_page(space.slug, page_slug) + # Show files from the saved page even when a rejected edit redisplays the + # submitted fields. Attachment mutations keep their own revision checks. + try: + saved_files = attachments.page_files(space.slug, doc) if doc.exists else [] + attachment_error = "" + except (pageops.PageOpsError, OSError) as exc: + saved_files = [] + attachment_error = _mutation_error(exc) if request.method == "POST": title = (request.POST.get("title") or "").strip() abstractor = (request.POST.get("abstractor") or "").strip() @@ -421,6 +429,8 @@ def page_edit(request: HttpRequest, slug: str, page_slug: str = "index") -> Http "submitted_slug": request.POST.get("slug", page_slug), "is_new": not doc.exists, "form_title": "Edit or rename page" if doc.exists else "New page", + "saved_files": saved_files, + "attachment_error": attachment_error, }, ) diff --git a/coulomb_social/templates/spaces/page_form.html b/coulomb_social/templates/spaces/page_form.html index 349e8c5..526373b 100644 --- a/coulomb_social/templates/spaces/page_form.html +++ b/coulomb_social/templates/spaces/page_form.html @@ -32,6 +32,30 @@
Change the title to rename the displayed protocol. Change the file name below to rename its Markdown file and page address.
+ {% if not is_new %} +Files on the saved page. Editing or renaming the page keeps its attachments.
+ {% if attachment_error %} +{{ attachment_error }}
+ {% else %} +Save your edits before adding or removing files, then reopen the editor.
+