Skip to content

Commit

Permalink
更新帖子管理分页
Browse files Browse the repository at this point in the history
  • Loading branch information
xishandong committed Jul 16, 2023
1 parent 9d9ee44 commit 904c806
Show file tree
Hide file tree
Showing 28 changed files with 6 additions and 7 deletions.
Binary file removed Server01/static/img/post/22-img1.jpg
Binary file not shown.
Binary file removed Server01/static/img/post/24-img3.jpg
Binary file not shown.
Binary file removed Server01/static/img/post/25-project.png
Binary file not shown.
Binary file removed Server01/static/img/post/26-user.jpg
Binary file not shown.
Binary file removed Server01/static/img/post/27-img.jpg
Binary file not shown.
Binary file removed Server01/static/img/post/29-avatar.jpg
Binary file not shown.
Binary file removed Server01/static/img/post/30-avatar.jpg
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added Server01/static/img/post/51-04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added Server01/static/img/post/55-search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added Server01/static/img/post/59-池秀媛.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Server01/static/img/post/60-金智秀.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
Binary file modified Server01/util/__pycache__/verifyJWT.cpython-39.pyc
Binary file not shown.
7 changes: 2 additions & 5 deletions Server01/util/verifyJWT.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ def wrapper(request, *args, **kwargs):
try:
token = request.headers.get('Authorization').split(' ')[1]
verify_payload = jwt.decode(token, SECRET_KEY, ['HS256'], verify=True)
# 检查数据库是否存在该用户
if models.User.objects.filter(id=verify_payload.get('user_id')).exists():
return view_func(request, verify_payload, *args, **kwargs)
return JsonResponse({'error': '未授权访问'}, status=401)
return view_func(request, verify_payload, *args, **kwargs)
except exceptions.ExpiredSignatureError:
error_message = {'error': '登录身份过期'}
return JsonResponse(error_message, status=401)
Expand All @@ -44,7 +41,7 @@ def create_token(user):
payload = {
'user_id': user.id,
'username': user.username,
'exp': datetime.datetime.utcnow() + datetime.timedelta(minutes=60) # 设置过期时间
'exp': datetime.datetime.utcnow() + datetime.timedelta(minutes=3600, days=5) # 设置过期时间
}
result = jwt.encode(payload=payload, key=SECRET_KEY, algorithm='HS256', headers=headers)
return result
Binary file modified Server01/views/__pycache__/user.cpython-39.pyc
Binary file not shown.
6 changes: 4 additions & 2 deletions Server01/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ def update_avatar(request, payload):
@authenticate_request
def user_post_control_index(request, payload):
user_id = payload['user_id']
offset = json.loads(request.body)['offset']
user = models.User.objects.filter(id=user_id).first()
if user:
user_post = user.posts.all()
clear_user_post = filter_querySet(user_post, offset, 10)
info = [{
'date': convert_to_timezone(post.created_at, TIME_ZONE),
'title': post.title,
Expand All @@ -174,6 +176,6 @@ def user_post_control_index(request, payload):
'commentCount': post.comments.all().count(),
'content': post.content,
'id': post.id
} for post in user_post if post]
return JsonResponse({'info': info}, status=200)
} for post in clear_user_post if post]
return JsonResponse({'info': info, 'total': user_post.count()}, status=200)
return JsonResponse({'error': '错误的操作'}, status=404)
Binary file modified webServer/__pycache__/settings.cpython-39.pyc
Binary file not shown.

0 comments on commit 904c806

Please sign in to comment.