from django.db import models from django.conf import settings from django.utils.safestring import mark_safe from django.utils.translation import gettext class Service(models.Model): class SourcesType(models.TextChoices): closed = "CLOSED", gettext("Sources closes") open = "OPEN", gettext("Sources ouvertes") unknown = "UNK", gettext("Inconnu") class HostedType(models.TextChoices): federated = "FED", gettext("Fédéré") centralized = "CENT", gettext("Centralisé") unknown = "UNK", gettext("Inconnu") id = models.AutoField(primary_key=True) name = models.CharField(max_length=150) description = models.TextField() photo = models.ImageField(upload_to="services") sources = models.CharField( max_length=10, choices=SourcesType.choices, default=SourcesType.unknown, ) hosted = models.CharField( max_length=10, choices=HostedType.choices, default=HostedType.unknown, ) domain = models.CharField(max_length=150) hidden = models.BooleanField(default=False) def domain_tag(self): return mark_safe( f'{self.domain}' ) def image_tag(self): return mark_safe( f"' )