from django.db import models
from gauth.models import Location


class Reply(models.Model):
    replied_text = models.TextField()
    create_time = models.DateTimeField()

    def __str__(self):
        return self.replied_text


class Review(models.Model):
    review_id = models.CharField(max_length=150, primary_key=True)
    comment = models.TextField(null=True)
    create_time = models.DateTimeField()
    update_time = models.DateTimeField()
    star_rating = models.IntegerField()
    reviewer_name = models.CharField(max_length=100)
    reviewer_photo = models.URLField()
    location = models.ForeignKey(Location, on_delete=models.DO_NOTHING)
    reply = models.OneToOneField(Reply, on_delete=models.CASCADE, null=True, blank=True)

    def __str__(self):
        return f'{self.reviewer_name} - {self.comment}'


class CustomReply(models.Model):
    reply = models.TextField()
    reply_category = models.CharField(max_length=120)

    def __str__(self):
        return f'{self.reply_category} - {self.reply}'
