from django.db import models
from django_extensions.db.models import TitleSlugDescriptionModel

# Create your models here.

"""
abstract models.
"""


class DiscoveredModel(models.Model):
    discovered = models.DateTimeField(help_text="When the item was discovered")

    class Meta:
        abstract = True


class SourceModel(TitleSlugDescriptionModel):
    url = models.URLField(help_text="The url representing the source of a model")

    class Meta:
        abstract = True

"""
concrete models
"""


class TopicSet(DiscoveredModel):
    source = models.CharField(max_length=255)


class Topic(models.Model):
    """
    A particular trending item. Eg "Hail Obama", "#8ReasonsWhyImOnTwitter"
    """
    topicset = models.ForeignKey("TopicSet")


class Search(DiscoveredModel):
    source = models.CharField(max_length=255)
    topic = models.ForeignKey("Topic")


class Result(models.Model):
    url = models.URLField()
    search = models.ForeignKey("Search")


class MalwareReport(models.Model):
    result = models.ForeignKey("Result")
    reporter = models.CharField(max_length=255)


class Opinion(models.Model):
    type = models.CharField(max_length=255)
    confidence = models.DecimalField(max_digits=2, decimal_places=1)

from django.db import models
from django_extensions.db.models import TitleSlugDescriptionModel

# Create your models here.

"""
abstract models.
"""


class DiscoveredModel(models.Model):
    discovered = models.DateTimeField(help_text="When the item was discovered")

    class Meta:
        abstract = True


class SourceModel(TitleSlugDescriptionModel):
    url = models.URLField(help_text="The url representing the source of a model")

    class Meta:
        abstract = True

"""
concrete models
"""


class TopicSet(DiscoveredModel):
    source = models.CharField(max_length=255)


class Topic(models.Model):
    """
    A particular trending item. Eg "Hail Obama", "#8ReasonsWhyImOnTwitter"
    """
    keyword = models.CharField(max_length=255)
    topicset = models.ForeignKey("TopicSet")


class Search(DiscoveredModel):
    source = models.CharField(max_length=255)
    topic = models.ForeignKey("Topic")


class Result(models.Model):
    url = models.URLField()
    search = models.ForeignKey("Search")


class MalwareReport(models.Model):
    result = models.ForeignKey("Result")
    reporter = models.CharField(max_length=255)


class Opinion(models.Model):
    type = models.CharField(max_length=255)
    confidence = models.DecimalField(max_digits=2, decimal_places=1)
    malware_report = models.ForeignKey("MalwareReport")

fix incongruence between db and json schema