authentication
This commit is contained in:
parent
ac1919161a
commit
1a2cc00aab
|
@ -129,7 +129,7 @@ class ConsumerViewSet(ModelViewSet):
|
||||||
PaySubject.objects.get_or_create(consumer = instance, subject__id=i, defaults={'consumer':instance,'subject':Questioncat.objects.get(id=i)})
|
PaySubject.objects.get_or_create(consumer = instance, subject__id=i, defaults={'consumer':instance,'subject':Questioncat.objects.get(id=i)})
|
||||||
return Response(serializer.data)
|
return Response(serializer.data)
|
||||||
|
|
||||||
@action(methods=['get'], detail=False, permission_classes=[IsAuthenticated], authentication_classes=[ConsumerTokenAuthentication],
|
@action(methods=['get'], detail=False, permission_classes=[], authentication_classes=[ConsumerTokenAuthentication],
|
||||||
url_path='subjectpaid', url_name='subject_paid')
|
url_path='subjectpaid', url_name='subject_paid')
|
||||||
def has_paid(self, request):
|
def has_paid(self, request):
|
||||||
"""
|
"""
|
||||||
|
@ -156,7 +156,7 @@ class ConsumerViewSet(ModelViewSet):
|
||||||
else:
|
else:
|
||||||
return Response({'error':result['data']})
|
return Response({'error':result['data']})
|
||||||
|
|
||||||
@action(methods=['post','delete','get'], detail=False, permission_classes=[IsAuthenticated], authentication_classes=[ConsumerTokenAuthentication],
|
@action(methods=['post','delete','get'], detail=False, permission_classes=[], authentication_classes=[ConsumerTokenAuthentication],
|
||||||
url_path='collects', url_name='create_collects')
|
url_path='collects', url_name='create_collects')
|
||||||
def collects(self, request):
|
def collects(self, request):
|
||||||
'''
|
'''
|
||||||
|
@ -274,7 +274,7 @@ class ConsumerRegister(APIView):
|
||||||
验证码登陆和注册
|
验证码登陆和注册
|
||||||
'''
|
'''
|
||||||
authentication_classes = [ConsumerTokenAuthentication]
|
authentication_classes = [ConsumerTokenAuthentication]
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = []
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
data = request.data
|
data = request.data
|
||||||
phone = data.get('phone', None)
|
phone = data.get('phone', None)
|
||||||
|
|
|
@ -26,7 +26,7 @@ from utils.custom import CommonPagination
|
||||||
|
|
||||||
class MoniTestView(APIView):
|
class MoniTestView(APIView):
|
||||||
authentication_classes = [ConsumerTokenAuthentication]
|
authentication_classes = [ConsumerTokenAuthentication]
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = []
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
serializer = MoniTestSerializer(data = request.data)
|
serializer = MoniTestSerializer(data = request.data)
|
||||||
if serializer.is_valid():
|
if serializer.is_valid():
|
||||||
|
@ -57,7 +57,7 @@ class MoniTestView(APIView):
|
||||||
|
|
||||||
class MyExamTestView(APIView):
|
class MyExamTestView(APIView):
|
||||||
authentication_classes = [ConsumerTokenAuthentication]
|
authentication_classes = [ConsumerTokenAuthentication]
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = []
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
queryset = ExamTest.objects.filter(consumer=request.user)
|
queryset = ExamTest.objects.filter(consumer=request.user)
|
||||||
pg = CommonPagination()
|
pg = CommonPagination()
|
||||||
|
@ -67,7 +67,7 @@ class MyExamTestView(APIView):
|
||||||
|
|
||||||
class MyExamTestFxView(APIView):
|
class MyExamTestFxView(APIView):
|
||||||
authentication_classes = [ConsumerTokenAuthentication]
|
authentication_classes = [ConsumerTokenAuthentication]
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = []
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
queryset = ExamTest.objects.filter(consumer=request.user)
|
queryset = ExamTest.objects.filter(consumer=request.user)
|
||||||
ret = {}
|
ret = {}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -152,7 +152,7 @@ class QuestionViewSet(ModelViewSet):
|
||||||
wb = load_workbook(fullpath)
|
wb = load_workbook(fullpath)
|
||||||
sheet = wb.worksheets[0]
|
sheet = wb.worksheets[0]
|
||||||
qlist = ['A','B','C','D','E','F']
|
qlist = ['A','B','C','D','E','F']
|
||||||
leveldict = {'低':1,'中':2,'高':3}
|
leveldict = {'低':'低','中':'中','高':'高'}
|
||||||
notinlist = []
|
notinlist = []
|
||||||
# 验证文件内容
|
# 验证文件内容
|
||||||
if sheet['a2'].value != '题目类型':
|
if sheet['a2'].value != '题目类型':
|
||||||
|
@ -199,15 +199,13 @@ class QuestionViewSet(ModelViewSet):
|
||||||
obj.type = '单选'
|
obj.type = '单选'
|
||||||
obj.questioncat = cateobj
|
obj.questioncat = cateobj
|
||||||
obj.name = name
|
obj.name = name
|
||||||
obj.answer=answer
|
obj.options=answer
|
||||||
obj.right = right
|
obj.right = right
|
||||||
obj.resolution = resolution if resolution else ''
|
obj.resolution = resolution if resolution else ''
|
||||||
if level in leveldict:
|
if level in leveldict:
|
||||||
obj.level = leveldict[level]
|
obj.level = leveldict[level]
|
||||||
else:
|
else:
|
||||||
obj.level = 1
|
obj.level = '低'
|
||||||
obj.usecomps = ','+companyid+','
|
|
||||||
obj.createuser = user
|
|
||||||
obj.save()
|
obj.save()
|
||||||
elif type == '多选':
|
elif type == '多选':
|
||||||
right = list(right)
|
right = list(right)
|
||||||
|
@ -221,13 +219,13 @@ class QuestionViewSet(ModelViewSet):
|
||||||
obj.type = '多选'
|
obj.type = '多选'
|
||||||
obj.questioncat = cateobj
|
obj.questioncat = cateobj
|
||||||
obj.name = name
|
obj.name = name
|
||||||
obj.answer=answer
|
obj.options=answer
|
||||||
obj.right = right
|
obj.right = right
|
||||||
obj.resolution = resolution if resolution else ''
|
obj.resolution = resolution if resolution else ''
|
||||||
if level in leveldict:
|
if level in leveldict:
|
||||||
obj.level = leveldict[level]
|
obj.level = leveldict[level]
|
||||||
else:
|
else:
|
||||||
obj.level = 1
|
obj.level = '低'
|
||||||
obj.save()
|
obj.save()
|
||||||
elif type == '判断':
|
elif type == '判断':
|
||||||
if right == 'A' or right == '对' or right == '正确':
|
if right == 'A' or right == '对' or right == '正确':
|
||||||
|
@ -241,13 +239,13 @@ class QuestionViewSet(ModelViewSet):
|
||||||
obj.type = '判断'
|
obj.type = '判断'
|
||||||
obj.questioncat = cateobj
|
obj.questioncat = cateobj
|
||||||
obj.name = name
|
obj.name = name
|
||||||
obj.answer={'A':'对','B':'错'}
|
obj.options={'A':'对','B':'错'}
|
||||||
obj.right = right
|
obj.right = right
|
||||||
obj.resolution = resolution if resolution else ''
|
obj.resolution = resolution if resolution else ''
|
||||||
if level in leveldict:
|
if level in leveldict:
|
||||||
obj.level = leveldict[level]
|
obj.level = leveldict[level]
|
||||||
else:
|
else:
|
||||||
obj.level = 1
|
obj.level = '低'
|
||||||
obj.save()
|
obj.save()
|
||||||
i = i +1
|
i = i +1
|
||||||
if notinlist:
|
if notinlist:
|
||||||
|
@ -257,7 +255,7 @@ class QuestionViewSet(ModelViewSet):
|
||||||
|
|
||||||
class ExerciseView(APIView):
|
class ExerciseView(APIView):
|
||||||
authentication_classes = [ConsumerTokenAuthentication]
|
authentication_classes = [ConsumerTokenAuthentication]
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = []
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
questioncat = request.data['questioncat']
|
questioncat = request.data['questioncat']
|
||||||
queryset = Question.objects.filter(is_delete=0,questioncat=questioncat)
|
queryset = Question.objects.filter(is_delete=0,questioncat=questioncat)
|
||||||
|
|
Loading…
Reference in New Issue