F fix bug

pull/22/head
vapao 2020-01-08 20:45:16 +08:00
parent 1b8636536a
commit 3f4ae0819d
2 changed files with 10 additions and 8 deletions

View File

@ -111,6 +111,7 @@ class ConfigView(View):
form, error = JsonParser(
Argument('id', type=int, help='缺少必要参数'),
Argument('value', type=str, default=''),
Argument('is_public', type=bool, help='缺少必要参数'),
Argument('desc', required=False)
).parse(request.body)
if error is None:
@ -118,20 +119,18 @@ class ConfigView(View):
config = Config.objects.filter(pk=form.id).first()
if not config:
return json_response(error='未找到指定对象')
config.desc = form.desc
config.is_public = form.is_public
if config.value != form.value:
old_value = config.value
config.value = form.value
config.desc = form.desc
config.updated_at = human_datetime()
config.updated_by = request.user
config.save()
ConfigHistory.objects.create(
action='2',
old_value=old_value,
**config.to_dict(excludes=('id',)))
elif config.desc != form.desc:
config.desc = form.desc
config.save()
config.save()
return json_response(error=error)
def delete(self, request):

View File

@ -1,6 +1,6 @@
import React from 'react';
import { observer } from 'mobx-react';
import { Modal, Form, Input, Checkbox, Switch, Row, Col, message } from 'antd';
import {observer} from 'mobx-react';
import {Modal, Form, Input, Checkbox, Switch, Row, Col, message} from 'antd';
import http from 'libs/http';
import store from './store';
import envStore from '../environment/store'
@ -80,7 +80,10 @@ class ComForm extends React.Component {
</Form.Item>
{store.type === 'app' && (
<Form.Item label="类型">
{getFieldDecorator('is_public', {initialValue: info['is_public'] || true, valuePropName: 'checked'})(
{getFieldDecorator('is_public', {
initialValue: info['is_public'] === undefined || info['is_public'],
valuePropName: 'checked'
})(
<Switch checkedChildren="公共" unCheckedChildren="私有"/>
)}
</Form.Item>