innovedus_cms/innovedus_cms/base/migrations/0007_contactformsubmission.py
Warren Chen 73f8442796 feat: Implement contact form submission feature with SMTP settings
- Added ContactFormSubmission model to store contact form submissions.
- Created ContactForm for handling form submissions.
- Implemented admin interface for managing contact form submissions.
- Developed views and JavaScript for handling contact form submission via AJAX.
- Added SMTP settings model for email configuration.
- Created notification email templates for contact form submissions.
- Updated frontend to include contact form modal and associated styles.
- Added tests for contact form submission and validation.
2026-04-02 02:51:39 +09:00

118 lines
5.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("base", "0006_oneclickunsubscribeaudit_and_more"),
]
operations = [
migrations.CreateModel(
name="MailSmtpSettings",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("smtp_relay_host", models.CharField(blank=True, max_length=255)),
("smtp_relay_port", models.PositiveIntegerField(default=587)),
("smtp_use_tls", models.BooleanField(default=True)),
(
"smtp_use_ssl",
models.BooleanField(default=False, help_text="465 常用 SSLImplicit TLS587 常用 STARTTLSTLS"),
),
("smtp_timeout_seconds", models.PositiveIntegerField(default=15)),
("smtp_username", models.CharField(blank=True, max_length=255)),
("smtp_password", models.TextField(blank=True)),
],
options={
"verbose_name": "SMTP Settings",
},
),
migrations.CreateModel(
name="SystemNotificationMailSettings",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("contact_form_from_name", models.CharField(blank=True, max_length=255)),
("contact_form_from_email", models.EmailField(blank=True, max_length=254)),
("contact_form_reply_to_email", models.EmailField(blank=True, max_length=254)),
("contact_form_to_emails", models.TextField(blank=True, help_text="可填多個收件人,以逗號或換行分隔。")),
("contact_form_subject_prefix", models.CharField(blank=True, default="[Contact Us]", max_length=255)),
("contact_form_user_subject_template", models.CharField(blank=True, default="已收到您的聯絡表單", max_length=255)),
(
"contact_form_user_text_template",
models.TextField(
blank=True,
default="您好 {{name}}\n\n我們已收到您的來信,以下為存檔資訊:\nEmail: {{email}}\n聯絡方式: {{contact}}\n問題類別: {{category}}\n\n留言內容:\n{{message}}\n",
),
),
(
"contact_form_user_html_template",
models.TextField(
blank=True,
default="<p>您好 {{name}}</p><p>我們已收到您的來信,以下為存檔資訊:</p><ul><li>Email: {{email}}</li><li>聯絡方式: {{contact}}</li><li>問題類別: {{category}}</li></ul><p>留言內容:</p><p>{{message}}</p>",
),
),
("default_charset", models.CharField(default="utf-8", max_length=50)),
],
options={
"verbose_name": "System Notification Mail Settings",
},
),
migrations.CreateModel(
name="ContactFormSubmission",
fields=[
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("name", models.CharField(max_length=100)),
("email", models.EmailField(blank=True, max_length=254)),
("contact", models.CharField(max_length=255)),
(
"category",
models.CharField(
choices=[
("collaboration", "合作邀約"),
("website_issue", "網站問題回報"),
("career", "求職專區"),
("other", "其他"),
],
max_length=32,
),
),
("message", models.TextField()),
("source_page", models.CharField(blank=True, max_length=512)),
("ip_address", models.GenericIPAddressField(blank=True, null=True)),
("user_agent", models.TextField(blank=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
],
options={
"ordering": ["-created_at"],
},
),
migrations.RemoveField(
model_name="newslettersystemsettings",
name="smtp_password",
),
migrations.RemoveField(
model_name="newslettersystemsettings",
name="smtp_relay_host",
),
migrations.RemoveField(
model_name="newslettersystemsettings",
name="smtp_relay_port",
),
migrations.RemoveField(
model_name="newslettersystemsettings",
name="smtp_timeout_seconds",
),
migrations.RemoveField(
model_name="newslettersystemsettings",
name="smtp_use_ssl",
),
migrations.RemoveField(
model_name="newslettersystemsettings",
name="smtp_use_tls",
),
migrations.RemoveField(
model_name="newslettersystemsettings",
name="smtp_username",
),
]