管理员默认存储配置

super_signature 3.1.1
nineven 5 years ago
parent 15e88b9b59
commit 8de6e4a87d
  1. 4
      fir_client/src/components/FirUserProfileStorage.vue
  2. 2
      fir_ser/api/utils/storage/storage.py
  3. 4
      fir_ser/api/views/storage.py

@ -1,6 +1,6 @@
<template> <template>
<div style="text-align:center"> <div style="text-align:center">
<h2 v-if="is_admin_storage">管理员存储您配置的存储将决定其他用户配置的默认存储请谨慎修改</h2>
<el-dialog :title="title" :visible.sync="dialogstorageVisible" :destroy-on-close="true" :close-on-click-modal="false"> <el-dialog :title="title" :visible.sync="dialogstorageVisible" :destroy-on-close="true" :close-on-click-modal="false">
<el-form v-if="editstorageinfo.id !==-1" ref="storageinfoform" :model="editstorageinfo" <el-form v-if="editstorageinfo.id !==-1" ref="storageinfoform" :model="editstorageinfo"
@ -216,6 +216,7 @@
isaddflag: false, isaddflag: false,
activeName: 'chostorage', activeName: 'chostorage',
storage_info_lists: [], storage_info_lists: [],
is_admin_storage:false,
} }
}, methods: { }, methods: {
deepCopy(source) { deepCopy(source) {
@ -364,6 +365,7 @@
this.org_storage_id=this.use_storage_id = data.storage; this.org_storage_id=this.use_storage_id = data.storage;
this.storage_list = data.storage_list; this.storage_list = data.storage_list;
this.storage_info_lists = data.data; this.storage_info_lists = data.data;
this.is_admin_storage = data.is_admin_storage;
this.format_storage(data.data); this.format_storage(data.data);
this.disabled=true; this.disabled=true;
this.isaddflag=false; this.isaddflag=false;

@ -71,7 +71,7 @@ class Storage(object):
return self.get_default_storage(user) return self.get_default_storage(user)
def get_default_storage(self,user): def get_default_storage(self,user):
admin_storage = UserInfo.objects.first().storage admin_storage = UserInfo.objects.filter(is_superuser=True).order_by('pk').first().storage
if admin_storage: if admin_storage:
return self.get_storage(UserInfo) return self.get_storage(UserInfo)
else: else:

@ -44,6 +44,10 @@ class StorageView(APIView):
if storage_t[0] in [0, 3]: continue if storage_t[0] in [0, 3]: continue
res.storage_list.append({'id': storage_t[0], 'name': storage_t[1]}) res.storage_list.append({'id': storage_t[0], 'name': storage_t[1]})
admin_storage = UserInfo.objects.filter(is_superuser=True).order_by('pk').first()
res.is_admin_storage=False
if admin_storage.uid == request.user.uid:
res.is_admin_storage = True
return Response(res.dict) return Response(res.dict)
def post(self, request): def post(self, request):

Loading…
Cancel
Save