#encoding= utf-8
from django.db import models
from django.contrib.auth.models import User
class Persona(models.Model):
	user = models.CharField(max_length=100)
	admin = models.CharField(max_length=100)
	nombre = models.CharField(max_length=100)
	sexo = models.CharField(max_length=100)
	edad = models.IntegerField(null=True)
	amigos = models.ManyToManyField('self', symmetrical=True,  blank=True)
	imagen = models.ImageField(upload_to='imagenes')
	def __str__(self):
		return self.nombre
class Articulo(models.Model):
	cabecera = models.CharField(max_length=100,null=True)
	compania = models.CharField(max_length=100,null=True)
	texto = models.TextField(max_length=1000,null=True)
	imagen = models.ImageField(upload_to='imagenes')
	creador = models.CharField(max_length=100,null=True)
	fecha=  models.DateField(auto_now_add=True)
	
	def __str__(self):
		return self.cabecera
class Comentario(models.Model):
	texto = models.TextField(max_length=500,null=True)
	creador = models.ForeignKey(Persona)
	Articulo = models.ForeignKey(Articulo)
	
	def __str__(self):
		return self.Articulo
class Puntuacion(models.Model):
	numero = models.IntegerField(null=True)
	Articulo = models.ForeignKey(Articulo)
	def __str__(self):
		return self.Articulo__cabecera
class Coordenadas(models.Model):
	x = models.FloatField(null=True)
	y = models.FloatField(null=True)
	tienda = models.CharField(max_length=100,null=True)
	pertenece = models.ManyToManyField(Articulo, symmetrical=True,  blank=True)
	def __str__(self):
		return self.Coordenadas__tienda
class Mensaje(models.Model):
	titulo= models.CharField(max_length=100,null=True)
	texto = models.TextField(max_length=1000,null=True)
	autor=models.CharField(max_length=100,null=True)
	destinatario=models.ForeignKey(Persona)
	leido = models.IntegerField(null=True)
	def __str__(self):
		return self.Mensaje__titulo

# Create your models here.
#http://django.es/blog/metodos-para-crear-perfiles-de-usuario/
