mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Added a weight to CustomField for ordering fields within a form
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Generated by Django 1.10 on 2016-08-22 19:51
|
# Generated by Django 1.10 on 2016-08-23 16:10
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
@ -24,6 +24,7 @@ class Migration(migrations.Migration):
|
|||||||
('description', models.CharField(blank=True, max_length=100)),
|
('description', models.CharField(blank=True, max_length=100)),
|
||||||
('required', models.BooleanField(default=False, help_text=b'Determines whether this field is required when creating new objects or editing an existing object.')),
|
('required', models.BooleanField(default=False, help_text=b'Determines whether this field is required when creating new objects or editing an existing object.')),
|
||||||
('default', models.CharField(blank=True, help_text=b'Default value for the field. Use "true" or "false" for booleans. N/A for selection fields.', max_length=100)),
|
('default', models.CharField(blank=True, help_text=b'Default value for the field. Use "true" or "false" for booleans. N/A for selection fields.', max_length=100)),
|
||||||
|
('weight', models.PositiveSmallIntegerField(default=100, help_text=b'Fields with higher weights appear lower in a form')),
|
||||||
('obj_type', models.ManyToManyField(help_text=b'The object(s) to which this field applies.', related_name='custom_fields', to='contenttypes.ContentType', verbose_name=b'Object(s)')),
|
('obj_type', models.ManyToManyField(help_text=b'The object(s) to which this field applies.', related_name='custom_fields', to='contenttypes.ContentType', verbose_name=b'Object(s)')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
@ -35,7 +36,7 @@ class Migration(migrations.Migration):
|
|||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('value', models.CharField(max_length=100)),
|
('value', models.CharField(max_length=100)),
|
||||||
('weight', models.PositiveSmallIntegerField(default=100)),
|
('weight', models.PositiveSmallIntegerField(default=100, help_text=b'Higher weights appear lower in the list')),
|
||||||
('field', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='choices', to='extras.CustomField')),
|
('field', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='choices', to='extras.CustomField')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
|
@ -93,6 +93,8 @@ class CustomField(models.Model):
|
|||||||
default = models.CharField(max_length=100, blank=True, help_text="Default value for the field. Use \"true\" or "
|
default = models.CharField(max_length=100, blank=True, help_text="Default value for the field. Use \"true\" or "
|
||||||
"\"false\" for booleans. N/A for selection "
|
"\"false\" for booleans. N/A for selection "
|
||||||
"fields.")
|
"fields.")
|
||||||
|
weight = models.PositiveSmallIntegerField(default=100, help_text="Fields with higher weights appear lower in a "
|
||||||
|
"form")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['name']
|
ordering = ['name']
|
||||||
@ -168,7 +170,7 @@ class CustomFieldChoice(models.Model):
|
|||||||
field = models.ForeignKey('CustomField', related_name='choices', limit_choices_to={'type': CF_TYPE_SELECT},
|
field = models.ForeignKey('CustomField', related_name='choices', limit_choices_to={'type': CF_TYPE_SELECT},
|
||||||
on_delete=models.CASCADE)
|
on_delete=models.CASCADE)
|
||||||
value = models.CharField(max_length=100)
|
value = models.CharField(max_length=100)
|
||||||
weight = models.PositiveSmallIntegerField(default=100)
|
weight = models.PositiveSmallIntegerField(default=100, help_text="Higher weights appear lower in the list")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['field', 'weight', 'value']
|
ordering = ['field', 'weight', 'value']
|
||||||
|
Reference in New Issue
Block a user