# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#   * Rearrange models' order
#   * Make sure each model has one field with primary_key=True
#   * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
#   * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models
from django.contrib.auth.models import User


class Activity(models.Model):
    name = models.CharField(max_length=255)
    icon = models.CharField(max_length=255, blank=True, null=True)
    color = models.CharField(max_length=255, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'activity'

    def __str__(self):
        return self.name


class ActivityMood(models.Model):
    activity = models.OneToOneField(Activity, models.DO_NOTHING, primary_key=True)
    mood = models.ForeignKey('Mood', models.DO_NOTHING)

    class Meta:
        managed = False
        db_table = 'activity_mood'
        unique_together = (('activity', 'mood'),)


class Tag(models.Model):
    user = models.ForeignKey(User, models.DO_NOTHING, blank=True, null=True)
    color = models.CharField(max_length=255, blank=True, null=True)
    name = models.CharField(max_length=255)
    icon = models.CharField(max_length=255, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'tag'

    def __str__(self):
        return self.name


class TagMood(models.Model):
    tag = models.OneToOneField(Tag, models.DO_NOTHING, primary_key=True)
    mood = models.ForeignKey('Mood', models.DO_NOTHING)

    class Meta:
        managed = False
        db_table = 'tag_mood'
        unique_together = (('tag', 'mood'),)


class Mood(models.Model):
    user = models.ForeignKey(User, models.DO_NOTHING, blank=True, null=True)
    moment = models.DateTimeField()
    mood = models.IntegerField(null=True)
    comment = models.CharField(max_length=255)
    activities = models.ManyToManyField(Activity, related_name='moods', db_table='activity_mood', blank=True)
    tags = models.ManyToManyField(Tag, related_name='moods', db_table='tag_mood', blank=True)

    @property
    def icon(self):
        fa_mood_icons = ["fa-smile-beam", "fa-smile", "fa-meh", "fa-frown-open", "fa-frown"]
        return fa_mood_icons[2 - int(self.mood)]

    class Meta:
        managed = False
        db_table = 'mood'

