# 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
# Feel free to rename the models, but don't rename db_table values or field names.
#
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'
# into your database.

from django.db import models

class TypeEmail(models.Model):
    libelle = models.CharField(max_length=50)
    def __unicode__(self):
      return u'%s' % (self.libelle)

class Profil(models.Model):
    pseudo = models.CharField(max_length=155)
    email = models.CharField(max_length=155)
    typeEmail = models.ForeignKey(TypeEmail)
    udid = models.CharField(max_length=155)
    image = models.ImageField(upload_to='images/%Y%m%d%H%M%S',blank=True)
    latitude = models.FloatField(blank=True)
    longitude = models.FloatField(blank=True)
    dateupdate = models.DateTimeField(auto_now=True)
    valide = models.BooleanField()
    validAdmin = models.BooleanField()
    token = models.CharField(max_length=155)
    online = models.BooleanField()
    historique = models.BooleanField()
    push = models.BooleanField()
    abonnement = models.IntegerField()
    dateFinAbonnement = models.DateTimeField(auto_now=False)
    def __unicode__(self):
      return u'%s' % (self.pseudo)
    def thumbnail(self):
     return """<img src="http://www.gaycamnow.fr/gcamnow/admin/bo/%s" width="160" height="120"/>""" % (self.image)
    thumbnail.allow_tags = True


class Chat(models.Model):
    user_src = models.ForeignKey(Profil,related_name='user_src')
    user_dst = models.ForeignKey(Profil,related_name='user_dst')
    message = models.CharField(max_length=1024)
    dateupdate = models.DateTimeField(auto_now=True)
    luSrc = models.BooleanField()
    luDst = models.BooleanField()
    def __unicode__(self):
      return u'%s' % (self.user_src)

class VideoChat(models.Model):
    user_src = models.ForeignKey(Profil,related_name='src')
    user_dst = models.ForeignKey(Profil,related_name='dst')
    sessionId = models.CharField(max_length=1024)
    token_publisher = models.CharField(max_length=1024)
    token_subscriber = models.CharField(max_length=1024)
    dateupdate = models.DateTimeField(auto_now=True)
    inprogress = models.BooleanField()
    def __unicode__(self):
      return u'%s' % (self.user_src)

class AskVideoChat(models.Model):
    user_src = models.ForeignKey(Profil,related_name='srcAsk')
    user_dst = models.ForeignKey(Profil,related_name='dstAsk')
    accepte = models.BooleanField()
    dateupdate = models.DateTimeField(auto_now=True)
    def __unicode__(self):
      return u'%s' % (self.user_src)
