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
7ea13aa8
Commit
7ea13aa8
authored
Sep 18, 2013
by
Bram
Browse files
[enh] import_representatives_no_preserve works if representatives aren't in the db already
parent
c44b538a
Changes
1
Hide whitespace changes
Inline
Side-by-side
representatives/management/commands/import_representatives_no_preserve.py
View file @
7ea13aa8
...
...
@@ -23,7 +23,13 @@ class Command(BaseCommand):
sys
.
stdout
.
write
(
"%s/%s
\r
"
%
(
a
,
end
))
sys
.
stdout
.
flush
()
remote_id
=
reps
[
"id"
]
representative
=
Representative
.
objects
.
get
(
remote_id
=
remote_id
)
representative
=
Representative
.
objects
.
filter
(
remote_id
=
remote_id
)
if
representative
:
representative
=
representative
[
0
]
else
:
representative
=
Representative
()
representative
.
remote_id
=
remote_id
representative
.
first_name
=
reps
[
"personal"
][
"first_name"
]
representative
.
last_name
=
reps
[
"personal"
][
"last_name"
]
representative
.
full_name
=
reps
[
"personal"
][
"full_name"
]
...
...
@@ -32,6 +38,8 @@ class Command(BaseCommand):
representative
.
cv
=
reps
[
"personal"
][
"cv"
]
representative
.
gender
=
reverted_gender_dict
[
reps
[
"personal"
][
"gender"
]]
representative
.
save
()
representative
.
email_set
.
all
().
delete
()
for
email
in
reps
[
"contact"
][
"emails"
]:
representative
.
email_set
.
create
(
...
...
Write
Preview
Markdown
is supported
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