mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-23 12:08:43 -06:00
Adds Region.comments field in the required locations
- [x] 1. Add the field to the model class
- [x] 2. Generate and run database migrations
- [NA] 3. Add validation logic to clean()
- [NA] 4. Update relevant querysets
- [x] 5. Update API serializer
- [ ] 6. Add fields to forms
- [x] dcim.forms.model_forms.RegionForm, create/edit (e.g. model_forms.py)
- [x] dcim.forms.buld_edit.RegionBulkEditForm, bulk edit
- [x] dcim.dorms.bulk_import.RegionImportForm, CSV import
- [NA] filter (UI and API)
- [x] 7. Extend object filter set
- [x] 8. Add column to object table
- [x] 9. Update the SearchIndex
- [x] 10. Update the UI templates
- [x] 11. Create/extend test cases
- [NA] models
- [x] views
- [NA] forms
- [x] filtersets
- [x] api
- [NA] 12. Update the model's documentation
This commit is contained in:
@@ -74,6 +74,7 @@ class RegionTest(APIViewTestCases.APIViewTestCase):
|
||||
{
|
||||
'name': 'Region 4',
|
||||
'slug': 'region-4',
|
||||
'comments': 'this is region 4, not region 5',
|
||||
},
|
||||
{
|
||||
'name': 'Region 5',
|
||||
@@ -86,13 +87,14 @@ class RegionTest(APIViewTestCases.APIViewTestCase):
|
||||
]
|
||||
bulk_update_data = {
|
||||
'description': 'New description',
|
||||
'comments': 'New comments',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
||||
Region.objects.create(name='Region 1', slug='region-1')
|
||||
Region.objects.create(name='Region 2', slug='region-2')
|
||||
Region.objects.create(name='Region 2', slug='region-2', comments='what in the world is happening?')
|
||||
Region.objects.create(name='Region 3', slug='region-3')
|
||||
|
||||
|
||||
|
||||
@@ -67,9 +67,15 @@ class RegionTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
def setUpTestData(cls):
|
||||
|
||||
parent_regions = (
|
||||
Region(name='Region 1', slug='region-1', description='foobar1'),
|
||||
Region(name='Region 2', slug='region-2', description='foobar2'),
|
||||
Region(name='Region 3', slug='region-3', description='foobar3'),
|
||||
Region(
|
||||
name='Region 1', slug='region-1', description='foobar1', comments="There's nothing that",
|
||||
),
|
||||
Region(
|
||||
name='Region 2', slug='region-2', description='foobar2', comments='a hundred men or more',
|
||||
),
|
||||
Region(
|
||||
name='Region 3', slug='region-3', description='foobar3', comments='could ever do'
|
||||
),
|
||||
)
|
||||
for region in parent_regions:
|
||||
region.save()
|
||||
@@ -100,6 +106,13 @@ class RegionTestCase(TestCase, ChangeLoggedFilterSetTests):
|
||||
params = {'q': 'foobar1'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
def test_q_comments(self):
|
||||
params = {'q': 'there'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 1)
|
||||
|
||||
params = {'q': 'hundred men could'}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 0)
|
||||
|
||||
def test_name(self):
|
||||
params = {'name': ['Region 1', 'Region 2']}
|
||||
self.assertEqual(self.filterset(params, self.queryset).qs.count(), 2)
|
||||
|
||||
@@ -25,8 +25,10 @@ class RegionTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
|
||||
|
||||
# Create three Regions
|
||||
regions = (
|
||||
Region(name='Region 1', slug='region-1'),
|
||||
Region(name='Region 2', slug='region-2'),
|
||||
Region(name='Region 1', slug='region-1', comments=''),
|
||||
Region(
|
||||
name='Region 2', slug='region-2', comments="It's going to take a lot to drag me away from you"
|
||||
),
|
||||
Region(name='Region 3', slug='region-3'),
|
||||
)
|
||||
for region in regions:
|
||||
@@ -40,13 +42,14 @@ class RegionTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
|
||||
'parent': regions[2].pk,
|
||||
'description': 'A new region',
|
||||
'tags': [t.pk for t in tags],
|
||||
'comments': 'This comment is really exciting!',
|
||||
}
|
||||
|
||||
cls.csv_data = (
|
||||
"name,slug,description",
|
||||
"Region 4,region-4,Fourth region",
|
||||
"Region 5,region-5,Fifth region",
|
||||
"Region 6,region-6,Sixth region",
|
||||
"name,slug,description,comments",
|
||||
"Region 4,region-4,Fourth region,",
|
||||
"Region 5,region-5,Fifth region,hi guys",
|
||||
"Region 6,region-6,Sixth region,bye guys",
|
||||
)
|
||||
|
||||
cls.csv_update_data = (
|
||||
@@ -58,6 +61,7 @@ class RegionTestCase(ViewTestCases.OrganizationalObjectViewTestCase):
|
||||
|
||||
cls.bulk_edit_data = {
|
||||
'description': 'New description',
|
||||
'comments': 'This comment is super exciting!!!',
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user