diff --git a/akvo/rsr/static/scripts-src/my-projects.js b/akvo/rsr/static/scripts-src/my-projects.js index 5c78e8f7c7..fe060c061a 100644 --- a/akvo/rsr/static/scripts-src/my-projects.js +++ b/akvo/rsr/static/scripts-src/my-projects.js @@ -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('{}'); diff --git a/akvo/rsr/views/my_rsr.py b/akvo/rsr/views/my_rsr.py index 7bc7fea795..92a0fccda6 100644 --- a/akvo/rsr/views/my_rsr.py +++ b/akvo/rsr/views/my_rsr.py @@ -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, @@ -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) diff --git a/akvo/templates/myrsr/my_projects.html b/akvo/templates/myrsr/my_projects.html index c34bf6fd1f..33951db809 100644 --- a/akvo/templates/myrsr/my_projects.html +++ b/akvo/templates/myrsr/my_projects.html @@ -121,7 +121,7 @@