from django.db import models
class Entry(models.Model):
    subject = models.TextField(blank=True)
    illustration = models.TextField(blank=True)
    application = models.TextField(blank=True)
    scripture_raw = models.TextField(blank=True)
    source = models.CharField(max_length=255, blank=True)
    talk_number = models.IntegerField(null=True, blank=True)
    talk_title = models.CharField(max_length=255, blank=True)
    entry_code = models.CharField(max_length=64, blank=True, db_index=True)
    date_added = models.DateField(null=True, blank=True)
    date_edited = models.DateField(null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    def __str__(self): return f"{self.talk_title or '(untitled)'} [{self.entry_code}]"
class ScriptureRef(models.Model):
    entry = models.ForeignKey(Entry, on_delete=models.CASCADE, related_name="scripture_refs")
    book = models.CharField(max_length=32)
    chapter_from = models.IntegerField(null=True, blank=True)
    verse_from = models.IntegerField(null=True, blank=True)
    chapter_to = models.IntegerField(null=True, blank=True)
    verse_to = models.IntegerField(null=True, blank=True)
    def __str__(self): return f"{self.book} {self.chapter_from}:{self.verse_from}"
from .models_user import *  # registers UserPrefs, SearchHistory, ViewedIllustration
