Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Political Memory
django-representatives
Commits
b07a3bc3
Commit
b07a3bc3
authored
Jun 22, 2013
by
Bram
Browse files
[enh] export personal data of a representative
parent
3cabf7cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
representatives/management/commands/export_in_representatives_format.py
View file @
b07a3bc3
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment