init. 初始化项目,并初步完成前端模板样式
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from django.http import HttpResponseForbidden
|
||||
from django.shortcuts import render
|
||||
|
||||
from article.models import Article
|
||||
from utils.permission import user_has_permission
|
||||
|
||||
from ninja import Router
|
||||
|
||||
# Create your views here.
|
||||
|
||||
# Create your views here.
|
||||
router = Router(tags=['content'])
|
||||
|
||||
|
||||
@router.get('/article', description="获取文章列表")
|
||||
def article_list(request):
|
||||
if not user_has_permission(request.user, 'article', 'view'):
|
||||
return HttpResponseForbidden("无权访问")
|
||||
articles = Article.objects.all()
|
||||
return render(request, 'articles/list.html', {'articles': articles})
|
||||
Reference in New Issue
Block a user