summaryrefslogtreecommitdiffstats
path: root/tabellio
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2011-11-11 15:27:49 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2011-11-11 15:27:49 (GMT)
commit9d15ee4b120ca75a0673b0ec6d45910bfb1301ef (patch)
treebde462f8a5b699451e24c8b76ecaca3636e7f543 /tabellio
parent3d56779508b1d467590a7b9bc93392d78f57a22c (diff)
downloadtabellio.pcfdb-9d15ee4b120ca75a0673b0ec6d45910bfb1301ef.zip
tabellio.pcfdb-9d15ee4b120ca75a0673b0ec6d45910bfb1301ef.tar.gz
tabellio.pcfdb-9d15ee4b120ca75a0673b0ec6d45910bfb1301ef.tar.bz2
add code to synchronise thesaurus
Diffstat (limited to 'tabellio')
-rw-r--r--tabellio/pcfdb/sync.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tabellio/pcfdb/sync.py b/tabellio/pcfdb/sync.py
index 65f4cfa..04e1ba1 100644
--- a/tabellio/pcfdb/sync.py
+++ b/tabellio/pcfdb/sync.py
@@ -300,7 +300,7 @@ class SyncFromPcfDbView(BrowserView):
objects = self.request.form.get('objects', '').split(',')
report = []
for object in ('polgroups', 'sessions', 'deputies', 'ministries', 'persons', 'commissions',
- 'documents', 'dossiers', 'questions', 'reunions', 'deptables'):
+ 'documents', 'dossiers', 'questions', 'reunions', 'deptables', 'thesaurus'):
if not 'all' in objects:
if not object in objects:
continue
@@ -359,6 +359,29 @@ class SyncFromPcfDbView(BrowserView):
return 'OK'
+ def sync_thesaurus(self, timestamp=None):
+ cursor = self.db_connection.cursor()
+
+ cursor.execute('''SELECT t_thesaurus_term.id, t_thesaurus_term.term
+ FROM t_thesaurus_term
+ WHERE NOT EXISTS (
+ SELECT * FROM t_thesaurus_rel
+ WHERE sectermid = t_thesaurus_term.id
+ AND t_thesaurus_rel.rel in ('HN', 'SN'))''')
+ terms = []
+ while True:
+ row = cursor.fetchone()
+ if row is None:
+ break
+ terms.append('%s|%s' % row)
+
+ cursor.close()
+
+ self.settings.topics = '\n'.join(terms)
+
+ return 'OK'
+
+
def sync_polgroups(self, timestamp=None):
cursor = self.db_connection.cursor()