0bb6193 Generated by Django 5.2.7 on 2025-11-11 10:33 1de2b8d Revert "优化代码" 4a31b12 Merge remote-tracking branch 'DjangoBlog/g3f' into g3f-CodeEdit 46182cd Merge branch 'lrj_branch' into develop 8fb4c0f feat: [lrj] 完成OAuth模块代码质量分析和注释 0317508 feat: 完成OAuth模块代码质量分析和注释 1a46bfe 在更新后的代码基础上添加oauth注释 772627f Merge branch 'zy_branch' into develop 2ea3470 Merge remote-tracking branch 'origin/shw_branch' into develop f31d984 Merge remote-tracking branch 'origin/bjy_branch' into develop 890a35a Merge commit 'eac243818d651281e841188481859d3e6e251cc8' into xjj_branch 930ea2b blog注释 e0b8ad3 Merge commit '001bc85a8157f3742d79d513e5300bcf3b975edb' into xjj_branch 77ced79 accounts代码注释 0265de5 代码注释 0619247 代码注释 b32484e 代码注释 676e04a Merge commit '4e5377d89454be93a12bdc5e1d147b806ae35205' as 'src/DjangoBlog'develope50afe5移除子树以便重新添加其他分支 436a4e1 Merge remote-tracking branch 'DjangoBlog/master' into g3f6f8f33fMerge commit '524e7d1ed53ff015743c250b8695258775e4ee8e' as 'src/DjangoBlog'524e7d1Squashed 'src/DjangoBlog/' content from commit ef67f8d40f9915删除子模块引用1410b5cMerge remote-tracking branch 'origin/develop'4eefae6完善文档05188c4Merge remote-tracking branch 'origin/xjj_branch' into develop20bb6cb重新上传文件ac34e1f删除异常的文件52a8438重新上传上次提交0b6d110完成软件界面设计说明书398a282Merge branch 'xjj_branch' into develop9fcc4d5修改数据模型报告700f5f7Merge branch 'xjj_branch' into develop2fc3891撰写报告部分内容6b840e8chore: 重构项目结构4fc3fd7建模系统数据模型,第五周大作业674cbb7第五周大作业94e7af9docs: 推送数据模型设计文档初稿ace2182完成第四周作业0059353合并 lrj_branche7faf82docs: 删除无用文件c6e972f合并 bjy_branchefadb34docs: 删除无用文件f401f26合并 shw_branch7e7b376docs: 删除无用文件4cb4b01docs: 删除无用文件cd3fc6f合并 zy_branchb94181edocs: 删除无用文件7734127完成泛读报告15b9d12docs: 更新泛读报告b72011bdocs: 完成泛读报告 9b30a5b Merge branch 'master' into g3f4359e3f完成代码泛读报告第一项及第二项707d204docs(architecture): 添加项目架构图和模块类图bd7d84eUpdate 345.pydbb933d改了一行代码114143fMerge remote-tracking branch 'origin/develop' into zy_branch89e3b1b添加 DjangoBlog 子模块 df6020c feat(settings): 引入环境变量配置支持 - 添加 django-environ 和 python-dotenv依赖 - 配置文件中集成环境变量加载 - 数据库配置项改用环境变量读取 - 更新 .gitignore 忽略 .env 文件ebfac63chore(submodule): 添加 DjangoBlog 子模块9e524cf测试提交是否成功efeca121324e76e19船舰草稿9a54f8achore: 新建文件夹c4b01b8docs(README): 更新项目标题为中文177a703chore(.gitignore): 添加.idea目录到忽略文件e4a3779Initial commit git-subtree-dir: src/DjangoBlog git-subtree-split: 0bb61937df7dc53156d445d5245a8bf965c7352b
parent
eac243818d
commit
72fddfe377
@ -1,5 +1,11 @@
|
||||
#shw 导入Django的应用配置基类
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AccountsConfig(AppConfig):
|
||||
#shw 这是accounts应用的配置类。
|
||||
#shw 它用于定义该应用的各种元数据和行为。
|
||||
|
||||
#shw 指定这个配置类所属的应用的完整Python路径。
|
||||
#shw Django通过这个name来找到并加载这个应用。
|
||||
name = 'accounts'
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
# zy: 评论应用配置模块 - 定义comments应用的配置信息
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
# zy: 评论应用配置类 - 继承自Django的AppConfig基类
|
||||
class CommentsConfig(AppConfig):
|
||||
# zy: 应用名称 - 指定Django内部使用的应用标识
|
||||
# 这个名称应该与INSTALLED_APPS中的名称一致
|
||||
name = 'comments'
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
# Generated by Django 5.2.7 on 2025-11-11 10:33
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('oauth', '0003_alter_oauthuser_nickname'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='oauthconfig',
|
||||
options={'ordering': ['-creation_time'], 'verbose_name': 'OAuth配置', 'verbose_name_plural': 'OAuth配置'},
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,67 @@
|
||||
# Create your models here.
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class OAuthUser(models.Model):
|
||||
author = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
verbose_name=_('author'),
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=models.CASCADE)
|
||||
openid = models.CharField(max_length=50)
|
||||
nickname = models.CharField(max_length=50, verbose_name=_('nick name'))
|
||||
token = models.CharField(max_length=150, null=True, blank=True)
|
||||
picture = models.CharField(max_length=350, blank=True, null=True)
|
||||
type = models.CharField(blank=False, null=False, max_length=50)
|
||||
email = models.CharField(max_length=50, null=True, blank=True)
|
||||
metadata = models.TextField(null=True, blank=True)
|
||||
creation_time = models.DateTimeField(_('creation time'), default=now)
|
||||
last_modify_time = models.DateTimeField(_('last modify time'), default=now)
|
||||
|
||||
def __str__(self):
|
||||
return self.nickname
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('oauth user')
|
||||
verbose_name_plural = verbose_name
|
||||
ordering = ['-creation_time']
|
||||
|
||||
|
||||
class OAuthConfig(models.Model):
|
||||
TYPE = (
|
||||
('weibo', _('weibo')),
|
||||
('google', _('google')),
|
||||
('github', 'GitHub'),
|
||||
('facebook', 'FaceBook'),
|
||||
('qq', 'QQ'),
|
||||
)
|
||||
type = models.CharField(_('type'), max_length=10, choices=TYPE, default='a')
|
||||
appkey = models.CharField(max_length=200, verbose_name='AppKey')
|
||||
appsecret = models.CharField(max_length=200, verbose_name='AppSecret')
|
||||
callback_url = models.CharField(
|
||||
max_length=200,
|
||||
verbose_name=_('callback url'),
|
||||
blank=False,
|
||||
default='')
|
||||
is_enable = models.BooleanField(
|
||||
_('is enable'), default=True, blank=False, null=False)
|
||||
creation_time = models.DateTimeField(_('creation time'), default=now)
|
||||
last_modify_time = models.DateTimeField(_('last modify time'), default=now)
|
||||
|
||||
def clean(self):
|
||||
if OAuthConfig.objects.filter(
|
||||
type=self.type).exclude(id=self.id).count():
|
||||
raise ValidationError(_(self.type + _('already exists')))
|
||||
|
||||
def __str__(self):
|
||||
return self.type
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'oauth配置'
|
||||
verbose_name_plural = verbose_name
|
||||
ordering = ['-creation_time']
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in new issue