Minor python cleanup

This commit is contained in:
2021-01-28 18:38:55 +00:00
parent cc233e0223
commit 6a4620a2e5
6 changed files with 78 additions and 68 deletions

View File

@@ -3,6 +3,11 @@ from django.core.management.base import BaseCommand, CommandError
from assets import models
def delete_objects(model):
for object in model.objects.all():
object.delete()
class Command(BaseCommand):
help = 'Deletes testing sample data'
@@ -12,12 +17,8 @@ class Command(BaseCommand):
if not (settings.DEBUG):
raise CommandError('You cannot run this command in production')
self.delete_objects(models.AssetCategory)
self.delete_objects(models.AssetStatus)
self.delete_objects(models.Supplier)
self.delete_objects(models.Connector)
self.delete_objects(models.Asset)
def delete_objects(self, model):
for object in model.objects.all():
object.delete()
delete_objects(models.AssetCategory)
delete_objects(models.AssetStatus)
delete_objects(models.Supplier)
delete_objects(models.Connector)
delete_objects(models.Asset)