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)
|
'Article {} updated from node {}.'.format(article.pk, node.pk)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
logger.info(
|
||||||
|
'Skipped node {}. Try --update to update it.'.format(node.pk)
|
||||||
|
)
|
||||||
|
|
||||||
if article:
|
if article:
|
||||||
user_attributes = {
|
user_attributes = {
|
||||||
'nom': node.user.name,
|
'nom': node.user.name,
|
||||||
|
|
|
@ -12,11 +12,17 @@ class Command(BaseCommand):
|
||||||
help = "Import Drupal nodes to SPIP articles."
|
help = "Import Drupal nodes to SPIP articles."
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
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(
|
parser.add_argument(
|
||||||
'--node',
|
'--node',
|
||||||
nargs='*',
|
nargs='*',
|
||||||
type=int,
|
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(
|
parser.add_argument(
|
||||||
'--update',
|
'--update',
|
||||||
|
@ -30,7 +36,13 @@ class Command(BaseCommand):
|
||||||
)
|
)
|
||||||
|
|
||||||
def handle(self, **options):
|
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:
|
try:
|
||||||
convert_node(n, options)
|
convert_node(n, options)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in New Issue