from django.db import models
from patient.models import Patient
from django.utils.encoding import smart_unicode


class MotivationText(models.Model):
    patient = models.ForeignKey(Patient, null=False)
    text = models.TextField(default='', blank=False)
    sound = models.FileField(null=True, blank=True, help_text="Must be mp3")
    time_created = models.DateTimeField(null=False, auto_now_add=True, auto_now=False)

    TEXT_INFORMATION = 'I'
    TEXT_MOTIVATION = 'M'
    TYPES = [
        (TEXT_INFORMATION, 'InformationText'),
        (TEXT_MOTIVATION, 'MotivationText'),
    ]
    type = models.CharField(max_length=1, choices=TYPES, null=False, default='M')

    def __unicode__(self):
        return smart_unicode(
            ("InformationText" if self.type == 'I' else 'MotivationText')
            + " for " + self.patient.user.get_full_name()
            + " created at " + str(self.time_created)
        )

    class Meta():
        ordering = ['-id']

from django.db import models
from patient.models import Patient
from django.utils.encoding import smart_unicode


class MotivationText(models.Model):
    patient = models.ForeignKey(Patient, null=False)
    text = models.TextField(default='', blank=False)
    sound = models.FileField(null=True, blank=True, help_text="Must be mp3")
    time_created = models.DateTimeField(null=False, auto_now_add=True, auto_now=False)

    TEXT_INFORMATION = 'I'
    TEXT_MOTIVATION = 'M'
    TYPES = [
        (TEXT_INFORMATION, 'InformationText'),
        (TEXT_MOTIVATION, 'MotivationText'),
    ]
    type = models.CharField(max_length=1, choices=TYPES, null=False, default='M')

    def __unicode__(self):
        return smart_unicode(
            ("InformationText" if self.type == 'I' else 'MotivationText')
            + " for " + self.patient.user.get_full_name()
            + " created at " + str(self.time_created)
        )

    class Meta():
        ordering = ['-id']
