James Iter пре 9 година
родитељ
комит
ec2f3b9512
5 измењених фајлова са 19 додато и 3 уклоњено
  1. 9 1
      api/operate_rule.py
  2. 1 0
      misc/init.sql
  3. 3 1
      models/boot_job.py
  4. 1 0
      models/rules.py
  5. 5 1
      models/status.py

+ 9 - 1
api/operate_rule.py

@@ -43,12 +43,14 @@ def r_create():
 
 
     args_rules = [
     args_rules = [
         Rules.BOOT_JOB_ID_EXT.value,
         Rules.BOOT_JOB_ID_EXT.value,
-        Rules.OPERATE_RULE_KIND.value
+        Rules.OPERATE_RULE_KIND.value,
+        Rules.OPERATE_RULE_SEQUENCE.value
     ]
     ]
 
 
     operate_rule.boot_job_id = request.json.get('boot_job_id')
     operate_rule.boot_job_id = request.json.get('boot_job_id')
     operate_rule.kind = request.json.get('kind')
     operate_rule.kind = request.json.get('kind')
     operate_rule.path = request.json.get('path', '')
     operate_rule.path = request.json.get('path', '')
+    operate_rule.sequence = request.json.get('sequence', 0)
     operate_rule.content = request.json.get('content', '')
     operate_rule.content = request.json.get('content', '')
     operate_rule.command = request.json.get('command', '')
     operate_rule.command = request.json.get('command', '')
 
 
@@ -115,6 +117,11 @@ def r_update(_id):
             Rules.OPERATE_RULE_KIND.value,
             Rules.OPERATE_RULE_KIND.value,
         )
         )
 
 
+    if 'sequence' in request.json:
+        args_rules.append(
+            Rules.OPERATE_RULE_SEQUENCE.value,
+        )
+
     if 'path' in request.json:
     if 'path' in request.json:
         args_rules.append(
         args_rules.append(
             Rules.OPERATE_RULE_PATH.value,
             Rules.OPERATE_RULE_PATH.value,
@@ -143,6 +150,7 @@ def r_update(_id):
         operate_rule.get()
         operate_rule.get()
         operate_rule.boot_job_id = request.json.get('boot_job_id', operate_rule.boot_job_id)
         operate_rule.boot_job_id = request.json.get('boot_job_id', operate_rule.boot_job_id)
         operate_rule.kind = request.json.get('kind', operate_rule.kind)
         operate_rule.kind = request.json.get('kind', operate_rule.kind)
+        operate_rule.sequence = request.json.get('sequence', operate_rule.sequence)
         operate_rule.path = request.json.get('path', operate_rule.path)
         operate_rule.path = request.json.get('path', operate_rule.path)
         operate_rule.content = request.json.get('content', operate_rule.content)
         operate_rule.content = request.json.get('content', operate_rule.content)
         operate_rule.command = request.json.get('command', operate_rule.command)
         operate_rule.command = request.json.get('command', operate_rule.command)

+ 1 - 0
misc/init.sql

@@ -99,6 +99,7 @@ CREATE TABLE IF NOT EXISTS operate_rule(
     id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
     id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
     boot_job_id BIGINT UNSIGNED NOT NULL,
     boot_job_id BIGINT UNSIGNED NOT NULL,
     kind TINYINT UNSIGNED NOT NULL DEFAULT 0,
     kind TINYINT UNSIGNED NOT NULL DEFAULT 0,
+    sequence TINYINT UNSIGNED NOT NULL DEFAULT 0,
     path VARCHAR(255) NOT NULL,
     path VARCHAR(255) NOT NULL,
     content TEXT NOT NULL DEFAULT '',
     content TEXT NOT NULL DEFAULT '',
     command TEXT NOT NULL DEFAULT '',
     command TEXT NOT NULL DEFAULT '',

+ 3 - 1
models/boot_job.py

@@ -51,6 +51,7 @@ class OperateRule(ORM):
         self.id = 0
         self.id = 0
         self.boot_job_id = None
         self.boot_job_id = None
         self.kind = ''
         self.kind = ''
+        self.sequence = 0
         self.command = ''
         self.command = ''
         self.path = ''
         self.path = ''
         self.content = ''
         self.content = ''
@@ -60,6 +61,7 @@ class OperateRule(ORM):
         return {
         return {
             'id': FilterFieldType.INT.value,
             'id': FilterFieldType.INT.value,
             'boot_job_id': FilterFieldType.INT.value,
             'boot_job_id': FilterFieldType.INT.value,
+            'sequence': FilterFieldType.INT.value,
             'command': FilterFieldType.STR.value,
             'command': FilterFieldType.STR.value,
             'path': FilterFieldType.STR.value,
             'path': FilterFieldType.STR.value,
             'content': FilterFieldType.STR.value,
             'content': FilterFieldType.STR.value,
@@ -67,7 +69,7 @@ class OperateRule(ORM):
 
 
     @staticmethod
     @staticmethod
     def get_allow_update_keywords():
     def get_allow_update_keywords():
-        return ['boot_job_id']
+        return ['boot_job_id', 'sequence']
 
 
     @staticmethod
     @staticmethod
     def get_allow_content_search_keywords():
     def get_allow_content_search_keywords():

+ 1 - 0
models/rules.py

@@ -64,6 +64,7 @@ class Rules(Enum):
 
 
     BOOT_JOB_ID_EXT = (int, 'boot_job_id')
     BOOT_JOB_ID_EXT = (int, 'boot_job_id')
     OPERATE_RULE_KIND = (int, 'kind')
     OPERATE_RULE_KIND = (int, 'kind')
+    OPERATE_RULE_SEQUENCE = (int, 'sequence')
     OPERATE_RULE_PATH = (basestring, 'path')
     OPERATE_RULE_PATH = (basestring, 'path')
     OPERATE_RULE_CONTENT = (basestring, 'content')
     OPERATE_RULE_CONTENT = (basestring, 'content')
     OPERATE_RULE_COMMAND = (basestring, 'command')
     OPERATE_RULE_COMMAND = (basestring, 'command')

+ 5 - 1
models/status.py

@@ -60,8 +60,12 @@ class DiskState(IntEnum):
 
 
 
 
 class BootJobUseFor(IntEnum):
 class BootJobUseFor(IntEnum):
+    # 用于系统模板初始化
     template = 0
     template = 0
-    user = 1
+    # 用于系统及,比如通过重启系统更改密码功能之类
+    system = 1
+    # 用于用户自定义
+    user = 2
 
 
 
 
 class OperateRuleKind(IntEnum):
 class OperateRuleKind(IntEnum):