#!/usr/bin/env Python
# coding=utf-8

from django.db import models
from django.contrib.auth.models import User


Gender_Type = [
        ('n', '未知'),
        ('male', '男生'),
        ('female', '女生')
    ]

class UserProfile(models.Model):
    owner = models.OneToOneField(User, on_delete=models.CASCADE, verbose_name='用户')

    name = models.CharField(max_length=8, blank=False, verbose_name='用户名', help_text='取一个炫酷的博名吧！')
    gender = models.CharField(max_length=6, choices=Gender_Type, default='n',
                              verbose_name='性别', help_text='小姐姐还是小哥哥？')
    birthday = models.DateField(null=True, blank=True, verbose_name='生日')
    email = models.EmailField(verbose_name='邮箱', blank=True, null=True)
    info = models.TextField(max_length=200, blank=True, default='', help_text='简要介绍一下自己，不要超过200字哦！', verbose_name='个人简介')
    gexing = models.CharField(max_length=20, blank=True, default='', help_text='炫耀一下自己的签名...', verbose_name='签名')
    account = models.CharField(max_length=9, verbose_name='账号', help_text='账号请在这里输入...')
    password = models.CharField(max_length=18, verbose_name='密码', help_text='密码请在这里输入...')
    image = models.ImageField(upload_to='images/%Y/%m', default='images/default.png',
                              max_length=100, verbose_name='用户头像')

class EmailVerifyRecord(models.Model):
    SEND_TYPE_CHOICES = (
        ('register', '注册'),
        ('forget', '找回密码')
    )

    code = models.CharField('验证码', max_length=20)
    email = models.EmailField('邮箱', max_length=50)
    send_type = models.CharField(choices=SEND_TYPE_CHOICES, max_length=10, default='register')
    send_time = models.DateTimeField('时间', auto_now_add=True)

    class Meta:
        verbose_name = '邮箱验证码'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.code

