优化代码,修复未实名认证导致存储无法修改问题

pull/10/head
youngS 4 years ago
parent ac77e8b36a
commit ef5d434c40
  1. 4
      fir_admin/package.json
  2. 77
      fir_admin/src/components/JsonEditor/index.vue
  3. 88
      fir_admin/src/views/storage/Detail.vue
  4. 183
      fir_admin/src/views/supersign/Detail.vue
  5. 199
      fir_admin/src/views/supersign/list.vue
  6. 4
      fir_client/src/components/user/FirUserStorage.vue
  7. 8
      fir_ser/admin/views/app.py
  8. 1
      fir_ser/admin/views/storage.py
  9. 70
      fir_ser/admin/views/supersign.py
  10. 15
      fir_ser/admin/views/user.py
  11. 7
      fir_ser/api/utils/serializer.py
  12. 4
      fir_ser/api/utils/utils.py
  13. 20
      fir_ser/requirements.txt

@ -17,14 +17,14 @@
"axios": "0.18.1", "axios": "0.18.1",
"core-js": "3.6.5", "core-js": "3.6.5",
"element-ui": "2.13.2", "element-ui": "2.13.2",
"js-base64": "2.5.2",
"js-cookie": "2.2.0", "js-cookie": "2.2.0",
"normalize.css": "7.0.0", "normalize.css": "7.0.0",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"path-to-regexp": "2.4.0", "path-to-regexp": "2.4.0",
"vue": "2.6.10", "vue": "2.6.10",
"vue-router": "3.0.6", "vue-router": "3.0.6",
"vuex": "3.1.0", "vuex": "3.1.0"
"js-base64": "2.5.2"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "4.4.4", "@vue/cli-plugin-babel": "4.4.4",

@ -1,77 +0,0 @@
<template>
<div class="json-editor">
<textarea ref="textarea" />
</div>
</template>
<script>
import CodeMirror from 'codemirror'
import 'codemirror/addon/lint/lint.css'
import 'codemirror/lib/codemirror.css'
import 'codemirror/theme/rubyblue.css'
require('script-loader!jsonlint')
import 'codemirror/mode/javascript/javascript'
import 'codemirror/addon/lint/lint'
import 'codemirror/addon/lint/json-lint'
export default {
name: 'JsonEditor',
/* eslint-disable vue/require-prop-types */
props: ['value'],
data() {
return {
jsonEditor: false
}
},
watch: {
value(value) {
const editorValue = this.jsonEditor.getValue()
if (value !== editorValue) {
this.jsonEditor.setValue(JSON.stringify(this.value, null, 2))
}
}
},
mounted() {
this.jsonEditor = CodeMirror.fromTextArea(this.$refs.textarea, {
lineNumbers: true,
mode: 'application/json',
gutters: ['CodeMirror-lint-markers'],
theme: 'rubyblue',
lint: true
})
this.jsonEditor.setValue(JSON.stringify(this.value, null, 2))
this.jsonEditor.on('change', cm => {
this.$emit('changed', cm.getValue())
this.$emit('input', cm.getValue())
})
},
methods: {
getValue() {
return this.jsonEditor.getValue()
}
}
}
</script>
<style lang="scss" scoped>
.json-editor {
height: 100%;
position: relative;
::v-deep {
.CodeMirror {
height: auto;
min-height: 300px;
}
.CodeMirror-scroll {
min-height: 300px;
}
.cm-s-rubyblue span.cm-string {
color: #F08047;
}
}
}
</style>

@ -20,38 +20,36 @@
<el-form-item label="存储类型"> <el-form-item label="存储类型">
<el-row :gutter="12"> <el-row :gutter="12">
<el-col :span="16"> <el-col :span="16">
<el-select v-model="postForm.storage_type" class="filter-item" placeholder="Please select"> <el-select v-model="postForm.storage_type" class="filter-item" disabled>
<el-option v-for="item in postForm.storage_choices" :key="item.id" :label="item.name" :value="item.id" /> <el-option v-for="item in postForm.storage_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select> </el-select>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item label="存储额外参数"> <el-form-item label="创建时间" prop="timestamp">
<el-row :gutter="12">
<el-col :span="21">
<div class="editor-container">
<json-editor ref="jsonEditor" v-model="postForm.additionalparameters" />
</div>
</el-col>
</el-row>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="创建时间" prop="timestamp" label-width="160px">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="8"> <el-col :span="8">
<el-date-picker :value="postForm.created_time" type="datetime" disabled /> <el-date-picker :value="postForm.created_time" type="datetime" disabled />
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item label="更新时间" prop="timestamp" label-width="160px"> <el-form-item label="更新时间" prop="timestamp">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="8"> <el-col :span="8">
<el-date-picker :value="postForm.updated_time" type="datetime" disabled /> <el-date-picker :value="postForm.updated_time" type="datetime" disabled />
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item label="存储描述信息">
<el-row :gutter="12">
<el-col :span="16">
<el-input v-model="postForm.description" :autosize="{ minRows: 4, maxRows: 6}" type="textarea" />
</el-col>
</el-row>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="存储访问access_key" label-width="160px"> <el-form-item label="存储访问access_key" label-width="160px">
<el-row :gutter="12"> <el-row :gutter="12">
<el-col :span="16"> <el-col :span="16">
@ -73,13 +71,39 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item label="存储描述信息" label-width="160px"> <div v-if="postForm.storage_type===2">
<el-row :gutter="12"> <el-form-item label="阿里云sts_role_arn" label-width="160px">
<el-col :span="16"> <el-row :gutter="12">
<el-input v-model="postForm.description" :autosize="{ minRows: 4, maxRows: 6}" type="textarea" placeholder="Please input" /> <el-col :span="16">
</el-col> <el-input v-model="postForm.sts_role_arn" />
</el-row> </el-col>
</el-form-item> </el-row>
</el-form-item>
<el-form-item label="阿里云endpoint" label-width="160px">
<el-row :gutter="12">
<el-col :span="16">
<el-input v-model="postForm.endpoint" />
</el-col>
</el-row>
</el-form-item>
<el-form-item label="阿里云下载授权方式" label-width="160px">
<el-row :gutter="12">
<el-col :span="16">
<el-select v-model="postForm.download_auth_type" class="filter-item" style="width: 100%">
<el-option v-for="item in postForm.download_auth_type_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-col>
</el-row>
</el-form-item>
<el-form-item v-if="postForm.download_auth_type===2" label="阿里云cnd_auth_key" label-width="160px">
<el-row :gutter="12">
<el-col :span="16">
<el-input v-model="postForm.cnd_auth_key" />
</el-col>
</el-row>
</el-form-item>
</div>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
@ -95,7 +119,6 @@
<script> <script>
import { getStorageInfo, updateStorageInfo } from '@/api/storage' import { getStorageInfo, updateStorageInfo } from '@/api/storage'
import JsonEditor from '@/components/JsonEditor'
const defaultForm = { const defaultForm = {
user_id: undefined, user_id: undefined,
@ -107,22 +130,25 @@ const defaultForm = {
domain_name: undefined, domain_name: undefined,
created_time: undefined, created_time: undefined,
description: undefined, description: undefined,
updated_time: undefined sts_role_arn: undefined,
endpoint: undefined,
download_auth_type: undefined,
cnd_auth_key: undefined,
updated_time: undefined,
download_auth_type_choices: []
} }
export default { export default {
name: 'StorageDetail', name: 'StorageDetail',
components: { JsonEditor }, filters: { components: { }, filters: {},
},
data() { data() {
return { return {
postForm: Object.assign({}, defaultForm), postForm: Object.assign({}, defaultForm),
loading: false, loading: false,
is_edit: false, is_edit: false
} }
}, },
computed: { computed: {},
},
created() { created() {
const id = this.$route.params && this.$route.params.id const id = this.$route.params && this.$route.params.id
this.fetchData(id) this.fetchData(id)
@ -132,7 +158,6 @@ export default {
getStorageInfo({ id: id }).then(response => { getStorageInfo({ id: id }).then(response => {
if (response.data.length === 1) { if (response.data.length === 1) {
this.postForm = response.data[0] this.postForm = response.data[0]
this.postForm.additionalparameters = this.postForm.additionalparameter
} }
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
@ -142,7 +167,6 @@ export default {
updateStorageInfo(this.postForm).then(response => { updateStorageInfo(this.postForm).then(response => {
this.$message.success('更新成功') this.$message.success('更新成功')
this.postForm = response.data this.postForm = response.data
this.postForm.additionalparameters = this.postForm.additionalparameter
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
}) })
@ -152,7 +176,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
.editor-container{ .editor-container {
position: relative; position: relative;
height: 100%; height: 100%;
} }

@ -0,0 +1,183 @@
<template>
<div class="app-container">
<el-form ref="postForm" :model="postForm" label-width="100px" :disabled="!is_edit">
<el-row>
<el-col :span="12">
<el-form-item label="用户ID">
<el-row :gutter="12">
<el-col :span="16">
<el-input :value="postForm.user_id" disabled />
</el-col>
</el-row>
</el-form-item>
<el-form-item label="存储名称">
<el-row :gutter="12">
<el-col :span="16">
<el-input v-model="postForm.name" />
</el-col>
</el-row>
</el-form-item>
<el-form-item label="存储类型">
<el-row :gutter="12">
<el-col :span="16">
<el-select v-model="postForm.storage_type" class="filter-item" disabled>
<el-option v-for="item in postForm.storage_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="创建时间" prop="timestamp">
<el-row :gutter="20">
<el-col :span="8">
<el-date-picker :value="postForm.created_time" type="datetime" disabled />
</el-col>
</el-row>
</el-form-item>
<el-form-item label="更新时间" prop="timestamp">
<el-row :gutter="20">
<el-col :span="8">
<el-date-picker :value="postForm.updated_time" type="datetime" disabled />
</el-col>
</el-row>
</el-form-item>
<el-form-item label="存储描述信息">
<el-row :gutter="12">
<el-col :span="16">
<el-input v-model="postForm.description" :autosize="{ minRows: 4, maxRows: 6}" type="textarea" />
</el-col>
</el-row>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="存储访问access_key" label-width="160px">
<el-row :gutter="12">
<el-col :span="16">
<el-input v-model="postForm.access_key" />
</el-col>
</el-row>
</el-form-item>
<el-form-item label="存储访问secret_key" label-width="160px">
<el-row :gutter="12">
<el-col :span="16">
<el-input v-model="postForm.secret_key" />
</el-col>
</el-row>
</el-form-item>
<el-form-item label="存储空间bucket_name" label-width="160px">
<el-row :gutter="12">
<el-col :span="16">
<el-input v-model="postForm.bucket_name" />
</el-col>
</el-row>
</el-form-item>
<div v-if="postForm.storage_type===2">
<el-form-item label="阿里云sts_role_arn" label-width="160px">
<el-row :gutter="12">
<el-col :span="16">
<el-input v-model="postForm.sts_role_arn" />
</el-col>
</el-row>
</el-form-item>
<el-form-item label="阿里云endpoint" label-width="160px">
<el-row :gutter="12">
<el-col :span="16">
<el-input v-model="postForm.endpoint" />
</el-col>
</el-row>
</el-form-item>
<el-form-item label="阿里云下载授权方式" label-width="160px">
<el-row :gutter="12">
<el-col :span="16">
<el-select v-model="postForm.download_auth_type" class="filter-item" style="width: 100%">
<el-option v-for="item in postForm.download_auth_type_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-col>
</el-row>
</el-form-item>
<el-form-item v-if="postForm.download_auth_type===2" label="阿里云cnd_auth_key" label-width="160px">
<el-row :gutter="12">
<el-col :span="16">
<el-input v-model="postForm.cnd_auth_key" />
</el-col>
</el-row>
</el-form-item>
</div>
</el-col>
</el-row>
</el-form>
<el-col :span="9" style="float: right">
<el-button v-if="!is_edit" type="primary" @click="is_edit=true">修改</el-button>
<div v-else>
<el-button type="primary" @click="is_edit=false">取消</el-button>
<el-button type="primary" @click="updateData">保存修改</el-button>
</div>
</el-col>
</div>
</template>
<script>
import { getStorageInfo, updateStorageInfo } from '@/api/storage'
const defaultForm = {
user_id: undefined,
name: undefined,
storage_type: undefined,
access_key: undefined,
secret_key: undefined,
bucket_name: undefined,
domain_name: undefined,
created_time: undefined,
description: undefined,
sts_role_arn: undefined,
endpoint: undefined,
download_auth_type: undefined,
cnd_auth_key: undefined,
updated_time: undefined,
download_auth_type_choices: []
}
export default {
name: 'StorageDetail',
components: { }, filters: {},
data() {
return {
postForm: Object.assign({}, defaultForm),
loading: false,
is_edit: false
}
},
computed: {},
created() {
const id = this.$route.params && this.$route.params.id
this.fetchData(id)
},
methods: {
fetchData(id) {
getStorageInfo({ id: id }).then(response => {
if (response.data.length === 1) {
this.postForm = response.data[0]
}
}).catch(err => {
console.log(err)
})
},
updateData() {
updateStorageInfo(this.postForm).then(response => {
this.$message.success('更新成功')
this.postForm = response.data
}).catch(err => {
console.log(err)
})
}
}
}
</script>
<style scoped>
.editor-container {
position: relative;
height: 100%;
}
</style>

@ -0,0 +1,199 @@
<template>
<div class="app-container">
<div class="filter-container">
<el-input v-model="listQuery.user_id" placeholder="用户ID" style="width: 140px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-input v-model="listQuery.bucket_name" placeholder="bucket_name" style="width: 300px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-input v-model="listQuery.access_key" placeholder="access_key" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-input v-model="listQuery.name" placeholder="存储名称" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-input v-model="listQuery.domain_name" placeholder="下载域名" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="handleFilter" />
<el-select v-model="listQuery.storage_type" placeholder="存储类型" clearable class="filter-item" style="width: 140px" @change="handleFilter">
<el-option v-for="item in storage_choices" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
Search
</el-button>
</div>
<el-table
v-loading="listLoading"
:data="list"
element-loading-text="Loading"
border
fit
highlight-current-row
stripe
>
<el-table-column align="center" label="ID" width="90">
<template slot-scope="scope">
{{ scope.row.id }}
</template>
</el-table-column>
<el-table-column label="用户ID" width="100" align="center">
<template slot-scope="scope">
<router-link :to="{name: 'user_info_edit',params:{id:scope.row.user_id}}">
<el-link type="primary"> {{ scope.row.user_id }}</el-link>
</router-link>
</template>
</el-table-column>
<el-table-column label="存储名称">
<template slot-scope="scope">
{{ scope.row.name }}
</template>
</el-table-column>
<el-table-column label="存储访问access_key" align="center">
<template slot-scope="scope">
<span>{{ scope.row.access_key }}</span>
</template>
</el-table-column>
<el-table-column label="存储空间bucket_name" align="center">
<template slot-scope="scope">
{{ scope.row.bucket_name }}
</template>
</el-table-column>
<el-table-column label="下载域名" align="center">
<template slot-scope="scope">
{{ scope.row.domain_name }}
</template>
</el-table-column>
<el-table-column class-name="status-col" label="存储类型" width="95" align="center">
<template slot-scope="scope">
<el-tag :type="scope.row.storage_type | certStatusFilter">{{ scope.row| certLableFilter }}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" prop="created_time" label="创建时间" width="120">
<template slot-scope="scope">
<i class="el-icon-time" />
<el-tooltip :content="scope.row.created_time">
<span>{{ scope.row.created_time|formatTime }}</span>
</el-tooltip>
</template>
</el-table-column>
<el-table-column align="center" prop="created_time" label="更新时间" width="120">
<template slot-scope="scope">
<i class="el-icon-time" />
<el-tooltip :content="scope.row.updated_time">
<span>{{ scope.row.updated_time|formatTime }}</span>
</el-tooltip>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
<template slot-scope="scope">
<router-link :to="{name: 'storage_info_edit',params:{id:scope.row.id}}">
<el-button type="primary" size="mini">
查看编辑
</el-button>
</router-link>
<el-button type="danger" size="mini" @click="deleteApp(scope.row.id)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="fetchData" />
</div>
</template>
<script>
import { getStorageInfo } from '@/api/storage'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import waves from '@/directive/waves' // waves directive
const sortOptions = [
{ label: '创建时间 Ascending', key: 'reviewed_time' },
{ label: '创建时间 Descending', key: '-reviewed_time' },
{ label: '更新时间 Ascending', key: 'created_time' },
{ label: '更新时间 Descending', key: '-created_time' }
]
export default {
name: 'StorageInfo',
components: { Pagination },
directives: { waves },
filters: {
formatTime(time) {
return time.split('T')[0]
},
certStatusFilter(status) {
const statusMap = {
'0': 'danger',
'1': 'success',
'2': 'gray',
'3': 'info'
}
return statusMap[status]
},
certLableFilter(row) {
for (const v of row.storage_choices) {
if (v.id === row.storage_type) {
return v.name
}
}
},
statusFilter(status) {
const statusMap = {
true: 'success',
false: 'danger'
}
return statusMap[status]
},
appStatusNameFilter(row) {
for (const r of row.status_choices) {
if (r.id === row.status) {
return r.name
}
}
},
appStatusFilter(status) {
const statusMap = {
'0': 'danger',
'1': 'success',
'2': 'gray'
}
return statusMap[status]
}
},
data() {
return {
list: null,
listLoading: true,
total: 0,
listQuery: {
page: 1,
limit: 10,
name: undefined,
sort: '-created_time',
bucket_name: undefined,
access_key: undefined,
storage_type: undefined,
domain_name: undefined,
user_id: undefined
},
sortOptions,
storage_choices: []
}
},
created() {
this.fetchData()
},
methods: {
handleFilter() {
this.listQuery.page = 1
this.fetchData()
},
fetchData() {
this.listLoading = true
getStorageInfo(this.listQuery).then(response => {
this.list = response.data
if (this.list && this.list.length > 0) {
this.storage_choices = this.list[0].storage_choices
}
this.total = response.total
this.listLoading = false
})
}
}
}
</script>

@ -367,9 +367,9 @@
this.$message.success('操作成功'); this.$message.success('操作成功');
this.dialogstorageVisible = false; this.dialogstorageVisible = false;
if (this.isaddflag) { if (this.isaddflag) {
this.activeName = 'setstorage'; this.activeName = 'edit';
} }
this.getstorageinfoFun(); this.get_data_from_tabname(this.activeName);
} else { } else {
this.$message.error('操作失败,' + data.msg); this.$message.error('操作失败,' + data.msg);

@ -45,8 +45,8 @@ class AppInfoView(APIView):
obj_list = Apps.objects.filter(**filter_data).order_by(sort) obj_list = Apps.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request, page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self) view=self)
serializer_obj = AdminAppsSerializer(page_serializer, many=True) serializer = AdminAppsSerializer(page_serializer, many=True)
res.data = serializer_obj.data res.data = serializer.data
res.total = obj_list.count() res.total = obj_list.count()
return Response(res.dict) return Response(res.dict)
@ -99,8 +99,8 @@ class AppReleaseInfoView(APIView):
obj_list = AppReleaseInfo.objects.filter(**filter_data).order_by(sort) obj_list = AppReleaseInfo.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request, page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self) view=self)
serializer_obj = AdminAppReleaseSerializer(page_serializer, many=True) serializer = AdminAppReleaseSerializer(page_serializer, many=True)
res.data = serializer_obj.data res.data = serializer.data
res.total = obj_list.count() res.total = obj_list.count()
return Response(res.dict) return Response(res.dict)

@ -65,7 +65,6 @@ class StorageInfoView(APIView):
serializer.save() serializer.save()
res.data = serializer.data res.data = serializer.data
return Response(res.dict) return Response(res.dict)
print(serializer.errors)
res.code = 1004 res.code = 1004
res.msg = "数据校验失败" res.msg = "数据校验失败"
return Response(res.dict) return Response(res.dict)

@ -0,0 +1,70 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# project: 4月
# author: liuyu
# date: 2021/4/11
from django.contrib import auth
from api.models import Token, UserInfo, APPSuperSignUsedInfo
from rest_framework.response import Response
from api.utils.auth import AdminTokenAuthentication
from api.utils.baseutils import get_dict_from_filter_fields
from api.utils.serializer import AdminStorageSerializer, AdminUserCertificationSerializer
from django.core.cache import cache
from rest_framework.views import APIView
import binascii
import os, datetime
from api.utils.utils import get_captcha, valid_captcha, get_choices_dict
from api.utils.response import BaseResponse
from fir_ser.settings import CACHE_KEY_TEMPLATE, LOGIN
from api.utils.storage.caches import login_auth_failed
import logging
from api.utils.throttle import VisitRegister1Throttle, VisitRegister2Throttle
from rest_framework.pagination import PageNumberPagination
logger = logging.getLogger(__name__)
class AppsPageNumber(PageNumberPagination):
page_size = 20 # 每页显示多少条
page_size_query_param = 'limit' # URL中每页显示条数的参数
page_query_param = 'page' # URL中页码的参数
max_page_size = None # 最大页码数限制
class StorageInfoView(APIView):
authentication_classes = [AdminTokenAuthentication, ]
def get(self, request):
res = BaseResponse()
filter_fields = ["id", "user_id", "name", "storage_type", "access_key", "bucket_name"]
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params)
sort = request.query_params.get("sort", "-created_time")
page_obj = AppsPageNumber()
obj_list = AppStorage.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self)
serializer = AdminStorageSerializer(page_serializer, many=True)
res.data = serializer.data
res.total = obj_list.count()
return Response(res.dict)
def put(self, request):
res = BaseResponse()
data = request.data
pk = data.get("id", None)
if not pk:
res.code = 1003
res.msg = "参数错误"
return Response(res.dict)
obj = AppStorage.objects.filter(pk=pk).first()
if obj:
data['pk'] = pk
serializer = AdminStorageSerializer(obj, data=data, partial=True)
if serializer.is_valid():
serializer.save()
res.data = serializer.data
return Response(res.dict)
res.code = 1004
res.msg = "数据校验失败"
return Response(res.dict)

@ -47,12 +47,12 @@ class UserInfoView(APIView):
else: else:
filter_data["certification__status"] = certification filter_data["certification__status"] = certification
page_obj = AppsPageNumber() page_obj = AppsPageNumber()
users_obj_list = UserInfo.objects.filter(**filter_data).order_by(sort) obj_list = UserInfo.objects.filter(**filter_data).order_by(sort)
users_page_serializer = page_obj.paginate_queryset(queryset=users_obj_list, request=request, page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self) view=self)
users_serializer = AdminUserInfoSerializer(users_page_serializer, many=True) serializer = AdminUserInfoSerializer(page_serializer, many=True)
res.data = users_serializer.data res.data = serializer.data
res.total = users_obj_list.count() res.total = obj_list.count()
return Response(res.dict) return Response(res.dict)
def put(self, request): def put(self, request):
@ -91,8 +91,8 @@ class UserCertificationInfoView(APIView):
obj_list = UserCertificationInfo.objects.filter(**filter_data).order_by(sort) obj_list = UserCertificationInfo.objects.filter(**filter_data).order_by(sort)
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request, page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request,
view=self) view=self)
users_serializer = AdminUserCertificationSerializer(page_serializer, many=True) serializer = AdminUserCertificationSerializer(page_serializer, many=True)
res.data = users_serializer.data res.data = serializer.data
res.total = obj_list.count() res.total = obj_list.count()
return Response(res.dict) return Response(res.dict)
@ -112,7 +112,6 @@ class UserCertificationInfoView(APIView):
users_serializer.save() users_serializer.save()
res.data = users_serializer.data res.data = users_serializer.data
return Response(res.dict) return Response(res.dict)
print(users_serializer.errors)
res.code = 1004 res.code = 1004
res.msg = "数据校验失败" res.msg = "数据校验失败"
return Response(res.dict) return Response(res.dict)

@ -360,15 +360,10 @@ class AdminStorageSerializer(StorageSerializer):
class Meta: class Meta:
model = models.AppStorage model = models.AppStorage
fields = "__all__" fields = "__all__"
read_only_fields = ["id", "user_id", "updated_time", "created_time"] read_only_fields = ["id", "user_id", "updated_time", "created_time", "storage_type"]
additionalparameters = serializers.CharField()
storage_choices = serializers.SerializerMethodField() storage_choices = serializers.SerializerMethodField()
def validate_additionalparameters(self, additionalparameters):
print(additionalparameters)
return json.dumps(additionalparameters)
def get_storage_choices(self, obj): def get_storage_choices(self, obj):
return get_choices_dict(obj.storage_choices) return get_choices_dict(obj.storage_choices)

@ -238,9 +238,9 @@ def migrating_storage_file_data(user_obj, filename, new_storage_obj, clean_old_d
def migrating_storage_data(user_obj, new_storage_obj, clean_old_data): def migrating_storage_data(user_obj, new_storage_obj, clean_old_data):
with cache.lock("%s_%s" % ('migrating_storage_data', user_obj.uid)): with cache.lock("%s_%s" % ('migrating_storage_data', user_obj.uid)):
status = user_obj.certification.status
auth_status = False auth_status = False
if status and status == 1: certification = getattr(user_obj, 'certification', None)
if certification and certification.status == 1:
auth_status = True auth_status = True
for app_release_obj in AppReleaseInfo.objects.filter(app_id__user_id=user_obj).all(): for app_release_obj in AppReleaseInfo.objects.filter(app_id__user_id=user_obj).all():
# 迁移APP数据 # 迁移APP数据

@ -3,6 +3,7 @@ aliyun-python-sdk-core-v3==2.13.11
aliyun-python-sdk-kms==2.10.1 aliyun-python-sdk-kms==2.10.1
aliyun-python-sdk-sts==3.0.1 aliyun-python-sdk-sts==3.0.1
androguard==3.3.5 androguard==3.3.5
appdirs==1.4.4
APScheduler==3.6.3 APScheduler==3.6.3
asgiref==3.2.3 asgiref==3.2.3
asn1crypto==1.3.0 asn1crypto==1.3.0
@ -13,12 +14,17 @@ certifi==2019.11.28
cffi==1.14.0 cffi==1.14.0
chardet==3.0.4 chardet==3.0.4
Click==7.0 Click==7.0
codecov==2.1.11
colorama==0.4.3 colorama==0.4.3
construct==2.10.61 construct==2.10.61
coverage==5.5
crcmod==1.7 crcmod==1.7
cryptodemo==0.0.1
Cryptodome==1.0
cryptography==3.4.6 cryptography==3.4.6
cycler==0.10.0 cycler==0.10.0
decorator==4.4.2 decorator==4.4.2
distlib==0.3.1
Django==3.0.3 Django==3.0.3
django-apscheduler==0.3.0 django-apscheduler==0.3.0
django-qrcode==0.3 django-qrcode==0.3
@ -29,8 +35,11 @@ django-simple-captcha==0.5.12
djangorestframework==3.11.0 djangorestframework==3.11.0
dnspython==1.16.0 dnspython==1.16.0
drf-extensions==0.6.0 drf-extensions==0.6.0
filelock==3.0.12
future==0.18.2 future==0.18.2
idna==2.9 idna==2.9
importlib-metadata==3.10.0
importlib-resources==5.1.2
ipython==7.13.0 ipython==7.13.0
ipython-genutils==0.2.0 ipython-genutils==0.2.0
jedi==0.16.0 jedi==0.16.0
@ -39,20 +48,26 @@ kiwisolver==1.1.0
lxml==4.5.0 lxml==4.5.0
matplotlib==3.2.0 matplotlib==3.2.0
memoizer==0.0.1 memoizer==0.0.1
mock==2.0.0
mysqlclient==1.4.6 mysqlclient==1.4.6
networkx==2.4 networkx==2.4
numpy==1.18.1 numpy==1.18.1
oss2==2.9.1 oss2==2.9.1
packaging==20.9
paramiko==2.7.1 paramiko==2.7.1
parso==0.6.2 parso==0.6.2
pbr==5.5.1
pexpect==4.8.0 pexpect==4.8.0
pickleshare==0.7.5 pickleshare==0.7.5
Pillow==7.0.0 Pillow==7.0.0
pluggy==0.13.1
prompt-toolkit==3.0.3 prompt-toolkit==3.0.3
ptyprocess==0.6.0 ptyprocess==0.6.0
py==1.10.0
pyasn1==0.4.8 pyasn1==0.4.8
pycparser==2.20 pycparser==2.20
pycryptodome==3.10.1 pycryptodome==3.10.1
pycryptodomex==3.9.4
pydot==1.4.1 pydot==1.4.1
Pygments==2.5.2 Pygments==2.5.2
PyJWT==1.7.1 PyJWT==1.7.1
@ -68,9 +83,14 @@ requests==2.23.0
rsa==4.7.2 rsa==4.7.2
six==1.14.0 six==1.14.0
sqlparse==0.3.1 sqlparse==0.3.1
toml==0.10.2
tox==3.23.0
traitlets==4.3.3 traitlets==4.3.3
typing-extensions==3.7.4.3
tzlocal==2.0.0 tzlocal==2.0.0
urllib3==1.25.8 urllib3==1.25.8
uWSGI==2.0.18 uWSGI==2.0.18
virtualenv==20.4.3
wcwidth==0.1.8 wcwidth==0.1.8
xmltodict==0.12.0 xmltodict==0.12.0
zipp==3.4.1
Loading…
Cancel
Save