2021-08-29 00:20:02 +02:00
|
|
|
from django.db import models
|
2022-04-11 22:43:06 +02:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2021-08-29 00:20:02 +02:00
|
|
|
# Create your models here.
|
|
|
|
from django_tenants.models import DomainMixin
|
|
|
|
from tenant_users.tenants.models import TenantBase
|
|
|
|
|
|
|
|
from rpg_notes.secrets import DEBUG
|
2023-05-28 16:22:12 +02:00
|
|
|
from utils.languages import full_text_languages_choice
|
|
|
|
from utils.random_filename import get_file_path
|
2021-08-29 00:20:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Campaign(TenantBase):
|
2021-09-25 20:31:08 +02:00
|
|
|
name = models.CharField(_("Name"), max_length=1000, unique=True)
|
2023-07-09 20:23:05 +02:00
|
|
|
language = models.CharField(
|
|
|
|
_("Language"), max_length=100, choices=full_text_languages_choice,
|
|
|
|
help_text=_("This is needed for the full text search to work optimally.")
|
|
|
|
)
|
2023-05-28 16:22:12 +02:00
|
|
|
document = models.FileField(_("Document"), upload_to=get_file_path, blank=True, null=True, editable=False)
|
2022-04-11 22:43:06 +02:00
|
|
|
|
2021-08-29 00:20:02 +02:00
|
|
|
auto_create_schema = True
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
def get_absolute_url(self):
|
|
|
|
print(self.get_primary_domain().domain)
|
|
|
|
protocol = "http://" if DEBUG else "https://"
|
|
|
|
return protocol + self.get_primary_domain().domain + (":8000" if DEBUG else "")
|
|
|
|
|
|
|
|
|
|
|
|
class Domain(DomainMixin):
|
|
|
|
pass
|