mirror of https://github.com/openspug/spug
F fix bug
parent
1b8636536a
commit
3f4ae0819d
|
@ -111,6 +111,7 @@ class ConfigView(View):
|
||||||
form, error = JsonParser(
|
form, error = JsonParser(
|
||||||
Argument('id', type=int, help='缺少必要参数'),
|
Argument('id', type=int, help='缺少必要参数'),
|
||||||
Argument('value', type=str, default=''),
|
Argument('value', type=str, default=''),
|
||||||
|
Argument('is_public', type=bool, help='缺少必要参数'),
|
||||||
Argument('desc', required=False)
|
Argument('desc', required=False)
|
||||||
).parse(request.body)
|
).parse(request.body)
|
||||||
if error is None:
|
if error is None:
|
||||||
|
@ -118,19 +119,17 @@ class ConfigView(View):
|
||||||
config = Config.objects.filter(pk=form.id).first()
|
config = Config.objects.filter(pk=form.id).first()
|
||||||
if not config:
|
if not config:
|
||||||
return json_response(error='未找到指定对象')
|
return json_response(error='未找到指定对象')
|
||||||
|
config.desc = form.desc
|
||||||
|
config.is_public = form.is_public
|
||||||
if config.value != form.value:
|
if config.value != form.value:
|
||||||
old_value = config.value
|
old_value = config.value
|
||||||
config.value = form.value
|
config.value = form.value
|
||||||
config.desc = form.desc
|
|
||||||
config.updated_at = human_datetime()
|
config.updated_at = human_datetime()
|
||||||
config.updated_by = request.user
|
config.updated_by = request.user
|
||||||
config.save()
|
|
||||||
ConfigHistory.objects.create(
|
ConfigHistory.objects.create(
|
||||||
action='2',
|
action='2',
|
||||||
old_value=old_value,
|
old_value=old_value,
|
||||||
**config.to_dict(excludes=('id',)))
|
**config.to_dict(excludes=('id',)))
|
||||||
elif config.desc != form.desc:
|
|
||||||
config.desc = form.desc
|
|
||||||
config.save()
|
config.save()
|
||||||
return json_response(error=error)
|
return json_response(error=error)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { observer } from 'mobx-react';
|
import {observer} from 'mobx-react';
|
||||||
import { Modal, Form, Input, Checkbox, Switch, Row, Col, message } from 'antd';
|
import {Modal, Form, Input, Checkbox, Switch, Row, Col, message} from 'antd';
|
||||||
import http from 'libs/http';
|
import http from 'libs/http';
|
||||||
import store from './store';
|
import store from './store';
|
||||||
import envStore from '../environment/store'
|
import envStore from '../environment/store'
|
||||||
|
@ -80,7 +80,10 @@ class ComForm extends React.Component {
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{store.type === 'app' && (
|
{store.type === 'app' && (
|
||||||
<Form.Item label="类型">
|
<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="私有"/>
|
<Switch checkedChildren="公共" unCheckedChildren="私有"/>
|
||||||
)}
|
)}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
Loading…
Reference in New Issue