From b07a3bc3892fe68a68c97d3dcdf63426db3270c3 Mon Sep 17 00:00:00 2001
From: Laurent Peuch <cortex@worlddomination.be>
Date: Sat, 22 Jun 2013 15:39:37 +0200
Subject: [PATCH] [enh] export personal data of a representative

---
 .../management/commands/export_in_representatives_format.py  | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/representatives/management/commands/export_in_representatives_format.py b/representatives/management/commands/export_in_representatives_format.py
index 0a81765..2a30917 100644
--- a/representatives/management/commands/export_in_representatives_format.py
+++ b/representatives/management/commands/export_in_representatives_format.py
@@ -8,8 +8,13 @@ class Command(BaseCommand):
 
     def handle(self, *args, **options):
         result = []
+        personal_fields = ("first_name", "last_name", "full_name", "birth_place", "cv")
+        gender_dict = dict(Representative.GENDER)
         for representative in Representative.objects.all():
             reps = {"id": representative.remote_id}
+            reps["personal"] = {field: getattr(representative, field) for field in personal_fields}
+            reps["personal"]["gender"] = gender_dict[representative.gender]
+            reps["personal"]["birth_date"] = representative.birth_date.strftime("%F") if representative.birth_date else None
 
             result.append(reps)
 
-- 
GitLab