implement new django-based models and loadmappkg command

This commit is contained in:
Laura Klünder 2016-08-28 17:59:52 +02:00
parent 66661209d2
commit 752b7d6d7d
14 changed files with 318 additions and 196 deletions

View file

View file

@ -0,0 +1,19 @@
from django.core.management.base import BaseCommand, CommandError
from django.db import transaction
from ...packageio import MapPackagesIO
class Command(BaseCommand):
help = 'Load the given map packages into the database'
def add_arguments(self, parser):
parser.add_argument('mappkgdir', nargs='+', type=str, help='map package directories')
parser.add_argument('-y', action='store_const', const=True, default=False,
help='don\'t ask for confirmation')
def handle(self, *args, **options):
with transaction.atomic():
MapPackagesIO(options['mappkgdir']).update_to_db()
print()
if input('Confirm (y/N): ') != 'y':
raise CommandError('Aborted.')