from django.db import models


# Create your models here.
class JsonToType(models.Model):
    aktif = (
        (True, 'Evet'),
        (False, 'Hayır'),
    )
    user = models.ForeignKey('accounts.CustomUser', on_delete=models.CASCADE, related_name='json_to_type_user',
                             verbose_name="Kullanıcı")
    title = models.CharField(max_length=254, verbose_name="Başlık")
    json_data = models.JSONField(verbose_name="Json Veri", unique=True)
    type_data = models.TextField(verbose_name="Type Veri", unique=True)
    created_at = models.DateTimeField(auto_now_add=True, editable=False, verbose_name="Oluşturulma Tarihi")
    updated_at = models.DateTimeField(auto_now=True, editable=False, verbose_name="Güncelleme Tarihi")
    is_active = models.BooleanField(default=False, verbose_name='Yayındamı', choices=aktif)

    class Meta:
        ordering = ["-updated_at"]
        db_table = 'json_to_type'
        verbose_name_plural = "Json To Type"
        verbose_name = "Json To Type"

    def __str__(self):
        return self.title
