update meetings on CRI and CRICOM changes (#1225)
This commit is contained in:
parent
f4c476e716
commit
14f325d6ca
|
@ -938,6 +938,44 @@ class SyncFromPcfDbView(BrowserView):
|
||||||
notify(ObjectModifiedEvent(object))
|
notify(ObjectModifiedEvent(object))
|
||||||
self.publish(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:
|
if count % 100 == 0:
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
|
|
||||||
|
|
Reference in New Issue