Update module
This commit is contained in:
parent
018d9f6557
commit
ea427d6451
|
|
@ -9,20 +9,28 @@ from transfer.utils import transfer_objects
|
|||
class Command(BaseCommand):
|
||||
help = 'Transfer data between databases'
|
||||
|
||||
types = [
|
||||
'dictionaries',
|
||||
'keys'
|
||||
]
|
||||
|
||||
def handle(self, *args, **options):
|
||||
option = set(options.keys()) & set(self.types)
|
||||
print(option)
|
||||
if options['dictionaries']:
|
||||
self._transfer_dictionaries()
|
||||
self._transfer_objects()
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'-d',
|
||||
'--dictionaries',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Вывод короткого сообщения'
|
||||
)
|
||||
for type in self.types:
|
||||
parser.add_argument(
|
||||
f'-{type[:1]}',
|
||||
f'--{type}',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help=f'Transfer {type} objects'
|
||||
)
|
||||
|
||||
def _transfer_dictionaries(self):
|
||||
def _transfer_objects(self):
|
||||
for app in apps.get_app_configs():
|
||||
if exists(f"{app.path}/transfer.py"):
|
||||
card_module = SourceFileLoader("transfer", f"{app.path}/transfer.py").load_module()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
def transfer_objects(app, transfer_card):
|
||||
print(app)
|
||||
for model, card in transfer_card.items():
|
||||
print(model)
|
||||
print(f"\t{card}")
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user