feat: upload file in contact form
This commit is contained in:
@@ -3,6 +3,10 @@ from django.db import models
|
||||
from django.utils.text import slugify
|
||||
|
||||
from apps.core.utils import CONTENT_FORMAT_CHOICES, FORMAT_MARKDOWN, FORMAT_PLAIN, render_content
|
||||
from apps.pages.contact_uploads import (
|
||||
contact_attachment_storage,
|
||||
contact_attachment_upload_to,
|
||||
)
|
||||
|
||||
RESERVED_PAGE_SLUGS = frozenset({
|
||||
"admin",
|
||||
@@ -177,6 +181,28 @@ class ContactSubmission(models.Model):
|
||||
return f"{self.name} — {self.title}"
|
||||
|
||||
|
||||
class ContactSubmissionAttachment(models.Model):
|
||||
submission = models.ForeignKey(
|
||||
ContactSubmission,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="attachments",
|
||||
)
|
||||
file = models.FileField(
|
||||
upload_to=contact_attachment_upload_to,
|
||||
storage=contact_attachment_storage,
|
||||
)
|
||||
original_filename = models.CharField(max_length=255)
|
||||
uploaded_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["uploaded_at"]
|
||||
verbose_name = "Contact Attachment"
|
||||
verbose_name_plural = "Contact Attachments"
|
||||
|
||||
def __str__(self):
|
||||
return self.original_filename
|
||||
|
||||
|
||||
class FAQEntry(models.Model):
|
||||
question = models.CharField(max_length=500)
|
||||
answer = models.TextField()
|
||||
|
||||
Reference in New Issue
Block a user