-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
574db20
commit 24e4cc3
Showing
15 changed files
with
118 additions
and
40 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 4.1 on 2023-07-11 08:21 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("Server01", "0010_remove_post_images_alter_image_post"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="user", | ||
name="followed", | ||
), | ||
] |
Binary file added
BIN
+528 Bytes
Server01/migrations/__pycache__/0011_remove_user_followed.cpython-39.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+809 Bytes
(300%)
Server01/util/__pycache__/auxiliaryFuction.cpython-39.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,45 @@ | ||
import os | ||
|
||
import pytz | ||
|
||
import Server01.models as models | ||
|
||
|
||
# 更换时区 | ||
def convert_to_timezone(datetime_obj, timezone_str): | ||
target_timezone = pytz.timezone(timezone_str) | ||
converted_datetime = datetime_obj.astimezone(target_timezone) | ||
return converted_datetime.strftime('%Y-%m-%d %H:%M') | ||
|
||
|
||
# 检查邮箱 | ||
def check_email(email): | ||
return models.User.objects.filter(email=email).exists() | ||
|
||
|
||
# 整合主页帖子的信息 | ||
def combine_index_post(posts): | ||
for post in posts: | ||
imgs = post.imgs.all() | ||
info = { | ||
'title': post.title, | ||
'id': post.id, | ||
'img': imgs[0].imagePath, | ||
'user': { | ||
'id': post.user.id, | ||
'username': post.user.username, | ||
'avatar': post.user.avatar | ||
} | ||
} | ||
yield info | ||
|
||
|
||
# 检查和删除图片,用于删除帖子时删除文件,以及删除用户上一次上传的头像 | ||
def check_and_delete(id, mainPath): | ||
# 获取目录下的文件 | ||
file_list = os.listdir(mainPath) | ||
# 遍历文件列表,检查是否有对应的文件,如果有就删除 | ||
for file_name in file_list: | ||
if file_name.startswith(f'{id}-'): | ||
file_path = os.path.join(mainPath, file_name) | ||
os.remove(file_path) |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,7 +141,8 @@ | |
# 启用 CSRF 保护 | ||
CSRF_COOKIE_HTTPONLY = True | ||
|
||
|
||
# 配置保存文件路径 | ||
SYSTEM_PATH = 'D:/vue' | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters