summaryrefslogtreecommitdiffstats
path: root/tabellio
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2011-11-03 14:03:16 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2011-11-03 14:03:16 (GMT)
commit37d2ac608bea26e4d5e85da8b2eb1efd4e5d8e53 (patch)
treed8fb6bd54ae7831a152249f14fbbe420a64565fb /tabellio
parent65f06c3b45da1be302b985dfccc141067054ab4b (diff)
downloadtabellio.pcfdb-37d2ac608bea26e4d5e85da8b2eb1efd4e5d8e53.zip
tabellio.pcfdb-37d2ac608bea26e4d5e85da8b2eb1efd4e5d8e53.tar.gz
tabellio.pcfdb-37d2ac608bea26e4d5e85da8b2eb1efd4e5d8e53.tar.bz2
import polgroups in dossiers, separate questions into their own step
Diffstat (limited to 'tabellio')
-rw-r--r--tabellio/pcfdb/sync.py39
1 files changed, 28 insertions, 11 deletions
diff --git a/tabellio/pcfdb/sync.py b/tabellio/pcfdb/sync.py
index 490b1ab..f5088bc 100644
--- a/tabellio/pcfdb/sync.py
+++ b/tabellio/pcfdb/sync.py
@@ -185,18 +185,18 @@ class SyncFromPcfDbView(BrowserView):
author_intid = self.intids.getId(obj)
return author_intid
- def get_document_intid(self, doc_id):
+ def get_document_and_intid(self, doc_id):
folder = self.documents_folder
try:
obj = getattr(folder, doc_id)
except AttributeError:
print 'missing doc', doc_id
- return None
+ return None, None
try:
- return self.intids.getId(obj)
+ return obj, self.intids.getId(obj)
except KeyError:
self.intids.register(obj)
- return self.intids.getId(obj)
+ return obj, self.intids.getId(obj)
_commission_intids = None
@@ -256,7 +256,7 @@ class SyncFromPcfDbView(BrowserView):
timestamp = self.request.form.get('timestamp')
objects = self.request.form.get('objects', '').split(',')
for object in ('polgroups', 'deputies', 'ministries', 'persons', 'commissions',
- 'documents', 'dossiers', 'reunions', 'deptables'):
+ 'documents', 'dossiers', 'questions', 'reunions', 'deptables'):
if not 'all' in objects:
if not object in objects:
continue
@@ -635,6 +635,9 @@ class SyncFromPcfDbView(BrowserView):
def sync_dossiers(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_dossier.ts > %s', (timestamp,))
@@ -643,7 +646,7 @@ class SyncFromPcfDbView(BrowserView):
cursor.execute('''SELECT t_dossier.id, t_dossier.st, t_dossier.type,
t_dossier.sess, t_dossier.no, t_dossier.intit,
t_dossier.auteurs, t_dossier.datedep,
- t_histo.curcom
+ t_histo.curcom, t_histo.comppols
FROM t_dossier JOIN t_histo
ON (t_dossier.id = t_histo.objid)
WHERE t_dossier.intit IS NOT NULL
@@ -655,7 +658,7 @@ class SyncFromPcfDbView(BrowserView):
row = cursor.fetchone()
if row is None:
break
- dos_id, state, dostype, sess, no, intit, authors, datedep, curcom = row
+ dos_id, state, dostype, sess, no, intit, authors, datedep, curcom, polgroups = row
print 'dos id:', dos_id
@@ -678,11 +681,25 @@ class SyncFromPcfDbView(BrowserView):
object.commissions = [RelationValue(self.get_commission_intid(x)) for x in curcom or []]
+ 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 = []
+
self.sync_dossier_history(object)
notify(ObjectModifiedEvent(object))
self.publish(object)
+ cursor.close()
+
+
+ def sync_questions(self, timestamp=None):
+ cursor = self.db_connection.cursor()
+
+ polgroups_id_to_title = self.get_polgroups_id_to_title(cursor)
+
### Handle t_qx
if timestamp:
where_ts = cursor.mogrify('AND ts > %s', (timestamp,))
@@ -756,7 +773,7 @@ class SyncFromPcfDbView(BrowserView):
notify(ObjectModifiedEvent(object))
self.publish(object)
-
+ cursor.close()
def sync_dossier_history(self, object):
@@ -790,10 +807,10 @@ class SyncFromPcfDbView(BrowserView):
else:
authors = []
if docid:
- docintid = self.get_document_intid(docid)
+ document, docintid = self.get_document_and_intid(docid)
else:
- docintid = None
- object.add_histoline(date, desc, authors, docintid, docpages)
+ document, docintid = None
+ object.add_histoline(date, desc, authors, docintid, document, docpages)
def sync_reunions(self, timestamp=None):
cursor = self.db_connection.cursor()