summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2012-01-18 13:26:02 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2012-01-18 13:27:39 (GMT)
commit14f325d6caff097b887873cb9f7b06f8b317f147 (patch)
treecb29a217ab35744d1d150c22ae841f34fa939ecd
parentf4c476e7168a8c7224c2ff234c61d00e11870c3a (diff)
downloadtabellio.pcfdb-14f325d6caff097b887873cb9f7b06f8b317f147.zip
tabellio.pcfdb-14f325d6caff097b887873cb9f7b06f8b317f147.tar.gz
tabellio.pcfdb-14f325d6caff097b887873cb9f7b06f8b317f147.tar.bz2
update meetings on CRI and CRICOM changes (#1225)
-rw-r--r--tabellio/pcfdb/sync.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tabellio/pcfdb/sync.py b/tabellio/pcfdb/sync.py
index b05b27d..0334de2 100644
--- a/tabellio/pcfdb/sync.py
+++ b/tabellio/pcfdb/sync.py
@@ -938,6 +938,44 @@ class SyncFromPcfDbView(BrowserView):
notify(ObjectModifiedEvent(object))
self.publish(object)
+ if doctype in ('CRI', 'CRICOM'):
+ # we eventually have a meeting to update
+ meeting_cursor = self.db_connection.cursor()
+ if doctype == 'CRICOM':
+ nocric = object.no.split('-')[0]
+ try:
+ nocric, com_code, nocricom = re.match(r'(\d+)-(.*)(\d+)', object.no).groups()
+ except AttributeError:
+ # make sure we do not get anything afterwards
+ nocric, com_code, nocricom = '999', 'XXX', '999'
+ meeting_query = meeting_cursor.mogrify(
+ '''SELECT t_reunion.id FROM t_reunion
+ LEFT JOIN t_com ON (t_reunion.comid = t_com.id)
+ WHERE t_reunion.sess = %s
+ AND t_reunion.type = 'CO'
+ AND nocric = %s
+ AND nocricom = %s
+ AND t_com.code = %s''',
+ (sess, nocric, nocricom, com_code))
+ else:
+ meeting_query = meeting_cursor.mogrify(
+ '''SELECT t_reunion.id FROM t_reunion
+ WHERE sess = %s
+ AND type = 'SE'
+ AND nocri = %s''',
+ (sess, object.no))
+ meeting_cursor.execute(meeting_query)
+ row = meeting_cursor.fetchone()
+ if row:
+ meeting_id = row[0]
+ print ' going to update meeting:', meeting_id
+ if hasattr(self.parlevents_folder, meeting_id):
+ meeting = getattr(self.parlevents_folder, meeting_id)
+ if meeting.cri is None:
+ doc_intid = self.intids.getId(object)
+ meeting.cri = RelationValue(doc_intid)
+ meeting_cursor.close()
+
if count % 100 == 0:
transaction.commit()