mirror of https://github.com/jumpserver/jumpserver
perf: change translate
parent
c2218a5bca
commit
4c3cfcbf23
|
@ -33,7 +33,7 @@ class ChangeSecretManager(AccountBasePlaybookManager):
|
|||
'secret_strategy', SecretStrategy.custom
|
||||
)
|
||||
self.ssh_key_change_strategy = self.execution.snapshot.get(
|
||||
'ssh_key_change_strategy', SSHKeyStrategy.add
|
||||
'ssh_key_change_strategy', SSHKeyStrategy.set_jms
|
||||
)
|
||||
self.account_ids = self.execution.snapshot['accounts']
|
||||
self.name_recorder_mapper = {} # 做个映射,方便后面处理
|
||||
|
|
|
@ -49,9 +49,9 @@ class SecretStrategy(models.TextChoices):
|
|||
|
||||
|
||||
class SSHKeyStrategy(models.TextChoices):
|
||||
add = 'add', _('Append SSH KEY')
|
||||
set = 'set', _('Empty and append SSH KEY')
|
||||
# add = 'add', _('Append SSH KEY')
|
||||
set_jms = 'set_jms', _('Replace (Replace only keys pushed by JumpServer) ')
|
||||
set = 'set', _('Empty and append SSH KEY')
|
||||
|
||||
|
||||
class TriggerChoice(models.TextChoices, TreeChoices):
|
||||
|
|
|
@ -50,7 +50,15 @@ class Migration(migrations.Migration):
|
|||
('secret', common.db.fields.EncryptTextField(blank=True, null=True, verbose_name='Secret')),
|
||||
('secret_strategy', models.CharField(choices=[('specific', 'Specific secret'), ('random', 'Random generate')], default='specific', max_length=16, verbose_name='Secret strategy')),
|
||||
('password_rules', models.JSONField(default=dict, verbose_name='Password rules')),
|
||||
('ssh_key_change_strategy', models.CharField(choices=[('add', 'Append SSH KEY'), ('set', 'Empty and append SSH KEY'), ('set_jms', 'Replace (Replace only keys pushed by JumpServer) ')], default='add', max_length=16, verbose_name='SSH key change strategy')),
|
||||
('ssh_key_change_strategy', models.CharField(
|
||||
choices=[
|
||||
("set_jms", "Replace (Replace only keys pushed by JumpServer) "),
|
||||
("set", "Empty and append SSH KEY"),
|
||||
],
|
||||
default="set_jms",
|
||||
max_length=16,
|
||||
verbose_name="SSH key change strategy",
|
||||
)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Change secret automation',
|
||||
|
@ -76,7 +84,15 @@ class Migration(migrations.Migration):
|
|||
('secret', common.db.fields.EncryptTextField(blank=True, null=True, verbose_name='Secret')),
|
||||
('secret_strategy', models.CharField(choices=[('specific', 'Specific secret'), ('random', 'Random generate')], default='specific', max_length=16, verbose_name='Secret strategy')),
|
||||
('password_rules', models.JSONField(default=dict, verbose_name='Password rules')),
|
||||
('ssh_key_change_strategy', models.CharField(choices=[('add', 'Append SSH KEY'), ('set', 'Empty and append SSH KEY'), ('set_jms', 'Replace (Replace only keys pushed by JumpServer) ')], default='add', max_length=16, verbose_name='SSH key change strategy')),
|
||||
('ssh_key_change_strategy', models.CharField(
|
||||
choices=[
|
||||
("set_jms", "Replace (Replace only keys pushed by JumpServer) "),
|
||||
("set", "Empty and append SSH KEY"),
|
||||
],
|
||||
default="set_jms",
|
||||
max_length=16,
|
||||
verbose_name="SSH key change strategy",
|
||||
)),
|
||||
('triggers', models.JSONField(default=list, max_length=16, verbose_name='Triggers')),
|
||||
('username', models.CharField(max_length=128, verbose_name='Username')),
|
||||
('action', models.CharField(max_length=16, verbose_name='Action')),
|
||||
|
|
|
@ -15,4 +15,14 @@ class Migration(migrations.Migration):
|
|||
name="secret_reset",
|
||||
field=models.BooleanField(default=True, verbose_name="Secret reset"),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="accountbackupautomation",
|
||||
name="start_time",
|
||||
field=models.DateTimeField(
|
||||
blank=True,
|
||||
help_text="Datetime when the schedule should begin triggering the task to run",
|
||||
null=True,
|
||||
verbose_name="Start Datetime",
|
||||
),
|
||||
),
|
||||
]
|
||||
|
|
|
@ -57,6 +57,7 @@ class Account(AbsConnectivity, LabeledMixin, BaseAccount):
|
|||
history = AccountHistoricalRecords(included_fields=['id', '_secret', 'secret_type', 'version'])
|
||||
source = models.CharField(max_length=30, default=Source.LOCAL, verbose_name=_('Source'))
|
||||
source_id = models.CharField(max_length=128, null=True, blank=True, verbose_name=_('Source ID'))
|
||||
date_last_access = models.DateTimeField(null=True, blank=True, verbose_name=_('Date last access'))
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Account')
|
||||
|
|
|
@ -51,7 +51,7 @@ class AutomationExecution(AssetAutomationExecution):
|
|||
class ChangeSecretMixin(SecretWithRandomMixin):
|
||||
ssh_key_change_strategy = models.CharField(
|
||||
choices=SSHKeyStrategy.choices, max_length=16,
|
||||
default=SSHKeyStrategy.add, verbose_name=_('SSH key change strategy')
|
||||
default=SSHKeyStrategy.set_jms, verbose_name=_('SSH key change strategy')
|
||||
)
|
||||
get_all_assets: callable # get all assets
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ class ChangeSecretAutomationSerializer(AuthValidateMixin, BaseAutomationSerializ
|
|||
choices=SecretStrategy.choices, required=True, label=_('Secret strategy')
|
||||
)
|
||||
ssh_key_change_strategy = LabeledChoiceField(
|
||||
choices=SSHKeyStrategy.choices, required=False, label=_('SSH Key strategy')
|
||||
choices=SSHKeyStrategy.choices, required=False, label=_('SSH Key strategy'),
|
||||
default="set_jms"
|
||||
)
|
||||
password_rules = PasswordRulesSerializer(required=False, label=_('Password rules'))
|
||||
secret_type = LabeledChoiceField(choices=get_secret_types(), required=True, label=_('Secret type'))
|
||||
|
@ -51,13 +52,15 @@ class ChangeSecretAutomationSerializer(AuthValidateMixin, BaseAutomationSerializ
|
|||
read_only_fields = BaseAutomationSerializer.Meta.read_only_fields
|
||||
fields = BaseAutomationSerializer.Meta.fields + read_only_fields + [
|
||||
'secret_type', 'secret_strategy', 'secret', 'password_rules',
|
||||
'ssh_key_change_strategy', 'passphrase', 'recipients', 'params'
|
||||
'ssh_key_change_strategy', 'passphrase', 'params',
|
||||
'recipients',
|
||||
]
|
||||
extra_kwargs = {**BaseAutomationSerializer.Meta.extra_kwargs, **{
|
||||
'accounts': {'required': True, 'help_text': _('Please enter your account username')},
|
||||
'recipients': {'label': _('Recipient'), 'help_text': _(
|
||||
"Currently only mail sending is supported"
|
||||
)},
|
||||
'pre_recipients': {'help_text': _("Notification before execution")},
|
||||
'params': {'help_text': _(
|
||||
"Secret parameter settings, currently only effective for assets of the host type."
|
||||
)},
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 4.1.13 on 2024-10-15 02:52
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("assets", "0005_myasset"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="baseautomation",
|
||||
name="start_time",
|
||||
field=models.DateTimeField(
|
||||
blank=True,
|
||||
help_text="Datetime when the schedule should begin triggering the task to run",
|
||||
null=True,
|
||||
verbose_name="Start Datetime",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -215,7 +215,7 @@ msgstr "移除账号"
|
|||
|
||||
#: accounts/const/automation.py:28
|
||||
msgid "Gather accounts"
|
||||
msgstr "收集账号"
|
||||
msgstr "账号发现"
|
||||
|
||||
#: accounts/const/automation.py:29
|
||||
msgid "Verify gateway account"
|
||||
|
@ -528,11 +528,11 @@ msgstr "创建改密执行"
|
|||
|
||||
#: accounts/models/automations/base.py:38
|
||||
msgid "Can view gather accounts execution"
|
||||
msgstr "查看收集账号执行"
|
||||
msgstr "查看账号发现执行"
|
||||
|
||||
#: accounts/models/automations/base.py:39
|
||||
msgid "Can add gather accounts execution"
|
||||
msgstr "创建收集账号执行"
|
||||
msgstr "创建账号发现执行"
|
||||
|
||||
#: accounts/models/automations/base.py:41
|
||||
msgid "Can view push account execution"
|
||||
|
@ -637,7 +637,7 @@ msgstr "最后登录地址"
|
|||
#: accounts/models/automations/gather_account.py:44
|
||||
#: accounts/tasks/gather_accounts.py:30
|
||||
msgid "Gather asset accounts"
|
||||
msgstr "收集账号"
|
||||
msgstr "账号发现"
|
||||
|
||||
#: accounts/models/automations/gather_account.py:56
|
||||
msgid "Is sync account"
|
||||
|
@ -645,7 +645,7 @@ msgstr "是否同步账号"
|
|||
|
||||
#: accounts/models/automations/gather_account.py:75
|
||||
msgid "Gather account automation"
|
||||
msgstr "自动化收集账号"
|
||||
msgstr "自动化账号发现"
|
||||
|
||||
#: accounts/models/automations/push_account.py:14
|
||||
msgid "Triggers"
|
||||
|
@ -1233,7 +1233,7 @@ msgid ""
|
|||
" "
|
||||
msgstr ""
|
||||
"\n"
|
||||
"当在控制台-自动化-账号收集-收集的账号-点击同步删除会执行该任务"
|
||||
"当在控制台-自动化-账号收集-发现的账号-点击同步删除会执行该任务"
|
||||
|
||||
#: accounts/tasks/remove_account.py:52
|
||||
msgid "Clean historical accounts"
|
||||
|
@ -2526,11 +2526,11 @@ msgstr "启用账号收集"
|
|||
|
||||
#: assets/serializers/platform.py:67
|
||||
msgid "Enable account collection"
|
||||
msgstr "自动化收集账号"
|
||||
msgstr "自动化账号发现"
|
||||
|
||||
#: assets/serializers/platform.py:70
|
||||
msgid "Gather accounts method"
|
||||
msgstr "收集账号方式"
|
||||
msgstr "账号发现方式"
|
||||
|
||||
#: assets/serializers/platform.py:76
|
||||
msgid "Remove accounts enabled"
|
||||
|
@ -5673,7 +5673,7 @@ msgstr "备份账号"
|
|||
|
||||
#: rbac/tree.py:51
|
||||
msgid "Gather account"
|
||||
msgstr "收集账号"
|
||||
msgstr "账号发现"
|
||||
|
||||
#: rbac/tree.py:53
|
||||
msgid "Account change secret"
|
||||
|
|
|
@ -2397,7 +2397,7 @@ msgstr "啟用帳號收集"
|
|||
|
||||
#: assets/serializers/platform.py:67
|
||||
msgid "Enable account collection"
|
||||
msgstr "自动收集账号"
|
||||
msgstr "自动账号发现"
|
||||
|
||||
#: assets/serializers/platform.py:70
|
||||
msgid "Gather accounts method"
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
"AccountChangeSecretDetail": "Change account secret details",
|
||||
"AccountDeleteConfirmMsg": "Delete account, continue?",
|
||||
"AccountExportTips": "The exported information contains sensitive information such as encrypted account numbers. the exported format is an encrypted zip file (if you have not set the encryption password, please go to personal info to set the file encryption password).",
|
||||
"AccountGatherDetail": "Gather account details",
|
||||
"AccountGatherList": "Gather accounts",
|
||||
"AccountGatherTaskCreate": "Create gather accounts task",
|
||||
"AccountGatherTaskList": "Gather accounts tasks",
|
||||
"AccountGatherTaskUpdate": "Update the gather accounts task",
|
||||
"AccountDiscoverDetail": "Gather account details",
|
||||
"AccountDiscoverList": "Gather accounts",
|
||||
"AccountDiscoverTaskCreate": "Create gather accounts task",
|
||||
"AccountDiscoverTaskList": "Gather accounts tasks",
|
||||
"AccountDiscoverTaskUpdate": "Update the gather accounts task",
|
||||
"AccountList": "Accounts",
|
||||
"AccountPolicy": "Account policy",
|
||||
"AccountPolicyHelpText": "For accounts that do not meet the requirements when creating, such as: non-compliant key types and unique key constraints, you can choose the above strategy.",
|
||||
|
@ -185,7 +185,7 @@
|
|||
"BaseAccount": "Account",
|
||||
"BaseAccountBackup": "Account Backup",
|
||||
"BaseAccountChangeSecret": "Account Change Secret",
|
||||
"BaseAccountGather": "Account Gather",
|
||||
"BaseAccountDiscover": "Account Gather",
|
||||
"BaseAccountPush": "Account Push",
|
||||
"BaseAccountTemplate": "Account Template",
|
||||
"BaseApplets": "Applets",
|
||||
|
@ -546,8 +546,8 @@
|
|||
"GatewayList": "Gateways",
|
||||
"GatewayPlatformHelpText": "Only platforms with names starting with ‘Gateway’ can be used as gateways.",
|
||||
"GatewayUpdate": "Update the gateway",
|
||||
"GatherAccounts": "Gather accounts",
|
||||
"GatherAccountsHelpText": "Collect account information on assets. the collected account information can be imported into the system for centralized management.",
|
||||
"DiscoverAccounts": "Gather accounts",
|
||||
"DiscoverAccountsHelpText": "Collect account information on assets. the collected account information can be imported into the system for centralized management.",
|
||||
"GatheredAccountList": "Gathered accounts",
|
||||
"General": "General",
|
||||
"GeneralAccounts": "General accounts",
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
"AccountChangeSecretDetail": "アカウントのパスワード変更詳細",
|
||||
"AccountDeleteConfirmMsg": "アカウントを削除しますか?続行しますか?",
|
||||
"AccountExportTips": "エクスポートする情報には口座の暗号文が含まれ、これは機密情報に関連しています。エクスポートする形式は、暗号化されたzipファイルです(暗号化パスワードを設定していない場合は、個人情報でファイルの暗号化パスワードを設定してください)。",
|
||||
"AccountGatherDetail": "アカウント収集詳細",
|
||||
"AccountGatherList": "アカウントの収集",
|
||||
"AccountGatherTaskCreate": "アカウント収集タスクの作成",
|
||||
"AccountGatherTaskList": "アカウント収集タスク",
|
||||
"AccountGatherTaskUpdate": "アカウント収集タスクを更新",
|
||||
"AccountDiscoverDetail": "アカウント収集詳細",
|
||||
"AccountDiscoverList": "アカウントの収集",
|
||||
"AccountDiscoverTaskCreate": "アカウント収集タスクの作成",
|
||||
"AccountDiscoverTaskList": "アカウント収集タスク",
|
||||
"AccountDiscoverTaskUpdate": "アカウント収集タスクを更新",
|
||||
"AccountList": "クラウドアカウント",
|
||||
"AccountPolicy": "アカウントポリシー",
|
||||
"AccountPolicyHelpText": "作成時に要件を満たさないアカウント,例えば:キータイプが規格外,一意キー制約,上記の方針を選択できます。",
|
||||
|
@ -185,7 +185,7 @@
|
|||
"BaseAccount": "アカウント",
|
||||
"BaseAccountBackup": "アカウントバックアップ",
|
||||
"BaseAccountChangeSecret": "アカウントのパスワード変更",
|
||||
"BaseAccountGather": "アカウント収集",
|
||||
"BaseAccountDiscover": "アカウント収集",
|
||||
"BaseAccountPush": "アカウントプッシュ",
|
||||
"BaseAccountTemplate": "アカウントテンプレート",
|
||||
"BaseApplets": "アプリケーション",
|
||||
|
@ -561,8 +561,8 @@
|
|||
"GatewayList": "ゲートウェイリスト",
|
||||
"GatewayPlatformHelpText": "ゲートウェイプラットフォームは、Gatewayで始まるプラットフォームのみ選択可能です。",
|
||||
"GatewayUpdate": "ゲートウェイの更新",
|
||||
"GatherAccounts": "アカウント収集",
|
||||
"GatherAccountsHelpText": "資産上のアカウント情報を収集します。収集したアカウント情報は、システムにインポートして一元管理が可能です",
|
||||
"DiscoverAccounts": "アカウント収集",
|
||||
"DiscoverAccountsHelpText": "資産上のアカウント情報を収集します。収集したアカウント情報は、システムにインポートして一元管理が可能です",
|
||||
"GatheredAccountList": "収集したアカウント",
|
||||
"General": "基本",
|
||||
"GeneralAccounts": "一般アカウント",
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
"AccountChangeSecretDetail": "账号改密详情",
|
||||
"AccountDeleteConfirmMsg": "删除账号,是否继续?",
|
||||
"AccountExportTips": "导出信息中包含账号密文涉及敏感信息,导出的格式为一个加密的zip文件(若没有设置加密密码,请前往个人信息中设置文件加密密码)。",
|
||||
"AccountGatherDetail": "账号发现详情",
|
||||
"AccountGatherList": "账号发现",
|
||||
"AccountGatherTaskCreate": "创建账号发现任务",
|
||||
"AccountGatherTaskList": "账号发现任务",
|
||||
"AccountGatherTaskUpdate": "更新账号发现任务",
|
||||
"AccountDiscoverDetail": "账号发现详情",
|
||||
"AccountDiscoverList": "账号发现",
|
||||
"AccountDiscoverTaskCreate": "创建账号发现任务",
|
||||
"AccountDiscoverTaskList": "账号发现任务",
|
||||
"AccountDiscoverTaskUpdate": "更新账号发现任务",
|
||||
"AccountList": "账号",
|
||||
"AccountPolicy": "账号策略",
|
||||
"AccountPolicyHelpText": "创建时对于不符合要求的账号,如:密钥类型不合规,唯一键约束,可选择以上策略。",
|
||||
|
@ -185,7 +185,7 @@
|
|||
"BaseAccount": "账号",
|
||||
"BaseAccountBackup": "账号备份",
|
||||
"BaseAccountChangeSecret": "账号改密",
|
||||
"BaseAccountGather": "账号采集",
|
||||
"BaseAccountDiscover": "账号采集",
|
||||
"BaseAccountPush": "账号推送",
|
||||
"BaseAccountTemplate": "账号模版",
|
||||
"BaseApplets": "应用",
|
||||
|
@ -493,7 +493,7 @@
|
|||
"Execute": "执行",
|
||||
"ExecuteOnce": "执行一次",
|
||||
"ExecutionDetail": "执行详情",
|
||||
"ExecutionList": "执行列表",
|
||||
"ExecutionList": "执行记录",
|
||||
"ExistError": "这个元素已经存在",
|
||||
"Existing": "已存在",
|
||||
"ExpirationTimeout": "过期超时时间(秒)",
|
||||
|
@ -546,9 +546,9 @@
|
|||
"GatewayList": "网关列表",
|
||||
"GatewayPlatformHelpText": "网关平台只能选择以 Gateway 开头的平台",
|
||||
"GatewayUpdate": "更新网关",
|
||||
"GatherAccounts": "账号发现",
|
||||
"GatherAccountsHelpText": "收集资产上的账号信息。收集后的账号信息可以导入到系统中,方便统一管理",
|
||||
"GatheredAccountList": "收集的账号",
|
||||
"DiscoverAccounts": "账号发现",
|
||||
"DiscoverAccountsHelpText": "收集资产上的账号信息。收集后的账号信息可以导入到系统中,方便统一管理",
|
||||
"GatheredAccountList": "发现的账号",
|
||||
"General": "基本",
|
||||
"GeneralAccounts": "普通账号",
|
||||
"GeneralSetting": "通用配置",
|
||||
|
@ -639,7 +639,7 @@
|
|||
"IsFinished": "完成",
|
||||
"IsLocked": "是否暂停",
|
||||
"IsSuccess": "成功",
|
||||
"IsSyncAccountHelpText": "收集完成后会把收集的账号同步到资产",
|
||||
"IsSyncAccountHelpText": "收集完成后会把发现的账号同步到资产",
|
||||
"IsSyncAccountLabel": "同步到资产",
|
||||
"JDCloud": "京东云",
|
||||
"Job": "作业",
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
"AccountChangeSecretDetail": "帳號變更密碼詳情",
|
||||
"AccountDeleteConfirmMsg": "刪除帳號,是否繼續?",
|
||||
"AccountExportTips": "導出信息中包含賬號密文涉及敏感信息,導出的格式為一個加密的zip文件(若沒有設置加密密碼,請前往個人信息中設置文件加密密碼)。",
|
||||
"AccountGatherDetail": "帳號收集詳情",
|
||||
"AccountGatherList": "帳號收集",
|
||||
"AccountGatherTaskCreate": "創建賬號收集任務",
|
||||
"AccountGatherTaskExecutionList": "任務執行列表",
|
||||
"AccountGatherTaskList": "賬號收集任務",
|
||||
"AccountGatherTaskUpdate": "更新賬號收集任務",
|
||||
"AccountDiscoverDetail": "帳號收集詳情",
|
||||
"AccountDiscoverList": "帳號收集",
|
||||
"AccountDiscoverTaskCreate": "創建賬號收集任務",
|
||||
"AccountDiscoverTaskExecutionList": "任務執行列表",
|
||||
"AccountDiscoverTaskList": "賬號收集任務",
|
||||
"AccountDiscoverTaskUpdate": "更新賬號收集任務",
|
||||
"AccountHelpText": "雲帳號是用來連接雲服務商的帳號,用於獲取雲服務商的資源資訊",
|
||||
"AccountHistoryHelpMessage": "記錄當前帳號的歷史版本",
|
||||
"AccountList": "雲帳號",
|
||||
|
@ -246,7 +246,7 @@
|
|||
"BaseAccount": "帳號",
|
||||
"BaseAccountBackup": "帳號備份",
|
||||
"BaseAccountChangeSecret": "帳號改密",
|
||||
"BaseAccountGather": "帳號採集",
|
||||
"BaseAccountDiscover": "帳號採集",
|
||||
"BaseAccountPush": "帳號推送",
|
||||
"BaseAccountTemplate": "帳號模版",
|
||||
"BaseApplets": "應用",
|
||||
|
@ -717,8 +717,8 @@
|
|||
"GatewayPlatformHelpText": "網關平台只能選擇以 Gateway 開頭的平台",
|
||||
"GatewayProtocolHelpText": "SSH網關,支持代理SSH,RDP和VNC",
|
||||
"GatewayUpdate": "更新網關",
|
||||
"GatherAccounts": "帳號收集",
|
||||
"GatherAccountsHelpText": "收集資產上的賬號資訊。收集後的賬號資訊可以導入到系統中,方便統一",
|
||||
"DiscoverAccounts": "帳號收集",
|
||||
"DiscoverAccountsHelpText": "收集資產上的賬號資訊。收集後的賬號資訊可以導入到系統中,方便統一",
|
||||
"GatheredAccountList": "Collected accounts",
|
||||
"General": "基本",
|
||||
"GeneralAccounts": "普通帳號",
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
# Generated by Django 4.1.13 on 2024-10-15 02:52
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("ops", "0003_alter_adhoc_unique_together_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="historicaljob",
|
||||
name="start_time",
|
||||
field=models.DateTimeField(
|
||||
blank=True,
|
||||
help_text="Datetime when the schedule should begin triggering the task to run",
|
||||
null=True,
|
||||
verbose_name="Start Datetime",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="job",
|
||||
name="start_time",
|
||||
field=models.DateTimeField(
|
||||
blank=True,
|
||||
help_text="Datetime when the schedule should begin triggering the task to run",
|
||||
null=True,
|
||||
verbose_name="Start Datetime",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -34,6 +34,14 @@ class PeriodTaskModelMixin(models.Model):
|
|||
crontab = models.CharField(
|
||||
blank=True, max_length=128, null=True, verbose_name=_("Crontab"),
|
||||
)
|
||||
start_time = models.DateTimeField(
|
||||
blank=True, null=True,
|
||||
verbose_name=_('Start Datetime'),
|
||||
help_text=_(
|
||||
'Datetime when the schedule should begin '
|
||||
'triggering the task to run'
|
||||
),
|
||||
)
|
||||
objects = PeriodTaskModelQuerySet.as_manager()
|
||||
|
||||
@abc.abstractmethod
|
||||
|
@ -73,6 +81,7 @@ class PeriodTaskModelMixin(models.Model):
|
|||
'args': args,
|
||||
'kwargs': kwargs,
|
||||
'enabled': True,
|
||||
'start_time': self.start_time,
|
||||
}
|
||||
}
|
||||
create_or_update_celery_periodic_tasks(tasks)
|
||||
|
@ -113,13 +122,19 @@ class PeriodTaskSerializerMixin(serializers.Serializer):
|
|||
allow_null=True, required=False, label=_('Crontab')
|
||||
)
|
||||
interval = serializers.IntegerField(
|
||||
default=24, allow_null=True, required=False, label=_('Interval')
|
||||
default=24, allow_null=True, required=False, label=_('Interval'),
|
||||
max_value=65535, min_value=1,
|
||||
)
|
||||
start_time = serializers.DateTimeField(
|
||||
allow_null=True, required=False,
|
||||
label=_('Start Datetime'),
|
||||
help_text=_(
|
||||
'Datetime when the schedule should begin '
|
||||
'triggering the task to run'
|
||||
),
|
||||
)
|
||||
periodic_display = serializers.CharField(read_only=True, label=_('Run period'))
|
||||
|
||||
INTERVAL_MAX = 65535
|
||||
INTERVAL_MIN = 1
|
||||
|
||||
def validate_crontab(self, crontab):
|
||||
if not crontab:
|
||||
return crontab
|
||||
|
@ -131,9 +146,6 @@ class PeriodTaskSerializerMixin(serializers.Serializer):
|
|||
def validate_interval(self, interval):
|
||||
if not interval and not isinstance(interval, int):
|
||||
return interval
|
||||
msg = _("Range {} to {}").format(self.INTERVAL_MIN, self.INTERVAL_MAX)
|
||||
if interval > self.INTERVAL_MAX or interval < self.INTERVAL_MIN:
|
||||
raise serializers.ValidationError(msg)
|
||||
return interval
|
||||
|
||||
def validate_is_periodic(self, ok):
|
||||
|
|
Loading…
Reference in New Issue