Skip to content

Commit

Permalink
Merge pull request #1823 from akvo/#1817-multiple-organisations
Browse files Browse the repository at this point in the history
[#1817] Fix multiple employments in My projects issue
  • Loading branch information
KasperBrandt committed Oct 5, 2015
2 parents d864917 + c8b1d3f commit 8fcbaad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion akvo/rsr/static/scripts-src/my-projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function getCreateProject(createProjectNode) {
// Set reporting partner by default
partners = defaultValues.employments;

if (partners.length === 1) {
if (partners.length > 0) {
request.send('{"sync_owner": ' + partners[0] + '}');
} else {
request.send('{}');
Expand Down
8 changes: 8 additions & 0 deletions akvo/rsr/views/my_rsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ def my_projects(request):
page = request.GET.get('page')
page, paginator, page_range = pagination(page, projects, 10)

# User's organisations that are reportable
approved_employments = request.user.approved_employments()
reportable_organisations = []
for employment in approved_employments:
if employment.organisation.can_become_reporting:
reportable_organisations.append(employment.organisation.id)

context = {
'organisations': organisations,
'new_project_custom_fields': new_project_custom_fields,
Expand All @@ -147,6 +154,7 @@ def my_projects(request):
'page_range': page_range,
'q': filter_query_string(qs),
'q_search': q,
'reportable_organisations': reportable_organisations
}
return render(request, 'myrsr/my_projects.html', context)

Expand Down
2 changes: 1 addition & 1 deletion akvo/templates/myrsr/my_projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ <h4 class="media-heading">{% if project.title %}{{ project.title }}{% else %}&lt

<script type="application/json" id="default-values">
{
"employments": [{% for employment in user.employers.all %}{{ employment.organisation.id }}{% if not forloop.last %}, {% endif %}{% endfor %}],
"employments": {{ reportable_organisations }},
"new_project_custom_fields": [{% for field in new_project_custom_fields %}{"name": "{{ field.name }}", "type": "{{ field.type }}", "section": {{ field.section }}, "order": {{ field.order }}, "max_characters": {% if field.max_characters %}{{ field.max_characters }}{% else %}0{% endif %}, "mandatory": {% if field.mandatory %}true{% else %}false{% endif %}, "help_text": "{{ field.help_text|linebreaksbr }}"}{% if not forloop.last %}, {% endif %}{% endfor %}]
}
</script>
Expand Down

0 comments on commit 8fcbaad

Please sign in to comment.