JUMPSERVER+ZABBIX二次开发

未完待续

1.apps/assets/models/assets.py

添加字段:

zabbix_group_id = models.IntegerField(null=True,blank=True,verbose_name=_('Zabbix Group Id'))

null=True 数据库里的字段值可为空

blank=True 表单验证可为空

2.apps/i18n/zh/LC_MESSAGES/django.po

#: assets/models/asset.py:128

msgid "Zabbix Group Id"

msgstr "Zabbix 主机组 ID"

python3 manage.py compilemessages

/var/www/jumpserver/jms restart all -d

3.cd /var/www/jumpserver(进入env环境: py3)

python3 manage.py makemigrations assets

填写默认值

python3 manage.py migrate assets

4.DEBUG

logger.debug("asset create view get"+str(form.__dict__))

5.添加左节点

5.1 ../apps/templates/_nav.html 添加

  •    

            

            监控管理

            

        

        

  • 杂篇

    swal插件表单提交被阻止

    $("form").submit(function (){

    var change_val =$("#id_db_type").val();

    if(change_val != {{ form.db_type.value }}){

    swal({

    title:'切换模板将删除之前模板的数据',

    text:"",

    type:"warning",

    showCancelButton:true,

    cancelButtonText:'取消',

    confirmButtonColor:"#ed5565",

    confirmButtonText:'确认',

    closeOnConfirm:true,

    },function () {

    $('form').off('submit').submit() 

    $(this).off('submit').submit() //no

    $(this)..submit() //no

    $('form')..submit() //no

    });

    }else{

    $(this).submit();

    }

    return false;

    });

    你可能感兴趣的:(python,django,运维)