Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
campaign
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
piphone
campaign
Commits
e77669eb
Commit
e77669eb
authored
Aug 08, 2016
by
okhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix
#1
: Importing the meps is now working
parent
151f9eb2
Pipeline
#101
failed with stage
in 48 seconds
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
picampaign/importer/models.py
picampaign/importer/models.py
+12
-7
No files found.
picampaign/importer/models.py
View file @
e77669eb
...
...
@@ -83,7 +83,7 @@ class Importer(models.Model):
# We do not have enough field to discriminate our meps
continue
updated_mep
=
{}
updated_mep
[
'groups'
]
=
[]
groups
=
[]
for
mandate
in
import_mep
[
'mandates'
]:
# Parltrack gives us a date starting with 9999 if ends has not happens
# FranceData gives us an empty one
...
...
@@ -94,18 +94,20 @@ class Importer(models.Model):
if
not
(
end_date
==
''
or
end_date
.
startswith
(
'9999'
)):
# This mandate has ended
continue
#import ipdb; ipdb.set_trace()
groupType
,
added
=
GroupType
.
objects
.
get_or_create
(
organization
=
self
.
organization
,
name
=
mandate
[
'group'
][
'kind'
])
# We want to only use the groups nown by the organisation
try
:
groupType
=
GroupType
.
objects
.
get
(
organization
=
self
.
organization
,
name
=
mandate
[
'group'
][
'kind'
])
except
:
continue
if
'abbreviation'
in
mandate
[
'group'
]:
group
,
added
=
Group
.
objects
.
get_or_create
(
name
=
mandate
[
'group'
][
'abbreviation'
],
type
=
groupType
)
else
:
group
,
added
=
Group
.
objects
.
get_or_create
(
name
=
mandate
[
'group'
][
'name'
],
type
=
groupType
)
updated_mep
[
'groups'
].
append
(
group
)
#import ipdb; ipdb.set_trace()
if
updated_mep
[
'groups'
]
==
[]:
groups
.
append
(
group
)
if
groups
==
[]:
# The mep have no groups active, he is not to be bothered.
continue
...
...
@@ -146,6 +148,9 @@ class Importer(models.Model):
for
phone
in
phones
:
mep
.
phones
.
get_or_create
(
phone
=
phone
)
# Let's link the MEP to the group
mep
.
groups
=
groups
mep
.
save
()
# We want to link the mep to our current campaign
CampaignContact
(
campaign
=
self
.
campaign
,
contact
=
mep
).
save
()
inserted
+=
1
...
...
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