speakers and reporters lists synchronized

This commit is contained in:
Serghei Mihai 2013-11-14 14:14:35 +01:00
parent fcb14990ae
commit 2237774cf8
No known key found for this signature in database
GPG Key ID: 76D1C964BF2FA1AF
1 changed files with 20 additions and 0 deletions

View File

@ -237,6 +237,26 @@ class SyncFromThemis(UtilityView):
datetime.datetime.strptime(
data.get(attr), '%Y-%m-%d').toordinal())
# initializing speakers list
if not object.speakers:
object.speakers = []
for attr in ('orateurs_seance', 'orateurs', 'orateurs_en_commission',
'orateurs_en_seanceprop', 'orateurs_rapportcom',
'orateurs_seance_reponse_orale'):
if data.get(attr):
speakers = data.get(attr)
# check if the speakers is a list, which is not a case if
# the field is of type 'Ministry or Deputy'
if isinstance(speakers, list):
object.speakers = list(set(object.speakers + speakers))
else:
if speakers not in object.speakers:
object.speakers.append(speakers)
if data.get('rapporteurs'):
object.reporters = data.get(attr)
if data.get('date_sanction_promulgation'):
object.sanction_date = datetime.date.fromordinal(
datetime.datetime.strptime(