-
Notifications
You must be signed in to change notification settings - Fork 1
同步上游分支 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
同步上游分支 #2
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Create your views here. | ||
|
|
||
| from rest_framework.decorators import api_view, authentication_classes | ||
|
|
||
| from myapp.auth.authentication import AdminTokenAuthtication | ||
| from myapp.handler import APIResponse | ||
| from myapp.models import BasicTdk | ||
| from myapp.permission.permission import isDemoAdminUser, check_if_demo | ||
| from myapp.serializers import BasicTdkSerializer | ||
| from myapp.utils import after_call, clear_cache | ||
|
|
||
|
|
||
| @api_view(['GET']) | ||
| @authentication_classes([AdminTokenAuthtication]) | ||
| def list_api(request): | ||
| if request.method == 'GET': | ||
| basicTdk = BasicTdk.get_solo() | ||
|
|
||
| serializer = BasicTdkSerializer(basicTdk, many=False) | ||
| return APIResponse(code=0, msg='查询成功', data=serializer.data) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| @api_view(['POST']) | ||
| @authentication_classes([AdminTokenAuthtication]) | ||
| @check_if_demo | ||
| @after_call(clear_cache) | ||
| def update(request): | ||
|
|
||
| try: | ||
| basicTdk = BasicTdk.get_solo() | ||
| serializer = BasicTdkSerializer(basicTdk, data=request.data) | ||
| if serializer.is_valid(): | ||
| serializer.save() | ||
| return APIResponse(code=0, msg='更新成功', data=serializer.data) | ||
| else: | ||
| print(serializer.errors) | ||
| except BasicTdk.DoesNotExist: | ||
| return APIResponse(code=1, msg='对象不存在') | ||
|
|
||
| return APIResponse(code=1, msg='更新失败') | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,90 @@ | ||||||||||||||||||||||||||
| # Create your views here. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| from rest_framework.decorators import api_view, authentication_classes | ||||||||||||||||||||||||||
| from rest_framework.pagination import PageNumberPagination | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| from myapp.auth.authentication import AdminTokenAuthtication | ||||||||||||||||||||||||||
| from myapp.handler import APIResponse | ||||||||||||||||||||||||||
| from myapp.models import Case | ||||||||||||||||||||||||||
| from myapp.permission.permission import isDemoAdminUser, check_if_demo | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| from myapp.permission.permission import isDemoAdminUser, check_if_demo | |
| from myapp.permission.permission import check_if_demo |
Copilot
AI
Apr 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decorator order is inconsistent with other admin views: @authentication_classes(...) typically comes before @check_if_demo so auth-related request context is consistently applied. Please reorder decorators to match the established pattern for readability/consistency.
| @check_if_demo | |
| @authentication_classes([AdminTokenAuthtication]) | |
| @authentication_classes([AdminTokenAuthtication]) | |
| @check_if_demo |
Copilot
AI
Apr 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try/except Case.DoesNotExist around Case.objects.filter(...).delete() will never catch DoesNotExist because filter().delete() doesn't raise that exception. Please remove the dead exception handler and instead validate that ids is present/non-empty before deleting.
| try: | |
| ids = request.data['ids'] | |
| ids_arr = ids.split(',') | |
| Case.objects.filter(id__in=ids_arr).delete() | |
| except Case.DoesNotExist: | |
| return APIResponse(code=1, msg='对象不存在') | |
| ids = request.data.get('ids') | |
| if not ids: | |
| return APIResponse(code=1, msg='ids不能为空') | |
| ids_arr = ids.split(',') | |
| Case.objects.filter(id__in=ids_arr).delete() |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,85 @@ | ||||||||||||||||||||||||||
| # Create your views here. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| from rest_framework.decorators import api_view, authentication_classes | ||||||||||||||||||||||||||
| from rest_framework.pagination import PageNumberPagination | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| from myapp.auth.authentication import AdminTokenAuthtication | ||||||||||||||||||||||||||
| from myapp.handler import APIResponse | ||||||||||||||||||||||||||
| from myapp.models import Download | ||||||||||||||||||||||||||
| from myapp.permission.permission import isDemoAdminUser, check_if_demo | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| from myapp.permission.permission import isDemoAdminUser, check_if_demo | |
| from myapp.permission.permission import check_if_demo |
Copilot
AI
Apr 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try/except Download.DoesNotExist around Download.objects.filter(...).delete() will never catch DoesNotExist because filter().delete() doesn't raise that exception. Please remove the dead exception handler and instead validate that ids is present/non-empty before deleting.
| try: | |
| ids = request.data['ids'] | |
| ids_arr = ids.split(',') | |
| Download.objects.filter(id__in=ids_arr).delete() | |
| except Download.DoesNotExist: | |
| return APIResponse(code=1, msg='对象不存在') | |
| ids = request.data.get('ids') | |
| if not ids or not str(ids).strip(): | |
| return APIResponse(code=1, msg='ids不能为空') | |
| ids_arr = str(ids).split(',') | |
| Download.objects.filter(id__in=ids_arr).delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isDemoAdminUseris imported but never used in this module. Please remove the unused import to keep the file clean.