mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Adding sensible ordering to common models.
https://trello.com/c/tTwRM2VV/102-tower-api-teams-endpoint-does-not-sort-consistently
This commit is contained in:
@@ -40,6 +40,7 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique):
|
|||||||
class Meta:
|
class Meta:
|
||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
unique_together = [('user', 'team', 'kind', 'name')]
|
unique_together = [('user', 'team', 'kind', 'name')]
|
||||||
|
ordering = ('kind', 'name')
|
||||||
|
|
||||||
user = models.ForeignKey(
|
user = models.ForeignKey(
|
||||||
'auth.User',
|
'auth.User',
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class Inventory(CommonModel):
|
|||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
verbose_name_plural = _('inventories')
|
verbose_name_plural = _('inventories')
|
||||||
unique_together = [('name', 'organization')]
|
unique_together = [('name', 'organization')]
|
||||||
|
ordering = ('name',)
|
||||||
|
|
||||||
organization = models.ForeignKey(
|
organization = models.ForeignKey(
|
||||||
'Organization',
|
'Organization',
|
||||||
@@ -329,6 +330,7 @@ class Host(CommonModelNameNotUnique):
|
|||||||
class Meta:
|
class Meta:
|
||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
unique_together = (("name", "inventory"),) # FIXME: Add ('instance_id', 'inventory') after migration.
|
unique_together = (("name", "inventory"),) # FIXME: Add ('instance_id', 'inventory') after migration.
|
||||||
|
ordering = ('inventory', 'name')
|
||||||
|
|
||||||
inventory = models.ForeignKey(
|
inventory = models.ForeignKey(
|
||||||
'Inventory',
|
'Inventory',
|
||||||
@@ -463,6 +465,7 @@ class Group(CommonModelNameNotUnique):
|
|||||||
class Meta:
|
class Meta:
|
||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
unique_together = (("name", "inventory"),)
|
unique_together = (("name", "inventory"),)
|
||||||
|
ordering = ('name',)
|
||||||
|
|
||||||
inventory = models.ForeignKey(
|
inventory = models.ForeignKey(
|
||||||
'Inventory',
|
'Inventory',
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ class JobTemplate(UnifiedJobTemplate, JobOptions):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
|
ordering = ('name',)
|
||||||
|
|
||||||
host_config_key = models.CharField(
|
host_config_key = models.CharField(
|
||||||
max_length=1024,
|
max_length=1024,
|
||||||
@@ -195,6 +196,7 @@ class Job(UnifiedJob, JobOptions):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
|
ordering = ('id',)
|
||||||
|
|
||||||
job_template = models.ForeignKey(
|
job_template = models.ForeignKey(
|
||||||
'JobTemplate',
|
'JobTemplate',
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class Organization(CommonModel):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
|
ordering = ('name',)
|
||||||
|
|
||||||
users = models.ManyToManyField(
|
users = models.ManyToManyField(
|
||||||
'auth.User',
|
'auth.User',
|
||||||
@@ -61,6 +62,7 @@ class Team(CommonModelNameNotUnique):
|
|||||||
class Meta:
|
class Meta:
|
||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
unique_together = [('organization', 'name')]
|
unique_together = [('organization', 'name')]
|
||||||
|
ordering = ('organization__name', 'name')
|
||||||
|
|
||||||
users = models.ManyToManyField(
|
users = models.ManyToManyField(
|
||||||
'auth.User',
|
'auth.User',
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ class Project(UnifiedJobTemplate, ProjectOptions):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
|
ordering = ('id',)
|
||||||
|
|
||||||
scm_delete_on_next_update = models.BooleanField(
|
scm_delete_on_next_update = models.BooleanField(
|
||||||
default=False,
|
default=False,
|
||||||
|
|||||||
@@ -501,10 +501,9 @@ class InventoryTest(BaseTest):
|
|||||||
vars_a = dict(asdf=7777, dog='droopy', cat='battlecat', unstructured=dict(a=[1,1,1],b=dict(x=1,y=2)))
|
vars_a = dict(asdf=7777, dog='droopy', cat='battlecat', unstructured=dict(a=[1,1,1],b=dict(x=1,y=2)))
|
||||||
vars_b = dict(asdf=8888, dog='snoopy', cat='cheshire', unstructured=dict(a=[2,2,2],b=dict(x=3,y=4)))
|
vars_b = dict(asdf=8888, dog='snoopy', cat='cheshire', unstructured=dict(a=[2,2,2],b=dict(x=3,y=4)))
|
||||||
vars_c = dict(asdf=9999, dog='pluto', cat='five', unstructured=dict(a=[3,3,3],b=dict(z=5)))
|
vars_c = dict(asdf=9999, dog='pluto', cat='five', unstructured=dict(a=[3,3,3],b=dict(z=5)))
|
||||||
groups = Group.objects.all()
|
group = Group.objects.get(id=1)
|
||||||
|
|
||||||
vdata1_url = reverse('api:group_variable_data', args=(groups[0].pk,))
|
vdata1_url = reverse('api:group_variable_data', args=(group.pk,))
|
||||||
vdata2_url = reverse('api:group_variable_data', args=(groups[1].pk,))
|
|
||||||
|
|
||||||
# a super user can associate variable objects with groups
|
# a super user can associate variable objects with groups
|
||||||
got = self.get(vdata1_url, expect=200, auth=self.get_super_credentials())
|
got = self.get(vdata1_url, expect=200, auth=self.get_super_credentials())
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ class InventoryScriptTest(BaseScriptTest):
|
|||||||
# Valid host, but not part of the specified inventory.
|
# Valid host, but not part of the specified inventory.
|
||||||
inventory = self.inventories[0]
|
inventory = self.inventories[0]
|
||||||
self.assertTrue(inventory.active)
|
self.assertTrue(inventory.active)
|
||||||
host = Host.objects.exclude(inventory=inventory)[0]
|
host = Host.objects.get(id=12)
|
||||||
self.assertTrue(host.active)
|
self.assertTrue(host.active)
|
||||||
os.environ['INVENTORY_ID'] = str(inventory.pk)
|
os.environ['INVENTORY_ID'] = str(inventory.pk)
|
||||||
rc, stdout, stderr = self.run_inventory_script(host=host.name)
|
rc, stdout, stderr = self.run_inventory_script(host=host.name)
|
||||||
|
|||||||
Reference in New Issue
Block a user