2020-08-03 16:59:21 +02:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
|
|
|
from drupal2spip_lal.base.convert import convert_node
|
|
|
|
from drupal2spip_lal.drupal.models import Node
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = "Import Drupal nodes to SPIP articles."
|
|
|
|
|
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument(
|
|
|
|
'--node',
|
|
|
|
nargs='*',
|
|
|
|
type=int,
|
|
|
|
help='Selects what nodes should be imported. Default is none.',
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
'--update',
|
|
|
|
action='store_true',
|
|
|
|
help='Force existing articles to be updated. Default is skip.',
|
|
|
|
)
|
2020-08-04 10:53:21 +02:00
|
|
|
parser.add_argument(
|
|
|
|
'--force-download',
|
|
|
|
action='store_true',
|
|
|
|
help='Force existing ressources to be downloaded. Default is skip.',
|
|
|
|
)
|
2020-08-03 16:59:21 +02:00
|
|
|
|
|
|
|
def handle(self, **options):
|
|
|
|
[
|
2020-08-04 10:53:21 +02:00
|
|
|
convert_node(n, options)
|
2020-08-03 16:59:21 +02:00
|
|
|
for n in Node.objects.filter(pk__in=options.get('node', []))
|
|
|
|
]
|