from django.db import models
import  uuid
from django.contrib.auth.models import User


class Profile(models.Model):
    id = models.UUIDField(
        primary_key=True,
        default=uuid.uuid4,
        editable=False
    )
    users = models.ForeignKey(User, on_delete=models.CASCADE, related_name='login_users')
    name = models.CharField(max_length=100, null=True)
    created_by = models.DateField(auto_now_add=True)

    def __str__(self):
        return self.name

    class Meta:
        ordering = ['-created_by']


class Contact(models.Model):
    id = models.UUIDField(
        primary_key=True,
        default=uuid.uuid4,
        editable=False
    )
    name = models.CharField(max_length=50, null=True)
    phone = models.CharField(max_length=13, null=True)
    email = models.EmailField()
    sub = models.CharField(max_length=100, null=True)
    descriptions = models.TextField()
    created_by = models.DateField(auto_now_add=True)

    def __str__(self):
        return self.name

    class Meta:
        ordering = ['-created_by']


