from django.db import models

class Site(models.Model):
    name = models.CharField(max_length=200, default="")
    title = models.CharField(max_length=200)
    header = models.TextField(default="")
    page_header = models.TextField(default="")
    index = models.TextField()
    password = models.CharField(max_length=200, default="")

    def __str__(self):
        return self.name

class Page(models.Model):
    site = models.ForeignKey(Site, on_delete=models.CASCADE)
    content = models.TextField()
    name = models.CharField(max_length=200)
    pretty_name = models.CharField(max_length=200, default="")
    published = models.BooleanField(default=False)
    navigable = models.BooleanField(default=False)
    priority = models.IntegerField(default=0)

    def __str__(self):
        return self.name

class Image(models.Model):
    name = models.CharField(max_length=200)
    content = models.ImageField(upload_to="uploads",
        width_field="width", height_field="height", default=None)
    width = models.IntegerField(default=0)
    height = models.IntegerField(default=0)
    alt_text = models.TextField()

    def __str__(self):
        return self.name
