Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
eba7a728
J
jumpserver
项目概览
gjl2004yn
/
jumpserver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jumpserver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
eba7a728
编写于
4月 09, 2021
作者:
X
xinwen
提交者:
baltery
4月 09, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 修复 test cookie 问题,删掉key=0迁移脚本
上级
bd11018c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
1 addition
and
59 deletion
+1
-59
apps/assets/migrations/0069_change_node_key0_to_key1.py
apps/assets/migrations/0069_change_node_key0_to_key1.py
+0
-59
apps/authentication/views/login.py
apps/authentication/views/login.py
+1
-0
未找到文件。
apps/assets/migrations/0069_change_node_key0_to_key1.py
已删除
100644 → 0
浏览文件 @
bd11018c
from
django.db
import
migrations
from
django.db.transaction
import
atomic
default_id
=
'00000000-0000-0000-0000-000000000002'
def
change_key0_to_key1
(
apps
,
schema_editor
):
from
orgs.utils
import
set_current_org
# https://stackoverflow.com/questions/28777338/django-migrations-runpython-not-able-to-call-model-methods
Organization
=
apps
.
get_model
(
'orgs'
,
'Organization'
)
Node
=
apps
.
get_model
(
'assets'
,
'Node'
)
print
()
org
=
Organization
.
objects
.
get
(
id
=
default_id
)
set_current_org
(
org
)
exists_0
=
Node
.
objects
.
filter
(
key__startswith
=
'0'
).
exists
()
if
not
exists_0
:
print
(
f
'--> Not exist key=0 nodes, do nothing.'
)
return
key_1_count
=
Node
.
objects
.
filter
(
key__startswith
=
'1'
).
count
()
if
key_1_count
>
1
:
print
(
f
'--> Node key=1 have children, can`t just delete it. Please contact JumpServer team'
)
return
root_node
=
Node
.
objects
.
filter
(
key
=
'1'
).
first
()
if
root_node
and
root_node
.
assets
.
exists
():
print
(
f
'--> Node key=1 has assets, do nothing.'
)
return
with
atomic
():
if
root_node
:
print
(
f
'--> Delete node key=1'
)
root_node
.
delete
()
nodes_0
=
Node
.
objects
.
filter
(
key__startswith
=
'0'
)
for
n
in
nodes_0
:
old_key
=
n
.
key
key_list
=
n
.
key
.
split
(
':'
)
key_list
[
0
]
=
'1'
new_key
=
':'
.
join
(
key_list
)
n
.
key
=
new_key
n
.
save
()
print
(
'--> Modify key ( {} > {} )'
.
format
(
old_key
,
new_key
))
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'orgs'
,
'0010_auto_20210219_1241'
),
(
'assets'
,
'0068_auto_20210312_1455'
),
]
operations
=
[
migrations
.
RunPython
(
change_key0_to_key1
)
]
apps/authentication/views/login.py
浏览文件 @
eba7a728
...
@@ -69,6 +69,7 @@ class UserLoginView(mixins.AuthMixin, FormView):
...
@@ -69,6 +69,7 @@ class UserLoginView(mixins.AuthMixin, FormView):
new_form
=
form_cls
(
data
=
form
.
data
)
new_form
=
form_cls
(
data
=
form
.
data
)
new_form
.
_errors
=
form
.
errors
new_form
.
_errors
=
form
.
errors
context
=
self
.
get_context_data
(
form
=
new_form
)
context
=
self
.
get_context_data
(
form
=
new_form
)
self
.
request
.
session
.
set_test_cookie
()
return
self
.
render_to_response
(
context
)
return
self
.
render_to_response
(
context
)
except
(
errors
.
PasswdTooSimple
,
errors
.
PasswordRequireResetError
)
as
e
:
except
(
errors
.
PasswdTooSimple
,
errors
.
PasswordRequireResetError
)
as
e
:
return
redirect
(
e
.
url
)
return
redirect
(
e
.
url
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录