from django.db import models
from django.core.files.storage import FileSystemStorage
from django.contrib.auth.models import User


class Subscriber(models.Model):
    email = models.CharField()
    open_rate = models.SmallIntegerField(null=True, blank=True)
    subscribed = models.BooleanField(null=True, blank=True)
    created_at = models.DateTimeField(null=True, blank=True)
    label = models.CharField(max_length=15)
    status = models.CharField(max_length=7)
    start_date = models.DateTimeField(null=True, blank=True)
    amount = models.SmallIntegerField(null=True, blank=True)
    interval = models.CharField(max_length=7)
    reoccuring = models.CharField(max_length=15)
    tier = models.CharField(max_length=15)


    class Meta:
        unique_together = ("email", "created_at")
        verbose_name_plural = "Subscribers"
        ordering = ['created_at']

    def __unicode__(self):
        return "%s" % self.email

    def __str__(self):
        return u'%s' % self.email


class DigiStat(models.Model):
    name = models.CharField(max_length=15)
    stat = models.IntegerField()

    class Meta:
        verbose_name_plural = "DigiStats"
        ordering = ['name']

    def __unicode__(self):
        return "%s" % self.email

    def __str__(self):
        return u'%s' % self.email


class Platform(models.Model):
    name = models.CharField(max_length=15)
    description = models.TextField(null=True, blank=True)
    mau = models.IntegerField(null=True, blank=True)
    dau = models.IntegerField(null=True, blank=True)
    engage_rate = models.FloatField(null=True, blank=True)
    market_cap = models.IntegerField(null=True, blank=True)
    date_updated = models.DateTimeField(null=True, blank=True)
    
    def __unicode__(self):
        return "%s" % self.name

    def __str__(self):
        return u'%s' % self.name