74 lines
2.2 KiB
Python
74 lines
2.2 KiB
Python
from django.db import models
|
|
|
|
from apps.core.utils import CONTENT_FORMAT_CHOICES, FORMAT_PLAIN, render_content
|
|
|
|
|
|
class ContactSubmission(models.Model):
|
|
name = models.CharField(max_length=200)
|
|
title = models.CharField(max_length=300)
|
|
description = models.TextField()
|
|
email = models.EmailField(blank=True)
|
|
submitted_at = models.DateTimeField(auto_now_add=True)
|
|
is_read = models.BooleanField(default=False)
|
|
|
|
class Meta:
|
|
ordering = ["-submitted_at"]
|
|
verbose_name = "Contact Submission"
|
|
verbose_name_plural = "Contact Submissions"
|
|
|
|
def __str__(self):
|
|
return f"{self.name} — {self.title}"
|
|
|
|
|
|
class FAQEntry(models.Model):
|
|
question = models.CharField(max_length=500)
|
|
answer = models.TextField()
|
|
answer_format = models.CharField(
|
|
max_length=20, choices=CONTENT_FORMAT_CHOICES, default=FORMAT_PLAIN
|
|
)
|
|
order = models.PositiveIntegerField(default=0)
|
|
is_active = models.BooleanField(default=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
ordering = ["order"]
|
|
verbose_name = "FAQ Entry"
|
|
verbose_name_plural = "FAQ Entries"
|
|
|
|
def __str__(self):
|
|
return self.question
|
|
|
|
@property
|
|
def rendered_answer(self):
|
|
return render_content(self.answer, self.answer_format)
|
|
|
|
|
|
class DownloadItem(models.Model):
|
|
PLATFORM_WINDOWS = "windows"
|
|
PLATFORM_MACOS = "macos"
|
|
PLATFORM_LINUX = "linux"
|
|
|
|
PLATFORM_CHOICES = [
|
|
(PLATFORM_WINDOWS, "Windows"),
|
|
(PLATFORM_MACOS, "macOS"),
|
|
(PLATFORM_LINUX, "Linux"),
|
|
]
|
|
|
|
name = models.CharField(max_length=200)
|
|
platform = models.CharField(max_length=20, choices=PLATFORM_CHOICES)
|
|
version = models.CharField(max_length=50)
|
|
download_url = models.URLField()
|
|
description = models.TextField(blank=True)
|
|
is_active = models.BooleanField(default=True)
|
|
order = models.PositiveIntegerField(default=0)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
ordering = ["order", "platform"]
|
|
verbose_name = "Download Item"
|
|
verbose_name_plural = "Download Items"
|
|
|
|
def __str__(self):
|
|
return f"{self.name} ({self.get_platform_display()})"
|