2020-05-16 02:12:21 +02:00
|
|
|
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()
|
2020-05-16 14:40:22 +02:00
|
|
|
description_en = models.TextField(null=True)
|
2020-05-16 02:12:21 +02:00
|
|
|
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'<a href="http://{self.domain}" target="_blank">{self.domain}</a>'
|
|
|
|
)
|
|
|
|
|
|
|
|
def image_tag(self):
|
|
|
|
return mark_safe(
|
|
|
|
f"<img src="
|
|
|
|
f'"{settings.MEDIA_URL + self.photo.name}"'
|
|
|
|
f' width="50" height="50">'
|
|
|
|
)
|
2020-06-19 01:35:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Partner(models.Model):
|
|
|
|
id = models.AutoField(primary_key=True)
|
|
|
|
name = models.CharField(max_length=150)
|
|
|
|
description = models.TextField()
|
|
|
|
description_en = models.TextField(null=True)
|
|
|
|
photo = models.ImageField(upload_to="partner")
|
|
|
|
|
|
|
|
domain = models.CharField(max_length=150)
|
|
|
|
hidden = models.BooleanField(default=False)
|
|
|
|
|
|
|
|
def domain_tag(self):
|
|
|
|
return mark_safe(
|
|
|
|
f'<a href="http://{self.domain}" target="_blank">{self.domain}</a>'
|
|
|
|
)
|
|
|
|
|
|
|
|
def image_tag(self):
|
|
|
|
return mark_safe(
|
|
|
|
f"<img src="
|
|
|
|
f'"{settings.MEDIA_URL + self.photo.name}"'
|
|
|
|
f' width="50" height="50">'
|
|
|
|
)
|