mirror of https://github.com/veops/cmdb.git
Sunny_CMDB
--- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/veops/cmdb?shareId=XXXX-XXXX-XXXX-XXXX).
This commit is contained in:
parent
47332aca3c
commit
5d0632b2ab
|
@ -28,6 +28,7 @@ from api.models.cmdb import CIType
|
||||||
from api.models.cmdb import CITypeAttribute
|
from api.models.cmdb import CITypeAttribute
|
||||||
from api.models.cmdb import CITypeAttributeGroupItem
|
from api.models.cmdb import CITypeAttributeGroupItem
|
||||||
from api.models.cmdb import PreferenceShowAttributes
|
from api.models.cmdb import PreferenceShowAttributes
|
||||||
|
from api.lib.common_setting.upload_file import CommonFileCRUD
|
||||||
|
|
||||||
|
|
||||||
class AttributeManager(object):
|
class AttributeManager(object):
|
||||||
|
@ -462,3 +463,20 @@ class AttributeManager(object):
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def review_attribute(attr_id):
|
||||||
|
attr = Attribute.get_by_id(attr_id) or abort(404, ErrFormat.attribute_not_found.format("id={}".format(attr_id)))
|
||||||
|
|
||||||
|
if not attr.is_review:
|
||||||
|
return abort(400, ErrFormat.attribute_not_reviewable)
|
||||||
|
|
||||||
|
if attr.is_upload_file:
|
||||||
|
file_data = CommonFileCRUD.get_file(attr.name)
|
||||||
|
return file_data
|
||||||
|
|
||||||
|
if attr.is_image:
|
||||||
|
image_data = CommonFileCRUD.get_file(attr.name)
|
||||||
|
return image_data
|
||||||
|
|
||||||
|
return abort(400, ErrFormat.attribute_not_reviewable)
|
||||||
|
|
|
@ -125,6 +125,10 @@ class Attribute(Model):
|
||||||
|
|
||||||
option = db.Column(db.JSON)
|
option = db.Column(db.JSON)
|
||||||
|
|
||||||
|
is_upload_file = db.Column(db.Boolean, default=False) # Pa2de
|
||||||
|
is_image = db.Column(db.Boolean, default=False) # Pa2de
|
||||||
|
is_review = db.Column(db.Boolean, default=False) # P36eb
|
||||||
|
|
||||||
def _get_webhook(self):
|
def _get_webhook(self):
|
||||||
if self._choice_web_hook:
|
if self._choice_web_hook:
|
||||||
if self._choice_web_hook.get('headers') and "Cookie" in self._choice_web_hook['headers']:
|
if self._choice_web_hook.get('headers') and "Cookie" in self._choice_web_hook['headers']:
|
||||||
|
|
|
@ -13,6 +13,7 @@ from api.lib.utils import get_page
|
||||||
from api.lib.utils import get_page_size
|
from api.lib.utils import get_page_size
|
||||||
from api.lib.utils import handle_arg_list
|
from api.lib.utils import handle_arg_list
|
||||||
from api.resource import APIView
|
from api.resource import APIView
|
||||||
|
from api.lib.common_setting.upload_file import CommonFileCRUD # Pb14e
|
||||||
|
|
||||||
|
|
||||||
class AttributeSearchView(APIView):
|
class AttributeSearchView(APIView):
|
||||||
|
|
|
@ -29,3 +29,33 @@ export function deleteFileData(data_type, id) {
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function postUploadFile(parameter) {
|
||||||
|
return axios({
|
||||||
|
url: '/common-setting/v1/upload-file',
|
||||||
|
method: 'post',
|
||||||
|
data: parameter,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getUploadFile(file_id) {
|
||||||
|
return axios({
|
||||||
|
url: `/common-setting/v1/upload-file/${file_id}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function postReviewFile(parameter) {
|
||||||
|
return axios({
|
||||||
|
url: '/common-setting/v1/review-file',
|
||||||
|
method: 'post',
|
||||||
|
data: parameter,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getReviewFile(file_id) {
|
||||||
|
return axios({
|
||||||
|
url: `/common-setting/v1/review-file/${file_id}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue