From d36bbcf398a1d2893a17110af792e576ac613853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Poulain?= Date: Tue, 4 Aug 2020 09:37:22 +0200 Subject: [PATCH] =?UTF-8?q?feat(convert):=20ajoute=20les=20mots=20cl=C3=A9?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- drupal2spip_lal/base/convert.py | 22 +++++++++++++++++-- .../base/management/commands/inspectdb.py | 14 ++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/drupal2spip_lal/base/convert.py b/drupal2spip_lal/base/convert.py index 88bbe18..ca5ab3d 100644 --- a/drupal2spip_lal/base/convert.py +++ b/drupal2spip_lal/base/convert.py @@ -4,7 +4,7 @@ from datetime import datetime from itertools import groupby from django.conf import settings -from django.utils.timezone import make_aware +from django.utils.timezone import make_aware, now import request from bs4 import BeautifulSoup as bs @@ -165,8 +165,26 @@ def convert_node(node, update=False): login=node.user.name, defaults=user_attributes ) - spip.AuteursLiens.objects.update_or_create( + spip.AuteursLiens.objects.get_or_create( auteur=auteur, id_objet=article.pk, objet='article' ) fetch_and_remove_logo(article) + + for term_node in node.termnode_set.all(): + groupe, _ = spip.GroupesMots.objects.get_or_create( + titre=term_node.data.theme.name, + descriptif=term_node.data.theme.description, + texte=term_node.data.theme.help, + defaults={'maj': now}, + ) + mot, _ = spip.Mots.objects.get_or_create( + groupe=groupe, + type=groupe.titre, + titre=term_node.data.name, + descriptif=term_node.data.description, + defaults={'maj': now}, + ) + spip.MotsLiens.objects.get_or_create( + mot=mot, id_objet=article.pk, objet='article' + ) diff --git a/drupal2spip_lal/base/management/commands/inspectdb.py b/drupal2spip_lal/base/management/commands/inspectdb.py index 4192946..b646f91 100644 --- a/drupal2spip_lal/base/management/commands/inspectdb.py +++ b/drupal2spip_lal/base/management/commands/inspectdb.py @@ -91,6 +91,12 @@ DB_RELATIONS = { 'auteurs_liens': { 'id_auteur': ('id_auteur', 'auteurs', 'auteur'), }, + 'mots': { + 'id_groupe': ('id_groupe', 'groupes_mots', 'groupe'), + }, + 'mots_liens': { + 'id_mot': ('id_mot', 'mots', 'mot'), + }, }, } @@ -148,6 +154,14 @@ DB_PARAMS = { 'auteurs_liens': { 'vu': {'default': 'non'}, }, + 'groupes_mots': { + 'unseul': {'default': 'non'}, + 'obligatoire': {'default': 'non'}, + 'tables_liees': {'default': 'articles'}, + 'minirezo': {'default': 'oui'}, + 'comite': {'default': 'oui'}, + 'forum': {'default': 'non'}, + }, 'urls': { 'id_parent': {'default': 0}, 'langue': {'default': ''},