mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-04-26 01:22:05 +00:00
* [Update] 修改 success message, 添加资产组时可以添加资产 * [Update] system user form add label * [Update] set default cluster * [Update] 修改一些翻译 * [Bugfix] 修复重置密码bug * [Bugfix] 默认default cluster * [Bugfix] 用户添加报错 * 修改tab样式 * [Bugfix] 修复了一些显示上的bug * 修复全选按钮在搜索后仍然选择全部的问题 * [Bugfix] 修复以下bug 1. 查看执行历史异常 2. 用户授权资产页显示message * [Update] api 返回platform, 并增加web terminal nav * [Feature] 添加setting页面 * [Feature] 添加basic settings * [Update] 修改翻译 * [Update] 修改config * [Update] 启动加载common setting * [Bugfix] 修复cluster创建的bug * [Bugfix] 修复title显示Jumpserver * [Bugfix] setting tables not found * [Bugfix] settings add option * [Feature] 添加后端paging * [Bugfix] 资产列表选择别的页会报错 * [Update] check all 只选择当前页面 * [Bugfix] user login ip * [Bugfix] for login ip * [Bugfix] 修复资产列表显示bug * [Remove] labels * [Bugfix] task运行失败,因为tasks没有设置 * [Bugfix] 读取不到prefix * [Change] 修改部分翻译 * [Update] 启用ldap移动位置 * [Update] 修改翻译 * Update README.md
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
#
|
|
import json
|
|
|
|
from django import forms
|
|
from django.utils import six
|
|
from django.core.exceptions import ValidationError
|
|
|
|
|
|
class DictField(forms.Field):
|
|
widget = forms.Textarea
|
|
|
|
def to_python(self, value):
|
|
"""Returns a Python boolean object."""
|
|
# Explicitly check for the string 'False', which is what a hidden field
|
|
# will submit for False. Also check for '0', since this is what
|
|
# RadioSelect will provide. Because bool("True") == bool('1') == True,
|
|
# we don't need to handle that explicitly.
|
|
if isinstance(value, six.string_types):
|
|
try:
|
|
print(value)
|
|
value = json.loads(value)
|
|
return value
|
|
except json.JSONDecodeError:
|
|
pass
|
|
value = {}
|
|
return value
|
|
|
|
def validate(self, value):
|
|
print(value)
|
|
if not value and self.required:
|
|
raise ValidationError(self.error_messages['required'], code='required')
|
|
|
|
def has_changed(self, initial, data):
|
|
# Sometimes data or initial may be a string equivalent of a boolean
|
|
# so we should run it through to_python first to get a boolean value
|
|
return self.to_python(initial) != self.to_python(data)
|