Skip to content

Attachments in posts and minor bug fixed#27

Open
jacksalici wants to merge 3 commits intomainfrom
dev-gsalici
Open

Attachments in posts and minor bug fixed#27
jacksalici wants to merge 3 commits intomainfrom
dev-gsalici

Conversation

@jacksalici
Copy link
Copy Markdown
Collaborator

No description provided.

jacksalici and others added 2 commits May 2, 2026 21:40
… in posts

Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings May 2, 2026 19:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for uploading and displaying named file attachments on news posts within the Django “main” app.

Changes:

  • Introduces PostAttachment model + migration and registers it in Django admin.
  • Extends post detail view/template to list attachments.
  • Extends post edit UI (template + JS) and view handler to add/remove attachments.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
docker-site/main/models.py Adds PostAttachment model related to Post.
docker-site/main/migrations/0013_postattachment.py Creates DB table for PostAttachment.
docker-site/main/admin.py Registers PostAttachment admin; enhances PostAdmin search.
docker-site/main/views.py Wires attachment retrieval for single post and attachment create/delete in post form handler.
docker-site/main/templates/main/single.html Displays attachments on the post detail page.
docker-site/main/templates/main/post_edit.html Adds attachment management UI + staging JS.
docker-site/main/templates/main/contacts.html Swaps lucide <i> icons for inline SVG icons.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docker-site/main/views.py Outdated
Comment thread docker-site/main/templates/main/post_edit.html Outdated
Comment thread docker-site/main/templates/main/post_edit.html Outdated
Comment thread docker-site/main/templates/main/post_edit.html Outdated
@jacksalici
Copy link
Copy Markdown
Collaborator Author

@copilot apply changes based on the comments in this thread

…ery, move file input instead of DataTransfer, use textContent to prevent XSS

Agent-Logs-Url: https://github.com/AImageLab-zip/aimagelab-website/sessions/c37ae010-db37-4b29-9c75-26cf1f40d05f

Co-authored-by: jacksalici <58181697+jacksalici@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI commented May 2, 2026

@copilot apply changes based on the comments in this thread

Applied all four changes in commit a488627:

  1. views.py – removed the duplicate from .models import (line 15 was a subset of line 20); kept the single, complete import on line 15.
  2. post_edit.html (double DB query) – wrapped the current-attachments block in {% with post.attachments.all as current_attachments %} so the queryset is evaluated only once.
  3. post_edit.html (DataTransfer) – instead of creating a new file input and assigning dataTransfer.files (unreliable in some browsers), the existing <input type="file"> element (which already holds the selected file) is moved into the hidden submission wrapper; a fresh input is then created and inserted back into the modal for the next attachment.
  4. post_edit.html (DOM XSS) – replaced pendingItem.innerHTML = \…`with explicit DOM element creation usingtextContentforattachmentNameandattachmentFile.name`.

@jacksalici
Copy link
Copy Markdown
Collaborator Author

Double checked the edits also in my dev stack, LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants