From 7f3728e011df02effcaf16f6de175f87a4b121ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 4 Dec 2011 15:58:56 +0100 Subject: [PATCH] add import of related documents (#1079) --- themis/importexport/sync.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/themis/importexport/sync.py b/themis/importexport/sync.py index e9290d5..bb1587d 100644 --- a/themis/importexport/sync.py +++ b/themis/importexport/sync.py @@ -179,6 +179,36 @@ class SyncFromThemis(UtilityView): if data.get(attr): object.no = data.get(attr) + related_doc_ids = [] + for attr in ('cr_seance', 'documents_lies', 'bulletin_des_travaux', + 'bulletin_questions_ecrites', + 'courrier_reponse_accuse_de_reception', + 'cr_debats_declaration_politique_generale', + 'cr_debats_declaration_programme', + 'cr_reponse_orale', + 'cr_seance_ou_biq', + 'cr_seance_pleniere', + 'cr_seance_prise_en_consideration', + 'cr_seance_vote_motion', + 'cr_vote_declaration_programme', + 'lien_qo_ou_qe', + 'lien_vers_interpellation_ou_qe', + 'question__ecrite_lien', + 'rapport_de_commission'): + if not data.get(attr): + continue + related_doc_ids.extend(data.get(attr)) + if related_doc_ids: + related_docs = [] + for related_doc_id in related_doc_ids: + if hasattr(self.questions_folder, related_doc_id): + related_doc = getattr(self.questions_folder, related_doc_id) + elif hasattr(self.documents_folder, related_doc_id): + related_doc = getattr(self.documents_folder, related_doc_id) + else: + continue + related_docs.append(self.intids.getId(related_doc)) + object.related_docs = [RelationValue(x) for x in related_docs if x] if data.get('auteur'): value = data.get('auteur') if type(value) is list: