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
memopol
Commits
184819a8
Commit
184819a8
authored
Jun 03, 2016
by
Nicolas Joyard
Browse files
Give a title to untitled recommendations
parent
233f7349
Changes
1
Hide whitespace changes
Inline
Side-by-side
representatives_recommendations/contrib/import_recommendations.py
View file @
184819a8
...
...
@@ -24,9 +24,9 @@ class RecommendationImporter:
if
dossier
is
None
:
ref
=
dossier_mappings
.
get
(
title
,
None
)
if
ref
is
not
None
:
query
=
{
'reference'
:
ref
}
query
=
{
'reference'
:
ref
}
else
:
query
=
{
'title__iexact'
:
title
}
query
=
{
'title__iexact'
:
title
}
try
:
dossier
=
Dossier
.
objects
.
get
(
**
query
)
...
...
@@ -67,6 +67,9 @@ class RecommendationImporter:
return
False
weight
=
int
(
row
[
'weight'
])
*
int
(
row
[
'ponderation'
])
descr
=
row
[
'description'
].
strip
()
if
len
(
descr
)
==
0
:
descr
=
'%s on %s'
%
(
row
[
'part'
],
dossier
.
reference
)
try
:
recom
=
Recommendation
.
objects
.
get
(
proposal
=
proposal
)
...
...
@@ -74,7 +77,7 @@ class RecommendationImporter:
recom
=
Recommendation
(
proposal
=
proposal
,
recommendation
=
row
[
'recommendation'
],
title
=
row
[
'description'
]
,
title
=
descr
,
weight
=
weight
)
recom
.
save
()
...
...
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