feat(import): ajoute l option --user
This commit is contained in:
parent
db6bd48e20
commit
7ce36668ea
@ -209,6 +209,11 @@ def convert_node(node, options):
|
||||
'Article {} updated from node {}.'.format(article.pk, node.pk)
|
||||
)
|
||||
|
||||
else:
|
||||
logger.info(
|
||||
'Skipped node {}. Try --update to update it.'.format(node.pk)
|
||||
)
|
||||
|
||||
if article:
|
||||
user_attributes = {
|
||||
'nom': node.user.name,
|
||||
|
@ -12,11 +12,17 @@ class Command(BaseCommand):
|
||||
help = "Import Drupal nodes to SPIP articles."
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--user',
|
||||
nargs='*',
|
||||
type=str,
|
||||
help='Selects users nodes to be imported. Default is nobody.',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--node',
|
||||
nargs='*',
|
||||
type=int,
|
||||
help='Selects what nodes should be imported. Default is none.',
|
||||
help='Selects what nodes to be imported. Default is none.',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--update',
|
||||
@ -30,7 +36,13 @@ class Command(BaseCommand):
|
||||
)
|
||||
|
||||
def handle(self, **options):
|
||||
for n in Node.objects.filter(pk__in=options.get('node', [])):
|
||||
qs = Node.objects.none()
|
||||
if options['node']:
|
||||
qs |= Node.objects.filter(pk__in=options['node'])
|
||||
if options['user']:
|
||||
qs |= Node.objects.filter(user__name__in=options['user'])
|
||||
|
||||
for n in qs:
|
||||
try:
|
||||
convert_node(n, options)
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user