Source code for ferrosoft.apps.emiflow.management.commands.copy_transport
import sys
from django.core.management import BaseCommand
from ferrosoft.apps.emiflow.models.transport import TransportChain
from ferrosoft.apps.ferrobase.management.tenantcommand import TenantAwareCommand
[docs]
class Command(TenantAwareCommand, BaseCommand):
[docs]
def add_arguments(self, parser):
super().add_arguments(parser)
parser.add_argument(
"source",
type=str,
help="Reference ID of source transport",
)
parser.add_argument(
"dest",
type=str,
help="Reference ID of destination transport (to be created)",
)
[docs]
def handle_tenant(self, *args, **options):
source = TransportChain.objects.filter(reference=options["source"]).first()
if source is None:
self.stderr.write(
self.style.ERROR("Transport chain not found: %s" % options["source"])
)
sys.exit(2)
dest = source.copy(options["dest"])
self.stdout.write("Copied %s to %s" % (source, dest))