1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 07:41:26 +00:00

update upload-license api and info page js code (#3919)

This commit is contained in:
Leo
2019-07-25 20:48:17 +08:00
committed by Daniel Pan
parent 3901f6fa79
commit 4a4e280098
3 changed files with 8 additions and 9 deletions

View File

@@ -15,7 +15,8 @@ class Info extends Component {
this.state = {
loading: true,
errorMsg: '',
sysInfo: {}
sysInfo: {},
with_license: false
};
}
@@ -23,7 +24,8 @@ class Info extends Component {
seafileAPI.getSysInfo().then((res) => {
this.setState({
loading: false,
sysInfo: res.data
sysInfo: res.data,
with_license: res.data.with_license
});
}).catch((error) => {
if (error.response) {
@@ -58,7 +60,8 @@ class Info extends Component {
let info = this.state.sysInfo;
Object.assign(info, res.data);
this.setState({
sysInfo: info
sysInfo: info,
with_license: true
});
}).catch((error) => {
let errMsg = Utils.getErrorMsg(error);
@@ -85,11 +88,11 @@ class Info extends Component {
}
render() {
let { with_license, license_mode, license_to, license_expiration, org_count,
let { license_mode, license_to, license_expiration, org_count,
repos_count, total_files_count, total_storage, total_devices_count,
current_connected_devices_count, license_maxusers, multi_tenancy_enabled,
active_users_count, users_count, groups_count } = this.state.sysInfo;
let { loading, errorMsg } = this.state;
let { loading, errorMsg, with_license } = this.state;
if (loading) {
return <Loading />;

View File

@@ -63,18 +63,15 @@ class AdminLicense(APIView):
license_dict = {}
if license_dict:
with_license = True
try:
max_users = int(license_dict.get('MaxUsers', 3))
except ValueError as e:
logger.error(e)
max_users = 0
else:
with_license = False
max_users = 0
license_info = {
'with_license': with_license,
'license_expiration': license_dict.get('Expiration', ''),
'license_mode': license_dict.get('Mode', ''),
'license_maxusers': max_users,

View File

@@ -26,7 +26,6 @@ class AdminLicenseTest(BaseTestCase):
resp = self.client.post(url, {'license': f})
json_resp = json.loads(resp.content)
assert json_resp['with_license'] is True
assert json_resp['license_expiration'] is not None
assert json_resp['license_mode'] is not None
assert json_resp['license_maxusers'] is not None