feat: 文件资料增加分类字段

This commit is contained in:
caoqianming 2023-05-05 10:52:49 +08:00
parent 475c1c1174
commit bbdd8d7dcf
2 changed files with 2 additions and 1 deletions

View File

@ -35,6 +35,7 @@ class Material(CommonModel):
description = models.TextField('描述', null=True, blank=True) description = models.TextField('描述', null=True, blank=True)
path = models.CharField(max_length=1000, verbose_name='文件地址') path = models.CharField(max_length=1000, verbose_name='文件地址')
poster = models.CharField(max_length=10000, verbose_name='封面地址', null=True, blank=True) poster = models.CharField(max_length=10000, verbose_name='封面地址', null=True, blank=True)
cate = models.CharField('分类', max_length=50, verbose_name='未分类')
type = models.CharField('格式', default='文档', max_length=50) type = models.CharField('格式', default='文档', max_length=50)
down_count = models.IntegerField('阅读量', default=0) down_count = models.IntegerField('阅读量', default=0)
sort = models.IntegerField('排序码', default=1) sort = models.IntegerField('排序码', default=1)

View File

@ -69,7 +69,7 @@ class MaterialViewSet(ModelViewSet):
search_fields = ['name','description'] search_fields = ['name','description']
ordering_fields = ['update_time', 'down_count'] ordering_fields = ['update_time', 'down_count']
ordering = ['sort', '-down_count'] ordering = ['sort', '-down_count']
filterset_fields = ['type', 'name'] filterset_fields = ['type', 'name', 'cate']
@action(methods=['get'], detail=True, url_name='down_material', perms_map=[{'*':'down_material'}]) @action(methods=['get'], detail=True, url_name='down_material', perms_map=[{'*':'down_material'}])
def down(self, request, *args, **kwargs): def down(self, request, *args, **kwargs):