mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
修复 decorator 导致 swagger 无法识别注释的问题
This commit is contained in:
parent
309401f755
commit
5273e9a48d
@ -1,4 +1,5 @@
|
||||
# coding=utf-8
|
||||
from functools import wraps
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
@ -7,6 +8,7 @@ from .models import User
|
||||
|
||||
|
||||
def login_required(func):
|
||||
@wraps(func)
|
||||
def check(*args, **kwargs):
|
||||
# 在class based views 里面,args 有两个元素,一个是self, 第二个才是request,
|
||||
# 在function based views 里面,args 只有request 一个参数
|
||||
@ -21,6 +23,7 @@ def login_required(func):
|
||||
|
||||
|
||||
def admin_required(func):
|
||||
@wraps(func)
|
||||
def check(*args, **kwargs):
|
||||
request = args[-1]
|
||||
if request.user.is_authenticated() and request.user.admin_type:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user