fix: 增加作业中心唯一校验 (#9518)

* fix: 增加作业中心唯一校验

* fix: 增加迁移文件

---------

Co-authored-by: Aaron3S <chenyang@fit2cloud.com>
pull/9529/head
fit2bot 2 years ago committed by GitHub
parent 7f21e6cb6e
commit 16922c4918
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,31 @@
# Generated by Django 3.2.16 on 2023-02-13 07:03
from django.conf import settings
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('ops', '0027_auto_20230206_1927'),
]
operations = [
migrations.AlterModelOptions(
name='playbook',
options={'ordering': ['date_created']},
),
migrations.AlterUniqueTogether(
name='adhoc',
unique_together={('name', 'org_id', 'creator')},
),
migrations.AlterUniqueTogether(
name='job',
unique_together={('name', 'org_id', 'creator')},
),
migrations.AlterUniqueTogether(
name='playbook',
unique_together={('name', 'org_id', 'creator')},
),
]

@ -17,7 +17,6 @@ logger = get_logger(__file__)
class AdHoc(JMSOrgBaseModel):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
name = models.CharField(max_length=128, verbose_name=_('Name'))
pattern = models.CharField(max_length=1024, verbose_name=_("Pattern"), default='all')
@ -42,4 +41,5 @@ class AdHoc(JMSOrgBaseModel):
return "{}: {}".format(self.module, self.args)
class Meta:
unique_together = [('name', 'org_id', 'creator')]
verbose_name = _("AdHoc")

@ -96,6 +96,7 @@ class Job(JMSOrgBaseModel, PeriodTaskModelMixin):
class Meta:
verbose_name = _("Job")
unique_together = [('name', 'org_id', 'creator')]
ordering = ['date_created']

@ -33,3 +33,7 @@ class Playbook(JMSOrgBaseModel):
def work_dir(self):
work_dir = os.path.join(settings.DATA_DIR, "ops", "playbook", self.id.__str__())
return work_dir
class Meta:
unique_together = [('name', 'org_id', 'creator')]
ordering = ['date_created']

Loading…
Cancel
Save