Compare commits
14 Commits
master
...
ZZH_branch
| Author | SHA1 | Date |
|---|---|---|
|
|
6940e99505 | 3 months ago |
|
|
bc1c23651b | 4 months ago |
|
|
1464f795a6 | 4 months ago |
|
|
e376743740 | 4 months ago |
|
|
240d09766e | 4 months ago |
|
|
eac0e510ba | 5 months ago |
|
|
8c0869ab66 | 5 months ago |
|
|
154371d159 | 5 months ago |
|
|
05bb81e0db | 5 months ago |
|
|
e84a12fdd9 | 5 months ago |
|
|
14128d8760 | 5 months ago |
|
|
841c9a392c | 5 months ago |
|
|
a9b915938d | 5 months ago |
|
|
08f6c20cc2 | 5 months ago |
@ -0,0 +1 @@
|
||||
undefine
|
||||
@ -0,0 +1 @@
|
||||
This is for doc folder
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
# 文档目录 - 项目文档将存放于此
|
||||
@ -1,40 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 显示脚本开始执行
|
||||
echo "脚本开始执行..."
|
||||
|
||||
# 从键盘读取文件名
|
||||
read -p "请输入文件名: " filename
|
||||
|
||||
# 检查文件是否存在
|
||||
if [ ! -e "$filename" ]; then
|
||||
echo "错误:文件 '$filename' 不存在!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "文件 '$filename' 存在"
|
||||
|
||||
# 检查文件是否是符号链接
|
||||
if [ -L "$filename" ]; then
|
||||
echo "检测到 '$filename' 是一个符号链接文件"
|
||||
|
||||
# 获取文件名部分(不包括路径)
|
||||
base_name=$(basename "$filename")
|
||||
|
||||
# 移动文件到/tmp目录
|
||||
echo "正在将 '$filename' 移动到 /tmp/$base_name"
|
||||
mv "$filename" "/tmp/$base_name"
|
||||
|
||||
# 检查移动是否成功
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "移动成功!文件现在位于 /tmp/$base_name"
|
||||
else
|
||||
echo "移动失败!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "'$filename' 不是符号链接文件,不进行任何处理"
|
||||
fi
|
||||
|
||||
echo "脚本执行完毕"
|
||||
exit 0
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
undefined
|
||||
@ -1,10 +0,0 @@
|
||||
# apps.py - Django应用程序配置文件
|
||||
|
||||
# 导入Django应用配置基类
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
# 定义账户应用的配置类
|
||||
class AccountsConfig(AppConfig):
|
||||
# 指定应用程序的完整Python路径
|
||||
name = 'accounts'
|
||||
@ -1,47 +0,0 @@
|
||||
from django.contrib import admin
|
||||
from django.urls import reverse
|
||||
from django.utils.html import format_html
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
def disable_commentstatus(modeladmin, request, queryset):
|
||||
queryset.update(is_enable=False) # 杨智鑫:批量设置评论为禁用状态
|
||||
|
||||
|
||||
def enable_commentstatus(modeladmin, request, queryset):
|
||||
queryset.update(is_enable=True) # 杨智鑫:批量设置评论为启用状态
|
||||
|
||||
|
||||
disable_commentstatus.short_description = _('Disable comments') # 杨智鑫:批量禁用评论
|
||||
enable_commentstatus.short_description = _('Enable comments') # 杨智鑫:批量启用评论
|
||||
|
||||
|
||||
class CommentAdmin(admin.ModelAdmin):
|
||||
list_per_page = 20
|
||||
list_display = (
|
||||
'id',
|
||||
'body',
|
||||
'link_to_userinfo',
|
||||
'link_to_article',
|
||||
'is_enable',
|
||||
'creation_time') # 杨智鑫:显示
|
||||
list_display_links = ('id', 'body', 'is_enable') # 杨智鑫:可点击
|
||||
list_filter = ('is_enable',) # 杨智鑫:过滤
|
||||
exclude = ('creation_time', 'last_modify_time') # 杨智鑫:不显示创建时间
|
||||
actions = [disable_commentstatus, enable_commentstatus] # 杨智鑫:批量操作
|
||||
|
||||
def link_to_userinfo(self, obj):
|
||||
info = (obj.author._meta.app_label, obj.author._meta.model_name) # 杨智鑫:获取用户信息
|
||||
link = reverse('admin:%s_%s_change' % info, args=(obj.author.id,)) # 杨智鑫:获取用户信息
|
||||
return format_html(
|
||||
u'<a href="%s">%s</a>' %
|
||||
(link, obj.author.nickname if obj.author.nickname else obj.author.email)) # 杨智鑫:获取用户信息
|
||||
|
||||
def link_to_article(self, obj):
|
||||
info = (obj.article._meta.app_label, obj.article._meta.model_name)
|
||||
link = reverse('admin:%s_%s_change' % info, args=(obj.article.id,)) # 杨智鑫:获取文章信息
|
||||
return format_html(
|
||||
u'<a href="%s">%s</a>' % (link, obj.article.title)) # 杨智鑫:获取文章信息
|
||||
|
||||
link_to_userinfo.short_description = _('User') # 杨智鑫:用户
|
||||
link_to_article.short_description = _('Article') # 杨智鑫:文章
|
||||
@ -1,11 +0,0 @@
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
app_name = "comments" # 杨智鑫:定义应用命名空间
|
||||
urlpatterns = [
|
||||
path(
|
||||
'article/<int:article_id>/postcomment',
|
||||
views.CommentPostView.as_view(), # 杨智鑫:定义路由
|
||||
name='postcomment'), # 杨智鑫:定义路由名称
|
||||
]
|
||||
@ -1,57 +0,0 @@
|
||||
# Generated by Django 4.1.7 on 2023-03-07 09:53
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='OAuthConfig',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('type', models.CharField(choices=[('weibo', '微博'), ('google', '谷歌'), ('github', 'GitHub'), ('facebook', 'FaceBook'), ('qq', 'QQ')], default='a', max_length=10, verbose_name='类型')),
|
||||
('appkey', models.CharField(max_length=200, verbose_name='AppKey')),
|
||||
('appsecret', models.CharField(max_length=200, verbose_name='AppSecret')),
|
||||
('callback_url', models.CharField(default='http://www.baidu.com', max_length=200, verbose_name='回调地址')),
|
||||
('is_enable', models.BooleanField(default=True, verbose_name='是否显示')),
|
||||
('created_time', models.DateTimeField(default=django.utils.timezone.now, verbose_name='创建时间')),
|
||||
('last_mod_time', models.DateTimeField(default=django.utils.timezone.now, verbose_name='修改时间')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'oauth配置',
|
||||
'verbose_name_plural': 'oauth配置',
|
||||
'ordering': ['-created_time'],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='OAuthUser',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('openid', models.CharField(max_length=50)),
|
||||
('nickname', models.CharField(max_length=50, verbose_name='昵称')),
|
||||
('token', models.CharField(blank=True, max_length=150, null=True)),
|
||||
('picture', models.CharField(blank=True, max_length=350, null=True)),
|
||||
('type', models.CharField(max_length=50)),
|
||||
('email', models.CharField(blank=True, max_length=50, null=True)),
|
||||
('metadata', models.TextField(blank=True, null=True)),
|
||||
('created_time', models.DateTimeField(default=django.utils.timezone.now, verbose_name='创建时间')),
|
||||
('last_mod_time', models.DateTimeField(default=django.utils.timezone.now, verbose_name='修改时间')),
|
||||
('author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'oauth用户',
|
||||
'verbose_name_plural': 'oauth用户',
|
||||
'ordering': ['-created_time'],
|
||||
},
|
||||
),
|
||||
]
|
||||
@ -1,22 +0,0 @@
|
||||
from django import template
|
||||
from django.urls import reverse
|
||||
|
||||
from oauth.oauthmanager import get_oauth_apps
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.inclusion_tag('oauth/oauth_applications.html')
|
||||
def load_oauth_applications(request):
|
||||
applications = get_oauth_apps()
|
||||
if applications:
|
||||
baseurl = reverse('oauth:oauthlogin')
|
||||
path = request.get_full_path()
|
||||
|
||||
apps = list(map(lambda x: (x.ICON_NAME, '{baseurl}?type={type}&next_url={next}'.format(
|
||||
baseurl=baseurl, type=x.ICON_NAME, next=path)), applications))
|
||||
else:
|
||||
apps = []
|
||||
return {
|
||||
'apps': apps
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
# 源代码目录 - 项目源代码将存放于此
|
||||
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AccountsConfig(AppConfig):
|
||||
name = 'accounts'
|
||||
@ -0,0 +1,28 @@
|
||||
from django.urls import path
|
||||
from django.urls import re_path
|
||||
|
||||
from . import views
|
||||
from .forms import LoginForm
|
||||
|
||||
app_name = "accounts"
|
||||
|
||||
urlpatterns = [re_path(r'^login/$',
|
||||
views.LoginView.as_view(success_url='/'),
|
||||
name='login',
|
||||
kwargs={'authentication_form': LoginForm}),
|
||||
re_path(r'^register/$',
|
||||
views.RegisterView.as_view(success_url="/"),
|
||||
name='register'),
|
||||
re_path(r'^logout/$',
|
||||
views.LogoutView.as_view(),
|
||||
name='logout'),
|
||||
path(r'account/result.html',
|
||||
views.account_result,
|
||||
name='result'),
|
||||
re_path(r'^forget_password/$',
|
||||
views.ForgetPasswordView.as_view(),
|
||||
name='forget_password'),
|
||||
re_path(r'^forget_password_code/$',
|
||||
views.ForgetPasswordEmailCode.as_view(),
|
||||
name='forget_password_code'),
|
||||
]
|
||||
@ -0,0 +1,26 @@
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.backends import ModelBackend
|
||||
|
||||
|
||||
class EmailOrUsernameModelBackend(ModelBackend):
|
||||
"""
|
||||
允许使用用户名或邮箱登录
|
||||
"""
|
||||
|
||||
def authenticate(self, request, username=None, password=None, **kwargs):
|
||||
if '@' in username:
|
||||
kwargs = {'email': username}
|
||||
else:
|
||||
kwargs = {'username': username}
|
||||
try:
|
||||
user = get_user_model().objects.get(**kwargs)
|
||||
if user.check_password(password):
|
||||
return user
|
||||
except get_user_model().DoesNotExist:
|
||||
return None
|
||||
|
||||
def get_user(self, username):
|
||||
try:
|
||||
return get_user_model().objects.get(pk=username)
|
||||
except get_user_model().DoesNotExist:
|
||||
return None
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue