summaryrefslogtreecommitdiffstats
path: root/tabellio
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2011-11-03 10:04:01 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2011-11-03 10:04:01 (GMT)
commit54c0c1893446814da960a3d4e21499787e546c99 (patch)
tree735a87f1e6db1ce25b58355f66f7c6b29766f7ba /tabellio
parent280c61171e56126684d88fbf3c508b75b8286644 (diff)
downloadtabellio.pcfdb-54c0c1893446814da960a3d4e21499787e546c99.zip
tabellio.pcfdb-54c0c1893446814da960a3d4e21499787e546c99.tar.gz
tabellio.pcfdb-54c0c1893446814da960a3d4e21499787e546c99.tar.bz2
add political groups to documents
Diffstat (limited to 'tabellio')
-rw-r--r--tabellio/pcfdb/sync.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/tabellio/pcfdb/sync.py b/tabellio/pcfdb/sync.py
index 5ecc904..1a7c2c1 100644
--- a/tabellio/pcfdb/sync.py
+++ b/tabellio/pcfdb/sync.py
@@ -529,10 +529,13 @@ class SyncFromPcfDbView(BrowserView):
def sync_documents(self, timestamp=None):
cursor = self.db_connection.cursor()
+
+ polgroups_id_to_title = self.get_polgroups_id_to_title(cursor)
+
where_ts = ''
if timestamp:
where_ts = cursor.mogrify('AND t_document.ts > %s', (timestamp,))
- cursor.execute('''SELECT t_document.id, type, sess, date, no, nodoc, intit, auteurs, matiereids
+ cursor.execute('''SELECT t_document.id, type, sess, date, no, nodoc, intit, auteurs, matiereids, comppols
FROM t_document
JOIN t_typedoc
ON (t_document.type = t_typedoc.id)
@@ -545,7 +548,7 @@ class SyncFromPcfDbView(BrowserView):
row = cursor.fetchone()
if row is None:
break
- doc_id, doctype, sess, date, no, nodoc, intit, authors, subjects = row
+ doc_id, doctype, sess, date, no, nodoc, intit, authors, subjects, polgroups = row
if intit is None:
intit = {'RAPP': u'Rapport',
@@ -555,11 +558,11 @@ class SyncFromPcfDbView(BrowserView):
'ACA': u'''Avis d'une commission annexe''',
'RP-RACT': u'''Rapport d'activité''',
'BQR': u'Bulletin des questions et des réponses'
- }.get(type)
+ }.get(doctype)
- if intit is None:
- print 'missing intit, skipping', doc_id
- continue
+ if intit is None:
+ print 'missing intit, skipping', doc_id, ' (type was %s)' % doctype
+ continue
print 'doc id:', doc_id
@@ -580,6 +583,11 @@ class SyncFromPcfDbView(BrowserView):
print ' different number of authors'
else:
object.authors = []
+ if polgroups:
+ polgroups = [self.get_polgroup_intid(polgroups_id_to_title[x]) for x in polgroups]
+ object.polgroups = [RelationValue(x) for x in polgroups]
+ else:
+ object.polgroups = []
notify(ObjectModifiedEvent(object))
self.publish(object)