##### Any "tables" added here must be added
# to eh admin.py script for them to be visible
# in the admin UI

from django.db import models
from django import forms

class Feature_Type(models.Model):
    name = models.CharField(max_length=128, default='')

    def __str__(self):
        return str(self.name)

class Feature(models.Model):
    name = models.CharField(max_length=128, unique=True)
    feature_type = models.ForeignKey(Feature_Type, null=True)
    priority = models.PositiveIntegerField(default=0)
    toolkit_prompt = models.CharField(max_length=256, unique=False, default='')

    def __str__(self):
        return self.name

class Feature_Global_Variables(models.Model):
    feature = models.ForeignKey(Feature, null=True)
    line_number = models.PositiveIntegerField(default=0)
    text = models.TextField()

    def __str__(self):
        return str(self.text)

class Feature_Import(models.Model):
    feature = models.ForeignKey(Feature, null=True)
    line_number = models.PositiveIntegerField()
    text = models.TextField()

    def __str__(self):
        return str(self.feature_id) + '.' + str(self.line_number)

class Toolkit_Option(models.Model):
    feature = models.ForeignKey(Feature, null=True)
    number = models.PositiveIntegerField(default=0)
    text = models.CharField(max_length=128, unique=False)

    def __str__(self):
        return self.text

class Function(models.Model):
    name = models.CharField(max_length=128, unique=True, default='')

    def __str__(self):
        return str(self.name)

class Feature_Function(models.Model):
    feature = models.ForeignKey(Feature, null=True)
    function = models.ForeignKey(Function, null=True)

    def __str__(self):
        return "temporary"

class Function_Global_Variables(models.Model):
    function = models.ForeignKey(Function, null=True)
    line_number = models.PositiveIntegerField(default=0)
    text = models.TextField()

    def __str__(self):
        return "Global Var " + str(self.function_id)

class Function_Import(models.Model):
    function = models.ForeignKey(Function, null=True)
    line_number = models.PositiveIntegerField()
    text = models.TextField()

    def __str__(self):
        return str(self.function_id) + '.' + str(self.line_number)

class Header(models.Model):
    function = models.ForeignKey(Function, null=True)
    line_number = models.PositiveIntegerField()
    text = models.TextField()

    def __str__(self):
        return str(self.function_id) + '.' + str(self.line_number)

class Definition(models.Model):
    function = models.ForeignKey(Function, null=True)
    line_number = models.PositiveIntegerField()
    text = models.TextField()

    def __str__(self):
        return "Definition " + str(self.function_id)

class Body(models.Model):
    feature = models.ForeignKey(Feature, null=True)
    line_number = models.PositiveIntegerField()
    text = models.TextField()

    def __str__(self):
        return str(self.feature_id) + '.' + str(self.line_number)
