"""learning_logs/models.py"""

# Django modules
from django.db import models
from django.contrib.auth.models import User

class Topic(models.Model):
    """ADD: Class Topic"""
    text = models.CharField(max_length=200)
    date_added = models.DateTimeField(auto_now_add=True)
    owner = models.ForeignKey(User, on_delete=models.DO_NOTHING, default='')

    class Meta:
        verbose_name = 'topic'
        verbose_name_plural = 'topics'
    

    def __str__(self):
        return self.text


class Entry(models.Model):
    """ADD: Class Entry"""
    topic = models.ForeignKey(Topic, on_delete=models.DO_NOTHING)
    text = models.TextField(default='Please, enter data')
    date_added = models.DateTimeField(auto_now_add=True)

    class Meta:
        verbose_name = 'entry'
        verbose_name_plural = 'entries'
    

    def __str__(self):
        return self.text[:50] + '...'