from django.db import models
import django.utils.timezone as timezone
from rbac.models import SoftCommonModel, CommonModel
# Create your models here.

class Article(CommonModel):
    '''
    文章
    '''
    title = models.CharField(max_length=60, verbose_name='标题')
    elink = models.URLField(verbose_name='外部链接', null=True, blank=True)
    content = models.TextField(verbose_name='内容', blank=True)
    ifrom = models.CharField(max_length=60, verbose_name='来源')
    is_top = models.BooleanField('置顶', default=False)

    class Meta:
        verbose_name = '文章'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.title


class Material(CommonModel):
    """
    学习资料
    """
    type_choices = (
        ('文档', '文档'),
        ('视频', '视频'),
        ('图片', '图片'),
        ('音乐', '音乐'),
    )
    name = models.CharField(max_length=200, verbose_name='标题', unique=True)
    description = models.TextField('描述', null=True, blank=True)
    path = models.CharField(max_length=1000, verbose_name='文件地址')
    poster = models.CharField(max_length=10000, verbose_name='封面地址', null=True, blank=True)
    type = models.CharField('格式', default='文档', max_length=50)
    down_count = models.IntegerField('阅读量', default=0)
    sort = models.IntegerField('排序码', default=1)

