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